AsyncSuffixAnalyzer_CS.AsyncSuffixAnalyzer_CSCodeFixProvider.MakeMethodNameAsync C# (CSharp) Method

MakeMethodNameAsync() private method

private MakeMethodNameAsync ( Microsoft.CodeAnalysis.Document document, Microsoft.CodeAnalysis.CSharp.Syntax.MethodDeclarationSyntax methodStmt, CancellationToken cancellationToken ) : Task
document Microsoft.CodeAnalysis.Document
methodStmt Microsoft.CodeAnalysis.CSharp.Syntax.MethodDeclarationSyntax
cancellationToken System.Threading.CancellationToken
return Task
        private async Task<Solution> MakeMethodNameAsync(Document document, MethodDeclarationSyntax methodStmt, CancellationToken cancellationToken)
        {
            var identifierToken = methodStmt.Identifier;
            var newName = identifierToken.Text + "Async";
            // Get the symbol representing the type to be renamed.
            var semanticModel = await document.GetSemanticModelAsync(cancellationToken);
            var methodSymbol = semanticModel.GetDeclaredSymbol(methodStmt, cancellationToken);

            // Produce a new solution that has all references to that type renamed, including the declaration.
            var originalSolution = document.Project.Solution;
            var optionSet = originalSolution.Workspace.Options;
            var newSolution = await Renamer.RenameSymbolAsync(document.Project.Solution, methodSymbol, newName, optionSet, cancellationToken).ConfigureAwait(false);

            // Return the new solution with the now-uppercase type name.
            return newSolution;

        }
    }