DotNetAnalyzers / StyleCopAnalyzers

An implementation of StyleCop rules using the .NET Compiler Platform
MIT License
2.61k stars 506 forks source link

SA0102 appears to be falsely reported for file scoped namespaces? (1.2.0-beta.556) #3868

Closed CodingBeagle closed 2 days ago

CodingBeagle commented 4 days ago

Using StyleCop.Analyzers version 1.2.0-beta.556 with the following PackageReference:

<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>

It appears that I get false positives when using file scoped namespaces? Example, given the following declaration at the top of a class:

namespace My.Example.Namespace;

I get the following error: "A syntax error has been discovered in file '...' [StyleCop Rule: SA0102]"

bjornhellander commented 4 days ago

SA0102 is never reported by this analyzer package. It looks like you are also using StyleCop "Classic" somehow and that one is reporting the error you are seeing.