SergeyTeplyakov / ErrorProne.NET

Set of roslyn-based analyzers for catching common C# errors (inspired by Google's error-prone)
MIT License
886 stars 42 forks source link

ErrorProne.NET.StructAnalyzers.MakeStructReadOnlyAnalyzer' threw an exception of type 'System.MissingMethodException' #222

Closed rotanov closed 3 years ago

rotanov commented 3 years ago

Installed latest beta of both analyzer packages from nuget to my NET5.0 project. Apparently it doesn't work, since I don't see squiggles when I change not-read-only-struct-argument to in. I also see about ~500 lines when building application, all of them are the same:

2>CSC : warning AD0001: Analyzer 'ErrorProne.NET.StructAnalyzers.MakeStructReadOnlyAnalyzer' threw an exception of type 'System.MissingMethodException' with message 'Method not found: 'Boolean ErrorProne.NET.Core.TypeExtensions.IsReadOnlyStruct(Microsoft.CodeAnalysis.INamedTypeSymbol)'.'.
SergeyTeplyakov commented 3 years ago

Thanks for reporting the issue. Looking...

Djoums commented 3 years ago

Bump, latest stable release works but not the prereleases (same error as OP).

rotanov commented 3 years ago

Yeah, I tried installing ErrorProne.NET nuget last week again and had no issues.

Djoums commented 3 years ago

I can't reproduce it anymore either, not sure what to think. It worked at some point and now no error when uninstalling/reinstalling.

rotanov commented 3 years ago

@SergeyTeplyakov Shall I close the issue?

SergeyTeplyakov commented 3 years ago

I have a theory here: I think its impossible to use different versions 'ErrorProne.NEET.CoreAnalyzers' and 'ErrorProne.NET.StructAnalyzers', because both of them rely on 'ErroorProne.NET.Core.dl'. So if the analyzer version s are different its possible that they will rely on the different version of 'ErrorProne.NET.Core.dll', but VS will load only one of them. So one of the analyzers will work and the other will fail with 'MissingMethodException'. Then recently I updated both analyzers to reference the same 'Core.dll'.

And I have a PR to remove the dependency whatsoever to avoid this issue in the future. So I think we can close this one.