Closed nstod closed 2 years ago
It sounds like in step (2), you're installing StyleCop Classic (the old StyleCop from Visual Studio 2013 and earlier) instead of StyleCop Analyzers (this project). StyleCop Analyzers doesn't have any rule SA0102.
Here is my full csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.406">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
There must be a Directory.Build.props/Directory.Build.targets file in a parent directory which is injecting additional packages outside what the project file shows. If you build on the command line and pass the /bl
flag to the compiler, it will produce a msbuild.binlog file which you can open in the MSBuild Structured Log Viewer to locate the point where StyleCop Classic is running.
See also #3066
This is a situation where I definitely want to help, but the error in question could not have been caused by any version of this project (it never existed). If I had a project with this error, by first choice for investigating it would be the binlog.
I apologize for all this. I wasn't able to track it down with the binlog, but I had forgotten that ReSharper had a StyleCop extension enabled. Once I disabled that, the problem went away. I will close this issue. I really appreciate the help.
Glad to hear the binlog helped!
StyleCop doesn't seem to like using declarations in VS2022. It works fine in VS2019.
Repro:
using var cts = new CancellationTokenSource();