-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Consider sharing diagnostics issued by JSON source generator with reflection-based serializer #61262
Comments
Tagging subscribers to this area: @dotnet/area-system-text-json Issue DetailsMany of the diagnostics issued by the JSON source generator are also applicable to the reflection-based serializer. For example, a type cannot contain multiple Rather than having different behavior, we could package these diagnostic examinations into an analyzer that could be shared between the source generator and the reflection serializer, potentially giving the reflection serializer less validation work to do at runtime. We'd have to consider where this analyzer would live. There are a couple options
The source generator would be dependent on the analyzer, so we'd need to ship the analyzer in a manner that guarantees its visibility to the source generator. cc @dotnet/area-system-text-json @jeffhandley
|
The new DllImportImportGenerator is same analyzer + source generator bundle. @jkoritzinsky Is that right? |
Yes that is correct. We have both analyzers and generators in the DllImportGenerator assembly in dotnet/runtime. |
Great, will look into how this is wired up. |
Moving to Future, as we won't have time to work on this in the .NET 7 timeframe. |
Many of the diagnostics issued by the JSON source generator are also applicable to the reflection-based serializer. For example, a type cannot contain multiple
[JsonConstructor]
applications. When the source generator is used, it logs a compile error when a type violates this expectation. A runtime exception is thrown in the reflection-based serializer instead.Rather than having different behavior, we could package these diagnostic examinations into an analyzer that could be shared between the source generator and the reflection serializer, potentially giving the reflection serializer less validation work to do at runtime. We'd have to consider where this analyzer would live. There are a couple options
(becoming the first analyzer to be shipped in the dotnet/runtime repo)The source generator would be dependent on the analyzer, so we'd need to ship the analyzer in a manner that guarantees its visibility to the source generator.
cc @dotnet/area-system-text-json @jeffhandley
The text was updated successfully, but these errors were encountered: