private static Task <Document> RefactorAsync( Document document, InitializerExpressionSyntax initializer, IEnumerable <IPropertySymbol> propertySymbols, bool initializeToDefault, CancellationToken cancellationToken) { IdentifierNameSyntax missingIdentifierName = (initializeToDefault) ? null : IdentifierName(MissingToken(TriviaList(), SyntaxKind.IdentifierToken, TriviaList(Space))); IEnumerable <AssignmentExpressionSyntax> newExpressions = propertySymbols .OrderBy(f => f.Name) .Select(propertySymbol => { return(SimpleAssignmentExpression( IdentifierName(propertySymbol.Name), (initializeToDefault) ? propertySymbol.Type.GetDefaultValueSyntax(document.GetDefaultSyntaxOptions()) : missingIdentifierName)); }); InitializerExpressionSyntax newInitializer = initializer .WithExpressions(initializer.Expressions.AddRange(newExpressions)); if (initializer.IsMultiLine()) { newInitializer = newInitializer.ReplaceNode( newInitializer.Expressions.Last(), newInitializer.Expressions.Last().AppendToTrailingTrivia(NewLine())); } newInitializer = newInitializer.WithFormatterAnnotation(); return(document.ReplaceNodeAsync(initializer, newInitializer, cancellationToken)); }