DotNetAnalyzers/StyleCopAnalyzers

Output from Roslyn Source Generators should be ignored by default

Closed this issue · 1 comments

With Source Generators becoming more popular now that Roslyn has direct support for it, StyleCop should be able to directly detect and ignore them without each generated file needing to specify // <auto-generated /> in it. That's putting the burden on the source generator author to know about and get right and hurts users of these analyzers who are "caught in the middle."

StyleCop Analyzers automatically ignores everything that Roslyn says is considered generated code. This should by filed on https://github.com/dotnet/roslyn. I would recommend source generator authors include the // <auto-generated /> comment in the generated code (or name the generated file ending with .g.cs), which is the same requirement that appeared for source generators prior to the ISourceGenerator interface.