WiseTechGlobal / WTG.Analyzers

Analyzers from WiseTech Global to enforce our styles, behaviours, and prevent common mistakes.
Other
16 stars 3 forks source link

WTG1005 false-positive on NuGet-shipped code #135

Closed yaakov-h closed 3 years ago

yaakov-h commented 3 years ago
/Users/yaakov/.nuget/packages/microsoft.net.test.sdk/16.8.0/build/netcoreapp2.1/Microsoft.NET.Test.Sdk.Program.cs(3,63): warning WTG1005: All line endings should be using LF, this issue usually occurs when copying code from another source.

We're only really concerned about code that is part of this project, not code imported by a package.

I'm not sure yet how we can detect the difference, though.

yaakov-h commented 3 years ago
% cat /Users/yaakov/.nuget/packages/microsoft.net.test.sdk/16.8.0/build/netcoreapp2.1/Microsoft.NET.Test.Sdk.Program.cs
// <auto-generated> This file has been auto generated. </auto-generated>
using System;
[Microsoft.VisualStudio.TestPlatform.TestSDKAutoGeneratedCode]
class AutoGeneratedProgram {static void Main(string[] args){}}                                                                                                                                                                        

This code already has the auto-generated header, so perhaps we're not detecting it correctly?

brian-reichle commented 3 years ago

It seems to be assuming that there will only be whitespace between the tag and end-of-line. https://github.com/WiseTechGlobal/WTG.Analyzers/blob/master/WTG.Analyzers.Utils/SyntaxTreeExtensions.cs#L62

Could probably just remove the trailing \s*$ from the regex.