bradgonesurfing bradgonesurfing -4 years ago 145
C# Question

Visual Studio reports a missing method in a Roslyn Analyser but it is definitely there

I'm trying to use this analyser ( I wrote it )

I apply it against this source file

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using Weingartner.Json.Migration;

namespace testjson
public class Class1
public int foo { get; set; }

and I see the following warning in the output.

1>CSC : warning CS8032: An instance of analyzer
Weingartner.Json.Migration.Roslyn.MigrationHashAnalyzer cannot be created from
: Method 'get_SupportedDiagnostics' in type
'Weingartner.Json.Migration.Roslyn.MigrationHashAnalyzer' from
assembly 'Weingartner.Json.Migration.Roslyn, Version=1.0.6246.21734,
Culture=neutral, PublicKeyToken=null' does not have an

which is quite strange because if I crack open the DLL with JustDecompile I see

[DiagnosticAnalyzer("C#", new string[] { })]
public class MigrationHashAnalyzer : DiagnosticAnalyzer
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics
return ImmutableArray.Create<DiagnosticDescriptor>(MigrationHashAnalyzer.Rule);

which is what I expect because the source for the analyzer compiles. If the method was really missing then it wouldn't compile.

Why would VS report a method missing when it is really there?

Answer Source

Visual Studio is quite particular about the version of the libraries it uses. VS itself uses version 1.1.36 of the System.Collections.Immutable package. Since your analyser uses a different version, the runtime is unable to find the method and assumes it hasn't been implemented.


enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download