Open billti opened 3 years ago
Yes, unfortunately this is just a version gotcha with the NuGet package. The fix should be in the .NET6 SDK.
How is this a gotcha with the NuGet package? Commit https://github.com/dotnet/roslyn-analyzers/commit/1c5c1b2b7b2a1bf14a5a09cd5cc040acbf18ec4a is included in the tag 5.0.1
, so shouldn't it be part of SDK 5.0.1? And why is NuGet relevant in that situatioN?
Raising this in case there is something amiss with the shipping/packaging of the Analyzers with the .NET SDK/VS.
I just spend a while troubleshooting why a project was getting CA2227 on a property with
{get; init;}
even though https://github.com/dotnet/roslyn-analyzers/pull/4463 should have fixed this last year. I'm running VS 2019 16.10.4 with the .NET SDK 5.0.302 installed with it.If I manage the NuGet packages for the project and explicitly install Microsoft.CodeAnalysis.NetAnalyzers version 5.0.3 into the project, then the fix is working and the analysis error goes away.
Looking at the .NET SDK file on my machine in
C:\Program Files\dotnet\sdk\5.0.302\Sdks\Microsoft.NET.Sdk\analyzers\Microsoft.CodeAnalysis.NetAnalyzers.dll
I can see it is version 5.0.4.22903 with a DateModified of 4/30/2021, which is well after 5.0.3 and the date the fix went in. Yet opening the assembly with IL Spy I can see the fix from commit https://github.com/dotnet/roslyn-analyzers/commit/1c5c1b2b7b2a1bf14a5a09cd5cc040acbf18ec4a is not there.The manually installed 5.0.3 NuGet package has a file version of 5.0.4.5504 and a DateModified of 1/25/2021, so would seem to be older than the VS 2019/.NET SDK installed version, yet with IL Spy I can see it does include the fix outlined.