runtime: Thousands of analyzer warnings are thrown inside Visual Studio

Visual Studio 17.2 Preview 5 6.0.100 SDK

Severity	Code	Description	Project	File	Line	Suppression State
Warning	CS8032	An instance of analyzer Microsoft.CodeAnalysis.CSharp.UseIndexOrRangeOperator.CSharpUseIndexOperatorDiagnosticAnalyzer cannot be created from C:\Users\vihofer\.nuget\packages\microsoft.codeanalysis.csharp.codestyle\4.3.0-1.22206.2\analyzers\dotnet\cs\Microsoft.CodeAnalysis.CSharp.CodeStyle.dll: Could not load file or assembly 'Microsoft.CodeAnalysis, Version=4.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified..	System.Text.Json (net6.0)		1	Active

Could not load file or assembly 'Microsoft.CodeAnalysis, Version=4.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.

How is that assembly supposed to be referenced? Are we missing a PackageReference?

Repro: Open i.e. the System.Text.Json solution file with VS.

cc @ericstj in case you have any ideas.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 23 (19 by maintainers)

Commits related to this issue

Most upvoted comments

Yep, 17.3 maps top the 4.3 version of the compiler.

i.e. this has zero impact on command-line builds, on CI, or on anyone consuming the output of builds, correct?

Yes, correct.

Thanks for the detailed response Sam. @agocke @stephentoub @danmoseley IMO we should treat analyzer updates as breaking changes. To be more precise, updating an analyzer’s major or minor version will result in a dependency on a newer version of VS. In our example, our analyzers are depending on VS 17.3 which hasn’t been released yet publicly which results in some analyzers being broken an tons of warnings being thrown.

This typically means that your analyzers are referencing a newer version of the compiler than the one you are building with. Are you referencing the 4.3 compiler?