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

Add // <auto-generated /> to the generated files #142

Closed
fubar-coder opened this issue Mar 12, 2022 · 4 comments · Fixed by #143 or #144
Closed

Add // <auto-generated /> to the generated files #142

fubar-coder opened this issue Mar 12, 2022 · 4 comments · Fixed by #143 or #144
Labels
enhancement New feature or request

Comments

@fubar-coder
Copy link

Is your feature request related to a problem? Please describe.

I'd like to use StyleCop.Analyzers and it shows warnings, because it's unable to recognize the file as automatically generated.

Describe the solution you'd like

It would be helpful if the automatically generated files would start with the following text:

// <auto-generated />

This would cause the analysis to skip those files. You can find the unit test for skipped files in ExclusionTests.cs in the StyleCop.Analyzers project.

Describe alternatives you've considered

The only alternative I've found is to disable the warnings in the whole project, which is undesirable.

Additional context

@fubar-coder fubar-coder added the enhancement New feature or request label Mar 12, 2022
@LPeter1997
Copy link
Contributor

I've pushed out an early nightly from the feature branch. Can you confirm that the warnings are gone? If so, I'll merge it in.

@fubar-coder
Copy link
Author

It looks good so far. There is still one remaining warning:

0>/home/fubar-coder/Ventuno/siam-web/server/SiamServer.Documents.DocumentSelector/Yoakke.SynKit.Parser.Generator/Yoakke.SynKit.Parser.Generator.ParserSourceGenerator/InjectedSources.ParserAttribute.cs(20,16): Warning CS8669 : Die Anmerkung für Nullable-Verweistypen darf nur in Code innerhalb eines #nullable-Anmerkungskontexts verwendet werden. Für automatisch generierten Code ist eine explizite #nullable-Anweisung in der Quelle erforderlich.

It's a translation of the message Warning CS8669 The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Auto-generated code requires an explicit '#nullable' directive in source. and it seems that it requires an explicit #nullable enable or #nullable annotations in generated code. My current workaround is to disable this warning in the project, which is fine for me.

Other projects seem to have a similar problem, e.g.: AArnott/CodeGeneration.Roslyn#183

@LPeter1997 LPeter1997 reopened this Mar 13, 2022
@LPeter1997
Copy link
Contributor

This is an issue with injected sources. I will look through the injected sources and add the appropriate directives.

@fubar-coder
Copy link
Author

Thanks, works now as expected! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants