Created
November 7, 2014 21:57
-
-
Save EIrwin/a2fd85b57e081d9e7561 to your computer and use it in GitHub Desktop.
GetFixesAsync Method Implementation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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