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

[release/6.0] Disable fast path serialization for types with properties using custom converters. #58571

Merged
merged 1 commit into from
Sep 3, 2021

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Sep 2, 2021

Backport of #58291 to release/6.0

/cc @steveharter @eiriktsarpalis

Customer Impact

If a serializable POCO has a property that specifies a custom converter, the property was ignored instead of being serialized with the custom converter.

Testing

Tests added to cover the scenario.

Risk

If [JsonSourceGenerationOptions(GenerationMode =JsonSourceGenerationMode.Serialization)] is used on the context class, a run-time error will now occur. This is consistent with other features that aren't supported in the "fast path". To fix this, JsonSourceGenerationMode.Default or JsonSourceGenerationMode.Metadata should be used instead.

@ghost
Copy link

ghost commented Sep 2, 2021

Tagging subscribers to this area: @eiriktsarpalis, @layomia
See info in area-owners.md if you want to be subscribed.

Issue Details

Backport of #58291 to release/6.0

/cc @steveharter @eiriktsarpalis

Customer Impact

Testing

Risk

Author: github-actions[bot]
Assignees: -
Labels:

area-System.Text.Json

Milestone: -

@danmoseley
Copy link
Member

Requires affected consumers to not use JsonSourceGenerationMode.Serialization to disable the fast path. Instead, JsonSourceGenerationMode.Default or JsonSourceGenerationMode.Metadata should be used.

can you clarify this? it's not as simple as "if we see this pattern fast path can't support, we silently dont use fast path"?

@steveharter
Copy link
Member

can you clarify this? it's not as simple as "if we see this pattern fast path can't support, we silently dont use fast path"?

Changed the wording and added some clarification. A run-time error will now occur (although a compile-time error I think would be better, but that is a separate discussion). cc @layomia @eiriktsarpalis

@@ -790,7 +790,7 @@ private string GenerateFastPathFuncForObject(TypeGenerationSpec typeGenSpec)
out Dictionary<string, PropertyGenerationSpec>? serializableProperties,
out bool castingRequiredForProps))
{
string exceptionMessage = @$"""Invalid serializable-property configuration specified for type '{typeRef}'. For more information, use 'JsonSourceGenerationMode.Serialization'.""";
string exceptionMessage = @$"""Invalid serializable-property configuration specified for type '{typeRef}'. For more information, see 'JsonSourceGenerationMode.Serialization'.""";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be in \src\libraries\System.Text.Json\gen\Resources\Strings.resx?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't need fixing in this PR, since it's pre existing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is tracked by #58292. We should fix for 6.

@danmoseley
Copy link
Member

Approved. Localized fix to customer reported issue in new feature, helping customers be successful with that feature.

Do you want me to merge?

@eiriktsarpalis
Copy link
Member

Do you want me to merge?

Yes please

@danmoseley danmoseley merged commit ea48ccc into release/6.0 Sep 3, 2021
@danmoseley danmoseley deleted the backport/pr-58291-to-release/6.0 branch September 3, 2021 18:59
@ghost ghost locked as resolved and limited conversation to collaborators Oct 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants