Closed grbell-ms closed 1 month ago
Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis See info in area-owners.md if you want to be subscribed.
I can reproduce. What's odd is that absolutely cannot reduce this to a smaller repro. Removing anything from your code makes the error just go away.
Description
Using source generation with a combination of case insensitive property names, ignored properties, and
JsonPropertyNameAttribute
with the same explicit name as an ignored property fails to compile.Reproduction Steps
Try to compile this:
Expected behavior
Compilation succeeds.
Actual behavior
Compilation fails with the error message:
CS0128 A local variable or function named '__value_SystemTextJsonIPAddresses' is already defined in this scope ClassLibrary1 D:\ClassLibrary1\ClassLibrary1\System.Text.Json.SourceGeneration\System.Text.Json.SourceGeneration.JsonSourceGenerator\SourceGenerationContext.Config2.g.cs
The generated code looks like this:
Regression?
No.
Known Workarounds
Reorder the properties so that the ignored properties come after the corresponding explicitly named property.
Configuration
No response
Other information
No response