Reputation: 3
I have created a vsix project which is referencing a Roslyn analyzer and a code fix library. I am able to get the analyzer for my extension but failed to get the code fix provider for the same diagnostics.
namespace CSharpDiagnostics
{
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class AsyncMethodNameAnalyzer : SyntaxNodeAnalyzer
{
// Analyzer code, which I am able to debug and working fine.
}
}
This is a code fix for the AsyncMethodNameAnalyzer
mentioned above.
It looks like the Export
attribute is not functioning properly for it.
namespace CSharpDiagnostics
{
[ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(AsyncMethodNameCodeFix))]
public class AsyncMethodNameCodeFix : CodeFixProvider
{
public override ImmutableArray<string> FixableDiagnosticIds
{
get
{
return ImmutableArray.Create(AsyncMethodNameAnalyzer.DiagnosticId);
}
}
public sealed override FixAllProvider GetFixAllProvider()
{
return WellKnownFixAllProviders.BatchFixer;
}
public override async Task RegisterCodeFixesAsync(CodeFixContext context)
{
// My code for fix provider
}
}
}
Upvotes: 0
Views: 356
Reputation: 6420
You have to make sure that the MEF extension is registered in your vsixmanifest file.
Upvotes: 1