reactiveui / refit

The automatic type-safe REST library for .NET Core, Xamarin and .NET. Heavily inspired by Square's Retrofit library, Refit turns your REST API into a live interface.
https://reactiveui.github.io/refit/
MIT License
8.63k stars 746 forks source link

[BUG] Generated code not marked as auto-generated (not excluded from code-analysis) #1095

Closed hakenr closed 3 years ago

hakenr commented 3 years ago

SYMPTOM Generated code violates StyleCop rule SA1517:CodeMustNotContainBlankLinesAtStartOfFile.

CAUSE The #pragma warning disable currently used is not enough. You should use // <auto-generated /> or other official generated code markers to prevent code-analysis of generated code.

clairernovotny commented 3 years ago

StyleCop is suposed to ignore files with .g.cs. @sharwell .

sharwell commented 3 years ago

All generated code should have the following in a comment at the top of the file:

// <auto-generated/>

For compatibility with the legacy WinForms designer, StyleCop Analyzers 1.0 did not require files ending with .Designer.cs to include this comment. The same exception was not made for .g.cs because the XAML compiler did emit the expected comment.

Starting with StyleCop Analyzers 1.1, the designation of generated code was deferred to Roslyn itself. The Roslyn semantics for marking a file as generated when it fails to include the expected comment are implemented here:

https://github.com/dotnet/roslyn/blob/d1adf48a74f06dab2a7d6d7b8ac57299d707bf54/src/Compilers/Core/Portable/InternalUtilities/GeneratedCodeUtilities.cs#L61-L86

GitHub
dotnet/roslyn
The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs. - dotnet/roslyn
hakenr commented 3 years ago

Got it, I'm using StyleCop Analyzers 1.0.x. But still the comment should be there... ;-)

github-actions[bot] commented 1 year ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.