private async Task <Document> InjectInstance(Document document, ClassDeclarationSyntax classNode, SimpleNameSyntax typeName) { var fieldName = "_" + ToVariableName(typeName); var fieldIdentifier = SyntaxFactory.Identifier(fieldName); ClassDeclarationSyntax updatedClass = classNode; var typeNameStr = typeName.GetText().ToString(); updatedClass = updatedClass.ReplaceNode(typeName, SyntaxFactory.IdentifierName(fieldName)); updatedClass = InjectToConstructor(typeName, updatedClass, fieldIdentifier); var root = await document.GetSyntaxRootAsync(); root = root.ReplaceNode(classNode, updatedClass); return(document.WithSyntaxRoot(root)); }