private async Task <Solution> MakeDecentAsync(Document document, MemberDeclarationSyntax memberDecl, CancellationToken cancellationToken) { string identifierTokenText = null; switch (memberDecl) { case TypeDeclarationSyntax ts: identifierTokenText = ts.Identifier.Text; break; case PropertyDeclarationSyntax ps: identifierTokenText = ps.Identifier.Text; break; } var newName = DirtyWordMagician.DirtyToDecent(identifierTokenText); // Get the symbol representing the type to be renamed. var semanticModel = await document.GetSemanticModelAsync(cancellationToken); var typeSymbol = semanticModel.GetDeclaredSymbol(memberDecl, 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, typeSymbol, newName, optionSet, cancellationToken).ConfigureAwait(false); // Return the new solution with the now-uppercase type name. return(newSolution); }
private async Task <Solution> MakeFieldDecentAsync(Document document, SyntaxToken declaration, CancellationToken cancellationToken) { var newName = DirtyWordMagician.DirtyToDecent(declaration.ValueText); var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false); var symbol = semanticModel.GetDeclaredSymbol(declaration.Parent, cancellationToken); var solution = document.Project.Solution; return(await Renamer.RenameSymbolAsync(solution, symbol, newName, solution.Workspace.Options, cancellationToken).ConfigureAwait(false)); }
static bool CheckDirtyWord(string input) { return(DirtyWordMagician.IsFullDirtyWord(input) || DirtyWordMagician.HasDirtyWord(input)); }