Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JsonSerializer IgnoreReadOnlyProperties Not Working for Enumerable Properties #95080

Closed
KatoFett opened this issue Nov 21, 2023 · 2 comments
Closed

Comments

@KatoFett
Copy link

Description

When serializing an object via the System.Text.Json.JsonSerializer, readonly enumerable properties are serialized regardless of IgnoreReadOnlyProperties set to True.

Reproduction Steps

.NET Fiddle

Expected behavior

All readonly properties are ignored.

Actual behavior

If the property's type is enumerable, it is serialized anyway.

Regression?

No

Known Workarounds

No response

Configuration

.NET 7, tested on 8 with .NET Fiddle

Other information

No response

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Nov 21, 2023
@ghost
Copy link

ghost commented Nov 21, 2023

Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

When serializing an object via the System.Text.Json.JsonSerializer, readonly enumerable properties are serialized regardless of IgnoreReadOnlyProperties set to True.

Reproduction Steps

.NET Fiddle

Expected behavior

All readonly properties are ignored.

Actual behavior

If the property's type is enumerable, it is serialized anyway.

Regression?

No

Known Workarounds

No response

Configuration

.NET 7, tested on 8 with .NET Fiddle

Other information

No response

Author: KatoFett
Assignees: -
Labels:

area-System.Text.Json, untriaged

Milestone: -

@eiriktsarpalis
Copy link
Member

Duplicate of #80113

@eiriktsarpalis eiriktsarpalis marked this as a duplicate of #80113 Nov 22, 2023
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Nov 22, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Dec 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants