Guidance around CS9057 #81256
-
|
We recently introduced a new analyzer in BenchmarkDotNet, however we quickly got user reports of error CS9057 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
|
If you want to support people using older SDKs with BenchmarkDotNet, then you will need to change the version of Roslyn you use for your analyzer to the minimum version supported by the sdk you want to support. |
Beta Was this translation helpful? Give feedback.
-
|
(I was beaten to it.. but maybe saying the same thing in a slightly different way is still helpful..?) This warning occurs when the analyzer was compiled against too new of a version of Roslyn for the host it was loaded into. When this happens, the analyzer could start calling new APIs which don't exist in that old host's version of Roslyn and things will fail at runtime. Your analyzer project should reference a version of Roslyn which is old enough to represent a supported API surface in the .NET SDKs, IDE versions, etc. you intend for your analyzer to be compatible with. https://learn.microsoft.com/en-us/dotnet/core/porting/versioning-sdk-msbuild-vs#supported-net-versions |
Beta Was this translation helpful? Give feedback.
Yes, you can do that. dotnet/sdk#20793 has the full details, but the tldr is put analyzers into paths like
analyzers/dotnet/roslyn3.7/csfor Roslyn 3.7, oranalyzers/dotnet/roslyn4.14/csfor version 4.14.