You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
JSON source generator emits CS0612 warnings if serialized types use [Obsolete] #76829
The JSON source generator should not trigger warnings when used with obsolete types. See #62076, which only fixed the bug when the Obsolete attribute includes a message.
Reproduction Steps
Same as #62076, but with [Obsolete] instead of [Obsolete("Use NewValue instead")].
If we do something for CS0612, then we would also need to be able to address obsoletions with custom diagnostic IDs, which can be SYSLIB values or user-defined diagnostics.
Even more generally... what if our generated code triggers a diagnostic from a completely different diagnostic, even one that is user-defined and intentionally running over generated code? How would customers suppress any arbitrary diagnostic within our generated code? How would that be configured?
Alternatively we could employ a convention where suppressions active in the partial class are applied to the extra generated code:
#pragma warning disable CS0618// gets replicated in all generated instantiations of the partial class[JsonSerializable(typeof(Foo))]publicpartialclassMyContext:JsonSerializerContext{}
#pragma warning restore CS0618
Activity
layomia commentedon Dec 2, 2022
Up for grabs. Same fix as #63496, but we're disabling
CS0612warnings this time.jeffhandley commentedon Dec 13, 2022
If we do something for
CS0612, then we would also need to be able to address obsoletions with custom diagnostic IDs, which can beSYSLIBvalues or user-defined diagnostics.jeffhandley commentedon Dec 13, 2022
Even more generally... what if our generated code triggers a diagnostic from a completely different diagnostic, even one that is user-defined and intentionally running over generated code? How would customers suppress any arbitrary diagnostic within our generated code? How would that be configured?
eiriktsarpalis commentedon Dec 13, 2022
This could be added to the existing
JsonSourceGenerationOptionsAttributevia a new property:The source generator reads that attribute at compile time to configure source gen. Usage of the new property would look as follows:
eiriktsarpalis commentedon Dec 13, 2022
Alternatively we could employ a convention where suppressions active in the partial class are applied to the extra generated code:
Hellevar commentedon Jan 10, 2023
Hi, @eiriktsarpalis !
Is it a final shape of expected API, so it can be implemented in a such way, or should it go through api review process as per https://github.com/dotnet/runtime/blob/main/docs/project/api-review-process.md ?
eiriktsarpalis commentedon Jan 10, 2023
@Hellevar this needs to go through API review before an implementation PR can be submitted.
Fix dotnet#76829.
Make a number of improvements to the System.Text.Json source generator (