-
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
Use of JsonSerializerContext Can Cause CS1591 #61379
Comments
Tagging subscribers to this area: @dotnet/area-system-text-json Issue DetailsDescriptionUsing
You cannot suppress
You also cannot disable the warning in source because the source code is generated in a separate file. It looks like the generated source code needs to include some suppressions.
The only workaround seems to be to globally disable this warning in the project
Configuration.NET SDK 6.0.100 Other informationSee also:
|
Would marking your class |
Thats another great workaround. |
Related to dotnet/roslyn#54119 |
Marking as 7.0 since the workaround here seems acceptable. We could augment the generator to emit documentation for generated members, but also have to consider scenarios where users want to provide their own documentation. Standing by for community feedback on this. |
If I make the class internal and I making a library, how my clients can invoke the serialization with JsonSerializerContext? Do I have to expose a Serialize method for all my classes (or one with a case per type)? Does every one of the people using my library have to create their own MyContext : JsonSerializerContext? Or what is the recommend way to expose JsonSerializerContext derived classes so external clients can use it? |
The generated file doesn't have to have a documentation comment. You can add the documentation on the partial that's not generated starting with dotnet/roslyn#56419. |
My previous comment is misleading. I thought the diagnostic is issued for the partial The issue is that generator can generate public members without doc comments. The generator should either add |
I'm running into this issue as well. To allow users to provide their own documentation, would this not require (at least) something like partial properties in order to work, or a fundamental re-design of the generator? At the moment, the way that code takes advantage of the library is via source-generated public properties. Of the 2 options (either adding comments or adding |
What would an acceptable PR look like for this? Are we happy to go with |
After discussion with the @dotnet/area-system-text-json crew consensus seems to be that we would need to emit relevant XML docs for every generated member that is public. |
Moving to the .NET 8 milestone. |
Description
Using
JsonSerializerContext
can cause aCS1591
"Missing XML comment" error on the generated code.You cannot suppress
CS1591
from a global suppressions file because this is a compiler error. Disabling CS1591 from an.editorconfig
file still causes the error.You also cannot disable the warning in source because the source code is generated in a separate file. It looks like the generated source code needs to include some suppressions.
The only workaround seems to be to globally disable this warning in the project
.csproj
file, which is not great since I would like to keep this warning.Configuration
.NET SDK 6.0.100
Other information
See also:
The text was updated successfully, but these errors were encountered: