Closed canton7 closed 2 years ago
Tagging subscribers to this area: @dotnet/area-system-text-json See info in area-owners.md if you want to be subscribed.
Author: | canton7 |
---|---|
Assignees: | - |
Labels: | `area-System.Text.Json`, `untriaged` |
Milestone: | - |
This is a bug since the generator is produced invalid syntax. Do you have any scenario/reason for making your context type generic?
Same underlying issue as https://github.com/dotnet/runtime/issues/62762.
Description
If the
JsonSerializerContext
given to the System.Text.Json source generator is generic, the source generator generates some very odd code.Reproduction Steps
Create a .NET 6 project containing the following, and look at the source generated by the System.Text.Json source generator:
Expected behavior
The source generator either produces a diagnostic saying that generic contexts aren't supported (and does not attempt to generate source), or the source generated is valid C#.
Actual behavior
It's a mix of things.
The class declaration itself is non-generic:
The default context is sort-of generic, but is confused about what a generic type parameter is:
The constructors are invalid C#:
Regression?
No
Known Workarounds
None
Configuration
.NET 6, Visual Studio 17.2.0 Preview 1.0.
Other information
No response