private static MethodDeclarationSyntax GetNewNode( MethodDeclarationSyntax methodDeclaration, TypeParameterConstraintSyntax constraint, SemanticModel semanticModel, CancellationToken cancellationToken) { string name = GetMethodTypeParameterName(semanticModel, methodDeclaration.BodyOrExpressionBody().SpanStart, cancellationToken); MethodDeclarationSyntax newNode = methodDeclaration.AddTypeParameterListParameters(TypeParameter(Identifier(name).WithRenameAnnotation())); if (constraint != null) { newNode = newNode.AddConstraintClauses(TypeParameterConstraintClause(name, constraint)); } return(newNode); }