sonar-dotnet icon indicating copy to clipboard operation
sonar-dotnet copied to clipboard

NET-1917 Consider AssemblyInfo.cs as a generated file

Open pavel-mikula-sonarsource opened this issue 4 years ago • 5 comments

Based on internal discussion, consider AssemblyInfo (CS and VB) as a generated file.

That should prevent it from being marked as duplicated code blocks, when AnalyzeGenerated=false.

Add Java integration tests to check duplications / improve our AutoGenerated ITs to account for Copy Paste Detection metrics

Shouldn't it also be considered a deprecated feature? (I know, that should be a different rule) It is only added for the pre-2017 project files. That in it self might be a constraint to: because if you have an AssemblyInfo file, and have a 2017-project file, it was added manually. And it might be worth checking if no class/struct/enum was defined, to mark it a such too.

Corniel avatar Mar 31 '21 19:03 Corniel

I think there's nothing wrong with naming your file like that for the same purpose in new SDK-style projects. We actually have similar one https://github.com/SonarSource/sonar-dotnet/blob/master/analyzers/src/SonarAnalyzer.CSharp/Properties/AssemblyInfo.cs as there are few rules asking you to mark your assembly with assembly attributes (like S3904).

@pavel-mikula-sonarsource I fully agree that you should be able to give your file the name you want (although there are guidelines about having the same name for your file as the class that defined in it, handled by StyleCop if I'm not mistaken).

My suggestion was (and I have to admit, not spelled out that well) that the assembly attributes previously required (and generated in the AssemblyInfo file) should become obsolete, and that deserves a rule on its own.

And for the auto generated part: you only want to skip those AssemblyInfo files, that where - as matter of fact - generated. If you decided to have you custom AssemblyInfo file, containing (only) some custom chosen attributes (like the one you mentioned), I think it's fair to not mark those as generated.

Corniel avatar Apr 02 '21 12:04 Corniel

Based on internal discussion, consider AssemblyInfo (CS and VB) as a generated file.

That should prevent it from being marked as duplicated code blocks, when AnalyzeGenerated=false.

Add Java integration tests to check duplications / improve our AutoGenerated ITs to account for Copy Paste Detection metrics

So, those include files marked with // <autogenerated/> that come from source generators too?

AraHaan avatar Apr 04 '21 11:04 AraHaan

Internal ticket NET-1917