-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
STJ fast-path generator does not always deduplicate shadowed members correctly. #98634
Comments
Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis Issue DetailsDescriptionSystem.Text.Json source generator is generating code which fails to compile if the following conditions are met:
Reproduction StepsFollowing code demonstrates the problem
Expected behaviorGenerated code should have no compilation errors. Actual behaviorGenerated code has 2 locals with the same name.
Regression?Not sure Known WorkaroundsNo response ConfigurationUsing .net 8, Windows 10, x64. Other informationNo response
|
This isn't related to polymorphism per se, here's a minimal reproduction: partial class BaseType
{
public string? MoreData { get; set; }
}
partial class DerivedType : BaseType
{
[JsonPropertyName("MoreData2")]
public new string? MoreData { get; set; }
}
[JsonSerializable(typeof(DerivedType))]
[JsonSourceGenerationOptions(DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)]
partial class MyContext : JsonSerializerContext; TL;DR the fast-path serializer isn't correctly deduplicating shadowed members when the shadowing type uses a custom property name. Related to #97621 |
Description
System.Text.Json source generator is generating code which fails to compile if the following conditions are met:
[JsonSourceGenerationOptions(DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)]
Reproduction Steps
Following code demonstrates the problem
Expected behavior
Generated code should have no compilation errors.
Actual behavior
Generated code has 2 locals with the same name.
Regression?
Not sure
Known Workarounds
No response
Configuration
Using .net 8, Windows 10, x64.
Other information
No response
The text was updated successfully, but these errors were encountered: