Skip to content
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

Suppress warning CS1591: Missing XML comment in autogenerated code #5987

Open
kirekocev3Shape opened this issue Mar 24, 2023 · 7 comments · May be fixed by #6474
Open

Suppress warning CS1591: Missing XML comment in autogenerated code #5987

kirekocev3Shape opened this issue Mar 24, 2023 · 7 comments · May be fixed by #6474
Labels
Milestone

Comments

@kirekocev3Shape
Copy link

Product

Hot Chocolate

Is your feature request related to a problem?

HotChocolate.Types.Analyzers generate code (Data Loaders, Type Auto Registration, etc) that can be publicly visible. This autogenerated code produces warnings type CS1591: Missing XML comment and it can not be suppressed.

The solution you'd like

I would like the autogenerated code to have directives that suppress the specified warnings.

@kirekocev3Shape kirekocev3Shape added the 🎉 enhancement New feature or request label Mar 24, 2023
@michaelstaib michaelstaib added this to the HC-13.1.0 milestone Mar 28, 2023
@michaelstaib
Copy link
Member

Thank you for this feedback ... I have added it to the 13.1 backlog.

@SeijiSuenaga
Copy link

For what it's worth, you can suppress these warnings using an .editorconfig file, for example:

[**/Generated/**]
dotnet_diagnostic.CS1591.severity = none

If you're using Visual Studio, you might be able to disable all warnings instead of specific ones:

[**/Generated/**]
generated_code = true

but I haven't gotten that to work with dotnet CLI.

@RobTF
Copy link

RobTF commented May 13, 2023

Hi @SeijiSuenaga,

Unfortunately the suppression in .editorconfig does not work with source generated files. If you try to filter suppression directives by the filename (e.g. in a [*.g.cs] section) it is ignored for these files.

I also ran into this issue with Godot and their source generators. It currently requires the generated code to add a `#pragma' directive in order to suppress analysis issues.

@SeijiSuenaga
Copy link

@RobTF that's odd because the first example I posted does work for me with .NET SDK 6.0.408 and VS Code with Roslyn analyzers enabled. 🤔 I get no warnings with that .editorconfig, and lots of warnings without it.

@RobTF
Copy link

RobTF commented May 13, 2023

Interesting... ill give it a try again tomorrow. If i get no joy ill push to a public repo so perhaps we could compare?

@michaelstaib michaelstaib modified the milestones: HC-13.1.0, HC-13.0.x Jun 2, 2023
@VaclavSir VaclavSir linked a pull request Aug 24, 2023 that will close this issue
@SapiensAnatis
Copy link

Is a fix for this likely to make it into a release in the near future? This is making me reconsider whether to use the source generators in our project -- they are great, but it looks like I would have to suppress the doc rules project-wide, because I couldn't get any editorconfig rules to be respected and we have our CI build our code with warnings set to errors.

@SapiensAnatis
Copy link

Turns out you can suppress messages in just the generated code using .globalconfig and then re-enabling the warning in .editorconfig

https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/configuration-files#global-analyzerconfig

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants