private async Task <Solution> UseCorrectType(Document document, TypeSyntax syntax, CancellationToken cancellationToken) { var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); var semanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false); var argumentList = syntax.Ancestors().OfType <TypeDeclarationSyntax>().First(); var symbol = semanticModel.GetDeclaredSymbol(argumentList, cancellationToken); var identifier = SyntaxFactory.ParseName(symbol.ToString()).WithAdditionalAnnotations(Simplifier.Annotation); root = root.ReplaceNode(syntax, identifier); document = document.WithSyntaxRoot(root); return(document.Project.Solution); }