LanguageDev / Yoakke

A collection of libraries for implementing compilers in .NET.
https://languagedev.github.io/Yoakke/
Apache License 2.0
141 stars 8 forks source link

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

Closed fubar-coder closed 2 years ago

fubar-coder commented 2 years ago

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

LPeter1997 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

fubar-coder commented 2 years ago

Thanks, works now as expected! :+1: