This project is read-only.
1

Resolved

The analyzer driver makes duplicate callbacks for FieldDeclarationSyntax nodes

description

An analyzer defined by
public override void Initialize(AnalysisContext context)
{
  context.RegisterSyntaxNodeAction(AnalyzeFieldDeclaration, SyntaxKind.FieldDeclaration);
}

private static void AnalyzeFieldDeclaration(SyntaxNodeAnalysisContext context)
{
  var fieldDeclaration = (FieldDeclarationSyntax)context.Node;

  var diagnostic = Diagnostic.Create(Rule, fieldDeclaration.GetLocation(), fieldDeclaration.ToString());
  context.ReportDiagnostic(diagnostic);
}
gets called multiple times for a unit test source code string defined by:
var test = @"public const double Pi = 3.1415;";
thereby returning multiple and identical diagnostics.

The problem seems to only exist in unit tests and not in live analysis in the Visual Studio editor.

comments

manishv wrote Dec 14, 2014 at 11:37 PM

I have a fix for this one..

manishv wrote Dec 31, 2014 at 5:45 PM

This one was fixed last week, seems like the work item didn't get updated.