Skip to content

Instantly share code, notes, and snippets.

@EIrwin
Created November 7, 2014 21:57
Show Gist options
  • Save EIrwin/a2fd85b57e081d9e7561 to your computer and use it in GitHub Desktop.
Save EIrwin/a2fd85b57e081d9e7561 to your computer and use it in GitHub Desktop.
GetFixesAsync Method Implementation
public async Task<IEnumerable<CodeAction>> GetFixesAsync(Document document, TextSpan span, IEnumerable<Diagnostic> diagnostics, CancellationToken cancellationToken)
{
SyntaxNode root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
SyntaxToken token = root.FindToken(span.Start);
TextSpan diagnosticSpan = diagnostics.First().Location.SourceSpan;
// Find the method declaration identified by the diagnostic.
MethodDeclarationSyntax declaration = root.FindToken(diagnosticSpan.Start).Parent.AncestorsAndSelf().OfType<MethodDeclarationSyntax>().First();
// Return a code action that will invoke the fix.
return new[] { CodeAction.Create("Reorder Parameters", c => FixIInternalUserOrdinal(document, declaration, c)) };
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment