239 references to GetLeadingTrivia
Microsoft.Analyzers.Local (1)
InternalReferencedInPublicDocAnalyzer.cs (1)
42
var symbolComment = symbolNode.
GetLeadingTrivia
()
Microsoft.AspNetCore.App.CodeFixes (3)
Authorization\AddAuthorizationBuilderFixer.cs (1)
119
var invocationLeadingTrivia = invocation.
GetLeadingTrivia
()
Kestrel\ListenOnIPv6AnyFixer.cs (1)
69
.WithLeadingTrivia(invocationExpressionSyntax.
GetLeadingTrivia
())
WebApplicationBuilderFixer.cs (1)
106
var indentation = hostBasedInvocationMethodExpr.
GetLeadingTrivia
();
Microsoft.CodeAnalysis.CSharp (2)
Compiler\DocumentationCommentCompiler.cs (1)
272
foreach (var trivia in implementationPart.GetNonNullSyntaxNode().
GetLeadingTrivia
())
DocumentationComments\SourceDocumentationCommentUtils.cs (1)
64
foreach (var trivia in syntaxNode.
GetLeadingTrivia
().Reverse())
Microsoft.CodeAnalysis.CSharp.CodeStyle (16)
src\Analyzers\CSharp\Analyzers\ConvertProgram\ConvertProgramAnalysis_TopLevelStatements.cs (2)
117
if (typeDeclaration.
GetLeadingTrivia
().Any(t => t.IsDocComment()))
146
if (member.
GetLeadingTrivia
().Any(t => t.IsDocComment()))
src\Analyzers\CSharp\Analyzers\UseCollectionExpression\CSharpUseCollectionExpressionForFluentDiagnosticAnalyzer.cs (1)
306
.Concat(memberAccess.Name.
GetLeadingTrivia
())
src\Analyzers\CSharp\Analyzers\UseCompoundAssignment\CSharpUseCompoundCoalesceAssignmentDiagnosticAnalyzer.cs (1)
160
if (whenTrue.
GetLeadingTrivia
().Any(static t => t.GetStructure() is ConditionalDirectiveTriviaSyntax))
src\Analyzers\CSharp\Analyzers\UseExpressionBody\Helpers\UseExpressionBodyForAccessorsHelper.cs (1)
63
return !declaration.
GetLeadingTrivia
().Any(t => t.Kind() == SyntaxKind.EndOfLineTrivia)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\BlockSyntaxExtensions.cs (3)
53
var leadingDirectives = statement.
GetLeadingTrivia
().Where(IsAnyCodeDirective).ToImmutableArray();
195
expression = firstStatement.
GetLeadingTrivia
().Any(t => t.IsDirective || t.IsSingleOrMultiLineComment())
196
? returnStatement.Expression.WithLeadingTrivia(returnStatement.
GetLeadingTrivia
())
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ExpressionSyntaxExtensions.cs (3)
861
if (expression.
GetLeadingTrivia
().Any(t => t.IsDirective))
881
if (expression.
GetLeadingTrivia
().Any(t => t.IsSingleOrMultiLineComment()))
885
.WithLeadingTrivia(expression.
GetLeadingTrivia
())
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\MemberAccessExpressionSyntaxExtensions.cs (2)
28
memberAccess.
GetLeadingTrivia
()
32
.AddRange(memberAccess.Name.
GetLeadingTrivia
()))];
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\StatementSyntaxExtensions.cs (1)
14
=> statement.WithLeadingTrivia(statement.
GetLeadingTrivia
().WithoutLeadingBlankLines());
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\UsingsAndExternAliasesOrganizer.cs (2)
44
if (!firstUsing.
GetLeadingTrivia
().Any(t => t.IsEndOfLine()))
57
!currentUsing.
GetLeadingTrivia
().Any(t => t.IsEndOfLine()))
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (52)
src\Analyzers\CSharp\CodeFixes\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionCodeFixProvider.cs (1)
100
switchExpressionStatement = switchExpressionStatement.WithPrependedLeadingTrivia(declStatement.
GetLeadingTrivia
());
src\Analyzers\CSharp\CodeFixes\ConvertToRecord\ConvertToRecordEngine.cs (5)
578
var classTrivia = typeDeclaration.
GetLeadingTrivia
().Where(trivia => !trivia.IsWhitespace()).AsImmutable();
589
var leadingPropTrivia = p.
GetLeadingTrivia
()
598
? p.Type.
GetLeadingTrivia
()
703
return docComment.
GetLeadingTrivia
();
772
var potentialDocComment = result.Declaration.
GetLeadingTrivia
().FirstOrNull(trivia => trivia.IsDocComment());
src\Analyzers\CSharp\CodeFixes\DocumentationComments\CSharpAddDocCommentNodesCodeFixProvider.cs (1)
86
.AddRange(elementNode.
GetLeadingTrivia
()));
src\Analyzers\CSharp\CodeFixes\InvokeDelegateWithConditionalAccess\InvokeDelegateWithConditionalAccessCodeFixProvider.cs (1)
97
newStatement = newStatement.WithPrependedLeadingTrivia(ifStatement.
GetLeadingTrivia
());
src\Analyzers\CSharp\CodeFixes\MakeMethodAsynchronous\CSharpMakeMethodAsynchronousCodeFixProvider.cs (2)
200
var newModifiers = TokenList(s_asyncKeywordWithSpace.WithLeadingTrivia(returnType.
GetLeadingTrivia
()));
208
.WithAsyncKeyword(AsyncKeyword.WithPrependedLeadingTrivia(anonymous.
GetLeadingTrivia
()));
src\Analyzers\CSharp\CodeFixes\MakeStatementAsynchronous\CSharpMakeStatementAsynchronousCodeFixProvider.cs (4)
72
.WithAwaitKeyword(AwaitKeyword.WithLeadingTrivia(forEach.
GetLeadingTrivia
()));
77
.WithAwaitKeyword(AwaitKeyword.WithLeadingTrivia(forEachDeconstruction.
GetLeadingTrivia
()));
82
.WithAwaitKeyword(AwaitKeyword.WithLeadingTrivia(usingStatement.
GetLeadingTrivia
()));
87
.WithAwaitKeyword(AwaitKeyword.WithLeadingTrivia(localDeclaration.
GetLeadingTrivia
()));
src\Analyzers\CSharp\CodeFixes\MisplacedUsingDirectives\MisplacedUsingDirectivesCodeFixProvider.cs (2)
286
var leadingTrivia = usingDirective.
GetLeadingTrivia
();
411
var leadingTrivia = syntaxRoot.
GetLeadingTrivia
();
src\Analyzers\CSharp\CodeFixes\UseCollectionExpression\CSharpCollectionExpressionRewriter.cs (2)
454
DotDotToken.WithLeadingTrivia(expression.
GetLeadingTrivia
()).WithTrailingTrivia(Space),
664
var leadingTrivia = parentStatement.
GetLeadingTrivia
();
src\Analyzers\CSharp\CodeFixes\UseCollectionInitializer\CSharpUseCollectionInitializerCodeFixProvider_CollectionInitializer.cs (1)
47
var trivia = statement.
GetLeadingTrivia
();
src\Analyzers\CSharp\CodeFixes\UseCompoundAssignment\CSharpUseCompoundCoalesceAssignmentCodeFixProvider.cs (3)
71
if (newWhenTrueStatement.
GetLeadingTrivia
().Any(t => t.IsSingleOrMultiLineComment()))
74
.WithPrependedLeadingTrivia(ifStatement.
GetLeadingTrivia
())
79
newWhenTrueStatement = newWhenTrueStatement.WithLeadingTrivia(ifStatement.
GetLeadingTrivia
());
src\Analyzers\CSharp\CodeFixes\UseExpressionBodyForLambda\UseExpressionBodyForLambdaCodeActionHelpers.cs (1)
47
expressionBody.
GetLeadingTrivia
().All(t => t.IsWhitespaceOrEndOfLine()))
src\Analyzers\CSharp\CodeFixes\UseImplicitOrExplicitType\UseExplicitTypeCodeFixProvider.cs (1)
96
var leadingTrivia = declarationExpression.
GetLeadingTrivia
()
src\Analyzers\CSharp\CodeFixes\UsePatternMatching\CSharpIsAndCastCheckCodeFixProvider.cs (1)
67
var trivia = localDeclaration.
GetLeadingTrivia
().Concat(localDeclaration.GetTrailingTrivia())
src\Analyzers\CSharp\CodeFixes\UsePatternMatching\CSharpUseNotPatternCodeFixProvider.cs (1)
65
negated.WithPrependedLeadingTrivia(notExpression.
GetLeadingTrivia
())
src\Analyzers\CSharp\CodeFixes\UsePrimaryConstructor\CSharpUsePrimaryConstructorCodeFixProvider.cs (2)
204
var leadingTrivia = firstMember.
GetLeadingTrivia
().ToImmutableArray();
552
=> memberDeclaration.
GetLeadingTrivia
().Any(t => t.GetStructure()?.Kind() == SyntaxKind.PragmaWarningDirectiveTrivia)
src\Analyzers\CSharp\CodeFixes\UsePrimaryConstructor\CSharpUsePrimaryConstructorCodeFixProvider_DocComments.cs (2)
41
=> GetDocCommentStructure(node.
GetLeadingTrivia
());
103
var typeDeclarationLeadingTrivia = typeDeclaration.
GetLeadingTrivia
();
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationService.cs (13)
790
.WithLeadingTrivia(delegateDeclarationSyntax.ReturnType.
GetLeadingTrivia
())
798
.WithLeadingTrivia(methodDeclarationSyntax.ReturnType.
GetLeadingTrivia
())
806
.WithLeadingTrivia(operatorDeclarationSyntax.ReturnType.
GetLeadingTrivia
())
814
.WithLeadingTrivia(conversionOperatorDeclarationSyntax.Type.
GetLeadingTrivia
())
822
.WithLeadingTrivia(propertyDeclaration.Type.
GetLeadingTrivia
())
830
.WithLeadingTrivia(eventDeclarationSyntax.Type.
GetLeadingTrivia
())
838
.WithLeadingTrivia(indexerDeclarationSyntax.Type.
GetLeadingTrivia
())
850
.WithLeadingTrivia(parameterSyntax.Type.
GetLeadingTrivia
())
864
.WithLeadingTrivia(incompleteMemberSyntax.Type.
GetLeadingTrivia
())
874
.WithLeadingTrivia(arrayTypeSyntax.ElementType.
GetLeadingTrivia
())
882
.WithLeadingTrivia(pointerTypeSyntax.ElementType.
GetLeadingTrivia
())
890
.WithLeadingTrivia(variableDeclarationSyntax.Type.
GetLeadingTrivia
())
898
.WithLeadingTrivia(catchDeclarationSyntax.Type.
GetLeadingTrivia
())
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\CastExpressionSyntaxExtensions.cs (2)
19
.Concat(node.Type.
GetLeadingTrivia
())
23
.Concat(node.Expression.
GetLeadingTrivia
())
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\CompilationUnitSyntaxExtensions.cs (2)
150
if (root.Usings[i].
GetLeadingTrivia
().Any(trivia => trivia.IsKind(SyntaxKind.IfDirectiveTrivia)))
155
if (root.Usings[i].
GetLeadingTrivia
().Any(trivia => trivia.IsKind(SyntaxKind.EndIfDirectiveTrivia)))
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpRemoveUnnecessaryImportsService.Rewriter.cs (3)
61
var leadingTrivia = currentUsing.
GetLeadingTrivia
();
75
if (ShouldPreserveTrivia(nextUsing.
GetLeadingTrivia
()))
115
var currentUsingLeadingTrivia = currentUsing.
GetLeadingTrivia
();
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpReplaceDiscardDeclarationsWithAssignmentsService.cs (2)
79
leading: declarationExpression.
GetLeadingTrivia
(),
198
var leadingTrivia = _localDeclarationStatement.Declaration.Type.
GetLeadingTrivia
()
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (1)
Diagnostics\FixAllProvider\BatchFixerTests.cs (1)
76
var leadingTrivia = node.
GetLeadingTrivia
();
Microsoft.CodeAnalysis.CSharp.Features (71)
ChangeSignature\CSharpChangeSignatureService.cs (1)
383
.WithLeadingTrivia(lambda.Parameter.
GetLeadingTrivia
())
CodeFixes\Suppression\CSharpSuppressionCodeFixProvider.cs (1)
137
leadingTriviaForAttributeList = memberNode.
GetLeadingTrivia
();
CodeRefactorings\ConvertLocalFunctionToMethod\CSharpConvertLocalFunctionToMethodCodeRefactoringProvider.cs (1)
133
method = method.WithoutLeadingTrivia().WithAttributeLists(localFunction.AttributeLists).WithLeadingTrivia(method.
GetLeadingTrivia
());
CodeRefactorings\InlineTemporary\InlineTemporaryCodeRefactoringProvider.cs (2)
300
var newLocalDeclaration = variableDeclarator.
GetLeadingTrivia
().Any(t => t.IsDirective)
323
.
GetLeadingTrivia
()
CodeRefactorings\SyncNamespace\CSharpChangeNamespaceService.cs (1)
458
openingBuilder.AddRange(baseNamespace.
GetLeadingTrivia
());
ConvertCast\CSharpConvertDirectCastToTryCastCodeRefactoringProvider.cs (1)
58
var newLeadingTrivia = castExpression.
GetLeadingTrivia
().AddRange(middleTrivia);
ConvertCast\CSharpConvertTryCastToDirectCastCodeRefactoringProvider.cs (1)
55
var newLeadingTrivia = asExpression.
GetLeadingTrivia
().AddRange(asExpression.OperatorToken.TrailingTrivia.SkipInitialWhitespace());
ConvertLinq\ConvertForEachToLinqQuery\CSharpConvertForEachToLinqQueryProvider.cs (1)
185
localDeclarationStatement.Declaration.Type.
GetLeadingTrivia
(),
ConvertPrimaryToRegularConstructor\ConvertPrimaryToRegularConstructorCodeRefactoringProvider_DocumentationComments.cs (2)
35
var triviaList = typeDeclaration.
GetLeadingTrivia
();
112
var triviaList = typeDeclaration.
GetLeadingTrivia
();
ConvertProgram\ConvertProgramTransform_ProgramMain.cs (3)
114
var oldTriviaWithoutBlankLines = oldClassDeclaration.
GetLeadingTrivia
().WithoutLeadingBlankLines();
136
triviaToMove = statement.
GetLeadingTrivia
();
140
var commentsToPreserve = TriviaList(statement.
GetLeadingTrivia
().Skip(triviaToMove.Count));
ConvertProgram\ConvertProgramTransform_TopLevelStatements.cs (4)
189
statements.AddRange(methodDeclaration.Body.Statements[0].WithPrependedLeadingTrivia(methodDeclaration.
GetLeadingTrivia
()));
205
expressionBody: otherMethod.ExpressionBody).WithLeadingTrivia(otherMethod.
GetLeadingTrivia
()));
217
statements[0] = statements[0].WithPrependedLeadingTrivia(typeDeclaration.
GetLeadingTrivia
());
226
namespaceDeclaration.
GetLeadingTrivia
().TakeWhile(t => t.Kind() is SyntaxKind.WhitespaceTrivia or SyntaxKind.EndOfLineTrivia));
ConvertToRawString\ConvertInterpolatedStringToRawStringCodeRefactoringProvider.cs (1)
207
newNode = newNode.WithLeadingTrivia(newNode.
GetLeadingTrivia
().Add(Whitespace(indentation)));
Copilot\CSharpCopilotCodeFixProvider.cs (1)
129
.WithLeadingTrivia(memberDeclaration.HasLeadingTrivia ? memberDeclaration.
GetLeadingTrivia
() : method.GetLeadingTrivia())
EncapsulateField\CSharpEncapsulateFieldService.cs (1)
78
.WithLeadingTrivia(fieldSyntax.
GetLeadingTrivia
())
ExtractMethod\CSharpMethodExtractor.CSharpCodeGenerator.CallSiteContainerRewriter.cs (1)
73
triviaList.AddRange(variable.
GetLeadingTrivia
());
ExtractMethod\CSharpMethodExtractor.CSharpCodeGenerator.cs (4)
367
triviaList.AddRange(variableDeclaration.
GetLeadingTrivia
());
455
newLeadingTrivia = newLeadingTrivia.AddRange(declaration.Type.
GetLeadingTrivia
());
457
newLeadingTrivia = newLeadingTrivia.AddRange(designation.
GetLeadingTrivia
());
506
identifierLeadingTrivia = identifierLeadingTrivia.AddRange(typeSyntax.
GetLeadingTrivia
());
FullyQualify\CSharpFullyQualifyService.cs (1)
45
var leadingTrivia = simpleName.
GetLeadingTrivia
();
IntroduceUsingStatement\CSharpIntroduceUsingStatementCodeRefactoringProvider.cs (3)
63
UsingKeyword.WithLeadingTrivia(expressionStatement.
GetLeadingTrivia
()),
85
UsingKeyword.WithLeadingTrivia(declarationStatement.
GetLeadingTrivia
()),
108
.WithUsingKeyword(Token(declarationStatement.
GetLeadingTrivia
(), SyntaxKind.UsingKeyword, [Space]));
IntroduceVariable\CSharpIntroduceVariableService.Rewriter.cs (1)
34
.WithLeadingTrivia(expression.
GetLeadingTrivia
())
IntroduceVariable\CSharpIntroduceVariableService_IntroduceLocal.cs (2)
225
var leadingTrivia = oldBody.
GetLeadingTrivia
()
487
var nextStatementLeading = nextStatement.
GetLeadingTrivia
();
ReplacePropertyWithMethods\CSharpReplacePropertyWithMethodsService.cs (1)
231
var leadingTrivia = propertyDeclaration.
GetLeadingTrivia
();
Snippets\CSharpIntMainSnippetProvider.cs (1)
44
var triviaSpan = returnStatement.
GetLeadingTrivia
().Span;
src\Analyzers\CSharp\Analyzers\ConvertProgram\ConvertProgramAnalysis_TopLevelStatements.cs (2)
117
if (typeDeclaration.
GetLeadingTrivia
().Any(t => t.IsDocComment()))
146
if (member.
GetLeadingTrivia
().Any(t => t.IsDocComment()))
src\Analyzers\CSharp\Analyzers\UseCollectionExpression\CSharpUseCollectionExpressionForFluentDiagnosticAnalyzer.cs (1)
306
.Concat(memberAccess.Name.
GetLeadingTrivia
())
src\Analyzers\CSharp\Analyzers\UseCompoundAssignment\CSharpUseCompoundCoalesceAssignmentDiagnosticAnalyzer.cs (1)
160
if (whenTrue.
GetLeadingTrivia
().Any(static t => t.GetStructure() is ConditionalDirectiveTriviaSyntax))
src\Analyzers\CSharp\Analyzers\UseExpressionBody\Helpers\UseExpressionBodyForAccessorsHelper.cs (1)
63
return !declaration.
GetLeadingTrivia
().Any(t => t.Kind() == SyntaxKind.EndOfLineTrivia)
src\Analyzers\CSharp\CodeFixes\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionCodeFixProvider.cs (1)
100
switchExpressionStatement = switchExpressionStatement.WithPrependedLeadingTrivia(declStatement.
GetLeadingTrivia
());
src\Analyzers\CSharp\CodeFixes\ConvertToRecord\ConvertToRecordEngine.cs (5)
578
var classTrivia = typeDeclaration.
GetLeadingTrivia
().Where(trivia => !trivia.IsWhitespace()).AsImmutable();
589
var leadingPropTrivia = p.
GetLeadingTrivia
()
598
? p.Type.
GetLeadingTrivia
()
703
return docComment.
GetLeadingTrivia
();
772
var potentialDocComment = result.Declaration.
GetLeadingTrivia
().FirstOrNull(trivia => trivia.IsDocComment());
src\Analyzers\CSharp\CodeFixes\DocumentationComments\CSharpAddDocCommentNodesCodeFixProvider.cs (1)
86
.AddRange(elementNode.
GetLeadingTrivia
()));
src\Analyzers\CSharp\CodeFixes\InvokeDelegateWithConditionalAccess\InvokeDelegateWithConditionalAccessCodeFixProvider.cs (1)
97
newStatement = newStatement.WithPrependedLeadingTrivia(ifStatement.
GetLeadingTrivia
());
src\Analyzers\CSharp\CodeFixes\MakeMethodAsynchronous\CSharpMakeMethodAsynchronousCodeFixProvider.cs (2)
200
var newModifiers = TokenList(s_asyncKeywordWithSpace.WithLeadingTrivia(returnType.
GetLeadingTrivia
()));
208
.WithAsyncKeyword(AsyncKeyword.WithPrependedLeadingTrivia(anonymous.
GetLeadingTrivia
()));
src\Analyzers\CSharp\CodeFixes\MakeStatementAsynchronous\CSharpMakeStatementAsynchronousCodeFixProvider.cs (4)
72
.WithAwaitKeyword(AwaitKeyword.WithLeadingTrivia(forEach.
GetLeadingTrivia
()));
77
.WithAwaitKeyword(AwaitKeyword.WithLeadingTrivia(forEachDeconstruction.
GetLeadingTrivia
()));
82
.WithAwaitKeyword(AwaitKeyword.WithLeadingTrivia(usingStatement.
GetLeadingTrivia
()));
87
.WithAwaitKeyword(AwaitKeyword.WithLeadingTrivia(localDeclaration.
GetLeadingTrivia
()));
src\Analyzers\CSharp\CodeFixes\MisplacedUsingDirectives\MisplacedUsingDirectivesCodeFixProvider.cs (2)
286
var leadingTrivia = usingDirective.
GetLeadingTrivia
();
411
var leadingTrivia = syntaxRoot.
GetLeadingTrivia
();
src\Analyzers\CSharp\CodeFixes\UseCollectionExpression\CSharpCollectionExpressionRewriter.cs (2)
454
DotDotToken.WithLeadingTrivia(expression.
GetLeadingTrivia
()).WithTrailingTrivia(Space),
664
var leadingTrivia = parentStatement.
GetLeadingTrivia
();
src\Analyzers\CSharp\CodeFixes\UseCollectionInitializer\CSharpUseCollectionInitializerCodeFixProvider_CollectionInitializer.cs (1)
47
var trivia = statement.
GetLeadingTrivia
();
src\Analyzers\CSharp\CodeFixes\UseCompoundAssignment\CSharpUseCompoundCoalesceAssignmentCodeFixProvider.cs (3)
71
if (newWhenTrueStatement.
GetLeadingTrivia
().Any(t => t.IsSingleOrMultiLineComment()))
74
.WithPrependedLeadingTrivia(ifStatement.
GetLeadingTrivia
())
79
newWhenTrueStatement = newWhenTrueStatement.WithLeadingTrivia(ifStatement.
GetLeadingTrivia
());
src\Analyzers\CSharp\CodeFixes\UseExpressionBodyForLambda\UseExpressionBodyForLambdaCodeActionHelpers.cs (1)
47
expressionBody.
GetLeadingTrivia
().All(t => t.IsWhitespaceOrEndOfLine()))
src\Analyzers\CSharp\CodeFixes\UseImplicitOrExplicitType\UseExplicitTypeCodeFixProvider.cs (1)
96
var leadingTrivia = declarationExpression.
GetLeadingTrivia
()
src\Analyzers\CSharp\CodeFixes\UsePatternMatching\CSharpIsAndCastCheckCodeFixProvider.cs (1)
67
var trivia = localDeclaration.
GetLeadingTrivia
().Concat(localDeclaration.GetTrailingTrivia())
src\Analyzers\CSharp\CodeFixes\UsePatternMatching\CSharpUseNotPatternCodeFixProvider.cs (1)
65
negated.WithPrependedLeadingTrivia(notExpression.
GetLeadingTrivia
())
src\Analyzers\CSharp\CodeFixes\UsePrimaryConstructor\CSharpUsePrimaryConstructorCodeFixProvider.cs (2)
204
var leadingTrivia = firstMember.
GetLeadingTrivia
().ToImmutableArray();
552
=> memberDeclaration.
GetLeadingTrivia
().Any(t => t.GetStructure()?.Kind() == SyntaxKind.PragmaWarningDirectiveTrivia)
src\Analyzers\CSharp\CodeFixes\UsePrimaryConstructor\CSharpUsePrimaryConstructorCodeFixProvider_DocComments.cs (2)
41
=> GetDocCommentStructure(node.
GetLeadingTrivia
());
103
var typeDeclarationLeadingTrivia = typeDeclaration.
GetLeadingTrivia
();
UseAutoProperty\CSharpUseAutoPropertyCodeFixProvider.cs (1)
152
var leadingTrivia = property.
GetLeadingTrivia
();
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (31)
LexicalAndXml\XmlDocCommentTests.cs (16)
149
var leading = tree.GetCompilationUnitRoot().Members[0].
GetLeadingTrivia
();
195
var leading = tree.GetCompilationUnitRoot().Members[0].
GetLeadingTrivia
();
342
var leading = tree.GetCompilationUnitRoot().Members[0].
GetLeadingTrivia
();
393
var leading = tree.GetCompilationUnitRoot().Members[0].
GetLeadingTrivia
();
906
var leading = tree.GetCompilationUnitRoot().Members[0].
GetLeadingTrivia
();
932
var leading = tree.GetCompilationUnitRoot().Members[0].
GetLeadingTrivia
();
1068
var leading = tree.GetCompilationUnitRoot().Members[0].
GetLeadingTrivia
();
1210
var leading = tree.GetCompilationUnitRoot().Members[0].
GetLeadingTrivia
();
1294
var leading = classdecl.
GetLeadingTrivia
();
1836
var trivias = keyword.
GetLeadingTrivia
();
1871
var trivias = keyword.
GetLeadingTrivia
();
1906
var trivias = keyword.
GetLeadingTrivia
();
1941
var trivias = keyword.
GetLeadingTrivia
();
1978
var trivias = typeParameter.
GetLeadingTrivia
();
2014
var trivias = typeParameter.
GetLeadingTrivia
();
2051
var trivias = keyword.
GetLeadingTrivia
();
Syntax\StructuredTriviaTests.cs (2)
88
var identTrivia = identExpr.
GetLeadingTrivia
()[0];
192
var trivia = tree.GetCompilationUnitRoot().Members[0].
GetLeadingTrivia
();
Syntax\SyntaxDiffingTests.cs (2)
312
var leadingTrivia = node.
GetLeadingTrivia
();
377
var leadingTrivia = node.
GetLeadingTrivia
();
Syntax\SyntaxNodeTests.cs (11)
932
var trivia = tree.GetCompilationUnitRoot().Members[0].
GetLeadingTrivia
()[0];
935
var triviaAgain = tree.GetCompilationUnitRoot().Members[0].
GetLeadingTrivia
()[0];
1485
c = c.WithLeadingTrivia(c.
GetLeadingTrivia
().Concat(c.
GetLeadingTrivia
()));
1487
var leadingTriviaWithDuplicate = c.
GetLeadingTrivia
();
2415
var leadingTrivia = ex.
GetLeadingTrivia
();
2437
var leadingTrivia = ex.
GetLeadingTrivia
();
3533
Assert.Equal(1, node.
GetLeadingTrivia
().Count);
3535
Assert.Equal(" ", node.
GetLeadingTrivia
().First().ToString());
3544
Assert.Equal(1, node.
GetLeadingTrivia
().Count);
3546
Assert.Equal(" ", node.
GetLeadingTrivia
().First().ToString());
Microsoft.CodeAnalysis.CSharp.Workspaces (54)
CodeGeneration\CSharpSyntaxGenerator.cs (1)
2235
.WithLeadingTrivia(lambda.
GetLeadingTrivia
())
Simplification\CSharpSimplificationService.Expander.cs (9)
267
.WithLeadingTrivia(node.
GetLeadingTrivia
());
336
.WithLeadingTrivia(node.
GetLeadingTrivia
()))
404
.WithLeadingTrivia(node.
GetLeadingTrivia
())
411
rewrittenname).WithLeadingTrivia(node.
GetLeadingTrivia
())
700
var identifiersLeadingTrivia = newNode.
GetLeadingTrivia
();
754
.WithLeadingTrivia(newNode.
GetLeadingTrivia
())
920
.WithLeadingTrivia(rewrittenNode.
GetLeadingTrivia
()));
945
.WithLeadingTrivia(rewrittenNode.
GetLeadingTrivia
())
951
var leadingTrivia = rewrittenNode.
GetLeadingTrivia
();
Simplification\Reducers\CSharpExtensionMethodReducer.cs (1)
105
newMemberAccess = newMemberAccess.WithLeadingTrivia(node.
GetLeadingTrivia
());
Simplification\Reducers\CSharpVarReducer.Rewriter.cs (1)
48
.WithLeadingTrivia(typeSyntax.
GetLeadingTrivia
())
Simplification\Simplifiers\ExpressionSimplifier.cs (1)
154
memberAccess.
GetLeadingTrivia
(),
Simplification\Simplifiers\NameSimplifier.cs (7)
89
.WithLeadingTrivia(genericName.
GetLeadingTrivia
())
129
name.
GetLeadingTrivia
(),
294
.WithLeadingTrivia(name.
GetLeadingTrivia
())
313
.WithLeadingTrivia(name.
GetLeadingTrivia
());
327
replacementNode = ((QualifiedNameSyntax)name).Right.WithLeadingTrivia(name.
GetLeadingTrivia
());
527
.WithLeadingTrivia(name.
GetLeadingTrivia
());
532
.WithLeadingTrivia(name.
GetLeadingTrivia
());
Simplification\Simplifiers\QualifiedCrefSimplifier.cs (1)
94
replacement = replacement.WithLeadingTrivia(crefSyntax.
GetLeadingTrivia
());
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\BlockSyntaxExtensions.cs (3)
53
var leadingDirectives = statement.
GetLeadingTrivia
().Where(IsAnyCodeDirective).ToImmutableArray();
195
expression = firstStatement.
GetLeadingTrivia
().Any(t => t.IsDirective || t.IsSingleOrMultiLineComment())
196
? returnStatement.Expression.WithLeadingTrivia(returnStatement.
GetLeadingTrivia
())
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ExpressionSyntaxExtensions.cs (3)
861
if (expression.
GetLeadingTrivia
().Any(t => t.IsDirective))
881
if (expression.
GetLeadingTrivia
().Any(t => t.IsSingleOrMultiLineComment()))
885
.WithLeadingTrivia(expression.
GetLeadingTrivia
())
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\MemberAccessExpressionSyntaxExtensions.cs (2)
28
memberAccess.
GetLeadingTrivia
()
32
.AddRange(memberAccess.Name.
GetLeadingTrivia
()))];
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\StatementSyntaxExtensions.cs (1)
14
=> statement.WithLeadingTrivia(statement.
GetLeadingTrivia
().WithoutLeadingBlankLines());
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\UsingsAndExternAliasesOrganizer.cs (2)
44
if (!firstUsing.
GetLeadingTrivia
().Any(t => t.IsEndOfLine()))
57
!currentUsing.
GetLeadingTrivia
().Any(t => t.IsEndOfLine()))
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationService.cs (13)
790
.WithLeadingTrivia(delegateDeclarationSyntax.ReturnType.
GetLeadingTrivia
())
798
.WithLeadingTrivia(methodDeclarationSyntax.ReturnType.
GetLeadingTrivia
())
806
.WithLeadingTrivia(operatorDeclarationSyntax.ReturnType.
GetLeadingTrivia
())
814
.WithLeadingTrivia(conversionOperatorDeclarationSyntax.Type.
GetLeadingTrivia
())
822
.WithLeadingTrivia(propertyDeclaration.Type.
GetLeadingTrivia
())
830
.WithLeadingTrivia(eventDeclarationSyntax.Type.
GetLeadingTrivia
())
838
.WithLeadingTrivia(indexerDeclarationSyntax.Type.
GetLeadingTrivia
())
850
.WithLeadingTrivia(parameterSyntax.Type.
GetLeadingTrivia
())
864
.WithLeadingTrivia(incompleteMemberSyntax.Type.
GetLeadingTrivia
())
874
.WithLeadingTrivia(arrayTypeSyntax.ElementType.
GetLeadingTrivia
())
882
.WithLeadingTrivia(pointerTypeSyntax.ElementType.
GetLeadingTrivia
())
890
.WithLeadingTrivia(variableDeclarationSyntax.Type.
GetLeadingTrivia
())
898
.WithLeadingTrivia(catchDeclarationSyntax.Type.
GetLeadingTrivia
())
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\CastExpressionSyntaxExtensions.cs (2)
19
.Concat(node.Type.
GetLeadingTrivia
())
23
.Concat(node.Expression.
GetLeadingTrivia
())
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\CompilationUnitSyntaxExtensions.cs (2)
150
if (root.Usings[i].
GetLeadingTrivia
().Any(trivia => trivia.IsKind(SyntaxKind.IfDirectiveTrivia)))
155
if (root.Usings[i].
GetLeadingTrivia
().Any(trivia => trivia.IsKind(SyntaxKind.EndIfDirectiveTrivia)))
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpRemoveUnnecessaryImportsService.Rewriter.cs (3)
61
var leadingTrivia = currentUsing.
GetLeadingTrivia
();
75
if (ShouldPreserveTrivia(nextUsing.
GetLeadingTrivia
()))
115
var currentUsingLeadingTrivia = currentUsing.
GetLeadingTrivia
();
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpReplaceDiscardDeclarationsWithAssignmentsService.cs (2)
79
leading: declarationExpression.
GetLeadingTrivia
(),
198
var leadingTrivia = _localDeclarationStatement.Declaration.Type.
GetLeadingTrivia
()
Microsoft.Gen.Logging (1)
Parsing\Parser.cs (1)
457
var triviaList = method.
GetLeadingTrivia
();
Microsoft.Interop.SourceGeneration (1)
GeneratedStatements.cs (1)
85
newLeadingTrivia = newLeadingTrivia.AddRange(firstStatementInStage.
GetLeadingTrivia
());
Microsoft.VisualStudio.LanguageServices.CSharp (5)
CodeModel\CSharpCodeModelService.cs (3)
1294
var leadingTriviaList = memberDeclaration.
GetLeadingTrivia
().ToList();
1331
.
GetLeadingTrivia
()
1427
var leadingTriviaList = memberDeclaration.
GetLeadingTrivia
().ToList();
CodeModel\MethodXml\MethodXmlBuilder.cs (1)
28
GenerateComments(statement.
GetLeadingTrivia
());
CodeModel\ModifierFlagsExtensions.cs (1)
108
var leadingTrivia = member.
GetLeadingTrivia
();
System.Windows.Forms.Analyzers.CodeFixes.CSharp (1)
System\Windows\Forms\CSharp\CodeFixes\AddDesignerSerializationVisibility\AddDesignerSerializationVisibilityCodeFixProvider.cs (1)
85
SyntaxTriviaList leadingTrivia = propertyDeclarationSyntax.
GetLeadingTrivia
();