5 overrides of Location
Microsoft.CodeAnalysis (5)
CommandLine\CommonCompiler.SuppressionDiagnostic.cs (1)
66
public override Location
Location
=> _originalDiagnostic.Location;
Diagnostic\Diagnostic.DiagnosticWithProgrammaticSuppression.cs (1)
71
public override Location
Location
Diagnostic\Diagnostic_SimpleDiagnostic.cs (1)
131
public override Location
Location
Diagnostic\DiagnosticWithInfo.cs (1)
33
public override Location
Location
DiagnosticAnalyzer\CompilerDiagnosticAnalyzer.CompilationAnalyzer.cs (1)
97
public override Location
Location
=> _original.Location;
586 references to Location
dotnet-format (8)
Analyzers\AnalyzerFormatter.cs (2)
178
var document = solution.GetDocument(diagnostic.
Location
.SourceTree);
184
var mappedLineSpan = diagnostic.
Location
.GetMappedLineSpan();
Analyzers\AnalyzerRunner.cs (3)
86
diagnostic.
Location
.IsInSource &&
87
diagnostic.
Location
.SourceTree != null &&
88
formattableDocumentPaths.Contains(diagnostic.
Location
.SourceTree.FilePath))
Analyzers\SolutionCodeFixApplier.cs (3)
33
.Where(diagnostic => diagnostic.
Location
.SourceTree != null)
41
var document = solution.GetDocument(diagnostic.
Location
.SourceTree);
112
return projectDiagnostics.Where(diagnostic => diagnostic.
Location
.SourceTree?.FilePath == document.FilePath).ToImmutableArray();
GenerateDocumentationAndConfigFiles (5)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeFixes\FixAllContextHelper.cs (1)
140
foreach (var (textDocument, diagnosticsForDocument) in diagnostics.GroupBy(d => solution.GetTextDocumentForLocation(d.
Location
)))
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeFixes\ForkingSyntaxEditorBasedCodeFixProvider.cs (1)
34
/// computed with respect to the original user document, and as such its <see cref="Diagnostic.
Location
"/> and <see
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeFixes\SyntaxEditorBasedCodeFixProvider.cs (2)
43
.Sort((d1, d2) => d1.
Location
.SourceSpan.Start - d2.
Location
.SourceSpan.Start);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\ProjectExtensions.cs (1)
42
var diagnosticFilePath = PathUtilities.GetDirectoryName(diagnostic?.
Location
.SourceTree?.FilePath ?? project.FilePath);
ILLink.CodeFixProvider (3)
BaseAttributeCodeFixProvider.cs (1)
42
SyntaxNode targetNode = root.FindNode(diagnostic.
Location
.SourceSpan, getInnermostNodeForTie: true);
RequiresUnsafeCodeFixProvider.cs (1)
50
SyntaxNode targetNode = root.FindNode(diagnostic.
Location
.SourceSpan, getInnermostNodeForTie: true);
UnsafeMethodMissingRequiresUnsafeCodeFixProvider.cs (1)
40
var node = root.FindNode(diagnostic.
Location
.SourceSpan, getInnermostNodeForTie: true);
Microsoft.Analyzers.Extra.Tests (8)
Resources\RoslynTestUtils.cs (8)
144
Assert.True(expectedSpan.Equals(actual.
Location
.SourceSpan),
145
$"Span {spanNum} doesn't match: expected {expectedSpan} but got {actual.
Location
.SourceSpan}");
269
if (x.
Location
.SourceSpan.Start < y.
Location
.SourceSpan.Start)
273
else if (x.
Location
.SourceSpan.Start > y.
Location
.SourceSpan.Start)
348
var doc = proj.GetDocument(d.
Location
.SourceTree);
530
return diagnostics.Where(d => d.
Location
.SourceTree!.FilePath.EndsWith(document.Name));
Microsoft.Analyzers.Local.Tests (9)
InternalReferencedInPublicDocAnalyzerTests.cs (1)
468
var location = detected[i].
Location
;
Resources\RoslynTestUtils.cs (8)
144
Assert.True(expectedSpan.Equals(actual.
Location
.SourceSpan),
145
$"Span {spanNum} doesn't match: expected {expectedSpan} but got {actual.
Location
.SourceSpan}");
270
if (x.
Location
.SourceSpan.Start < y.
Location
.SourceSpan.Start)
274
else if (x.
Location
.SourceSpan.Start > y.
Location
.SourceSpan.Start)
349
var doc = proj.GetDocument(d.
Location
.SourceTree);
531
return diagnostics.Where(d => d.
Location
.SourceTree!.FilePath.EndsWith(document.Name));
Microsoft.AspNetCore.App.CodeFixes (15)
Authorization\AddAuthorizationBuilderFixer.cs (2)
59
var diagnosticTarget = root.FindNode(diagnostic.
Location
.SourceSpan, getInnermostNodeForTie: true);
136
var diagnosticTarget = root.FindNode(diagnostic.
Location
.SourceSpan, getInnermostNodeForTie: true);
Dependencies\AddPackageFixer.cs (2)
49
var location = diagnostic.
Location
.SourceSpan;
83
var position = diagnostic.
Location
.SourceSpan.Start;
DetectMismatchedParameterOptionalityFixer.cs (1)
45
var param = root.FindNode(diagnostic.
Location
.SourceSpan);
Http\HeaderDictionaryAddFixer.cs (4)
70
var diagnosticTarget = root.FindNode(diagnostic.
Location
.SourceSpan, getInnermostNodeForTie: true);
87
var diagnosticTarget = root.FindNode(diagnostic.
Location
.SourceSpan, getInnermostNodeForTie: true);
101
var diagnosticTarget = root.FindNode(diagnostic.
Location
.SourceSpan, getInnermostNodeForTie: true);
115
var diagnosticTarget = root.FindNode(diagnostic.
Location
.SourceSpan, getInnermostNodeForTie: true);
Http\HeaderDictionaryIndexerFixer.cs (1)
51
var param = root.FindNode(diagnostic.
Location
.SourceSpan);
Kestrel\ListenOnIPv6AnyFixer.cs (1)
40
var argumentSyntax = root.FindNode(diagnostic.
Location
.SourceSpan).FirstAncestorOrSelf<ArgumentSyntax>();
PublicPartialProgramClassFixer.cs (1)
38
var classDeclaration = root.FindNode(diagnostic.
Location
.SourceSpan)
RouteParameterUnusedParameterFixer.cs (1)
60
var param = root.FindNode(diagnostic.
Location
.SourceSpan);
WebApplicationBuilderFixer.cs (2)
79
var diagnosticTarget = root.FindNode(diagnostic.
Location
.SourceSpan, getInnermostNodeForTie: true);
94
var diagnosticTarget = root.FindNode(diagnostic.
Location
.SourceSpan, getInnermostNodeForTie: true);
Microsoft.AspNetCore.Components.Analyzers (1)
ComponentParametersShouldBePublicCodeFixProvider.cs (1)
35
var diagnosticSpan = diagnostic.
Location
.SourceSpan;
Microsoft.AspNetCore.Components.SdkAnalyzers (1)
ComponentParametersShouldBePublicCodeFixProvider.cs (1)
35
var diagnosticSpan = diagnostic.
Location
.SourceSpan;
Microsoft.AspNetCore.Mvc.Api.Analyzers (2)
AddResponseTypeAttributeCodeFixAction.cs (2)
41
public override string EquivalenceKey => _diagnostic.
Location
.ToString();
131
var diagnosticNode = root.FindNode(_diagnostic.
Location
.SourceSpan);
Microsoft.CodeAnalysis (41)
CommandLine\CommonCompiler.SuppressionDiagnostic.cs (1)
66
public override Location Location => _originalDiagnostic.
Location
;
CommandLine\SarifV1ErrorLogger.cs (1)
85
WriteLocations(diagnostic.
Location
, diagnostic.AdditionalLocations);
CommandLine\SarifV2ErrorLogger.cs (1)
113
WriteLocations(diagnostic.
Location
, diagnostic.AdditionalLocations);
Diagnostic\CommonDiagnosticComparer.cs (3)
30
return x.
Location
== y.
Location
&& x.Id == y.Id;
40
return Hash.Combine(obj.
Location
, obj.Id.GetHashCode());
Diagnostic\Diagnostic.cs (10)
44
/// <param name="location">An optional primary location of the diagnostic. If null, <see cref="
Location
"/> will return <see cref="Location.None"/>.</param>
59
/// <param name="location">An optional primary location of the diagnostic. If null, <see cref="
Location
"/> will return <see cref="Location.None"/>.</param>
80
/// <param name="location">An optional primary location of the diagnostic. If null, <see cref="
Location
"/> will return <see cref="Location.None"/>.</param>
101
/// <param name="location">An optional primary location of the diagnostic. If null, <see cref="
Location
"/> will return <see cref="Location.None"/>.</param>
128
/// <param name="location">An optional primary location of the diagnostic. If null, <see cref="
Location
"/> will return <see cref="Location.None"/>.</param>
179
/// <param name="location">An optional primary location of the diagnostic. If null, <see cref="
Location
"/> will return <see cref="Location.None"/>.</param>
229
/// <param name="location">An optional primary location of the diagnostic. If null, <see cref="
Location
"/> will return <see cref="Location.None"/>.</param>
439
return "Unresolved diagnostic at " + this.
Location
;
444
return "Void diagnostic at " + this.
Location
;
496
if (isLocationWithinSpan(
Location
, tree, filterSpanWithinTree))
Diagnostic\Diagnostic.DiagnosticWithProgrammaticSuppression.cs (1)
73
get { return _originalUnsuppressedDiagnostic.
Location
; }
Diagnostic\DiagnosticFormatter.cs (3)
32
switch (diagnostic.
Location
.Kind)
37
var span = diagnostic.
Location
.GetLineSpan();
38
var mappedSpan = diagnostic.
Location
.GetMappedLineSpan();
DiagnosticAnalyzer\AnalysisResultBuilder.cs (2)
304
=> diagnostic.
Location
.SourceTree;
309
if (diagnostic.
Location
is ExternalFileLocation externalFileLocation)
DiagnosticAnalyzer\AnalysisScope.cs (4)
299
if (diagnostic.
Location
.IsInSource)
301
if (diagnostic.
Location
.SourceTree != filterFile.SourceTree)
306
else if (diagnostic.
Location
is ExternalFileLocation externalFileLocation)
315
return ShouldInclude(diagnostic.
Location
.SourceSpan);
DiagnosticAnalyzer\AnalyzerDriver.cs (2)
635
return suppressInGeneratedCode && IsInGeneratedCode(diagnostic.
Location
, compilation, cancellationToken);
2027
if (diagnostic?.
Location
.SourceTree is { } tree &&
DiagnosticAnalyzer\AnalyzerExecutor.AnalyzerDiagnosticReporter.cs (4)
117
(!FilterSpanForLocalDiagnostics.HasValue || FilterSpanForLocalDiagnostics.Value.IntersectsWith(diagnostic.
Location
.SourceSpan)))
130
if (diagnostic.
Location
.IsInSource)
133
_contextFile.Value.SourceTree == diagnostic.
Location
.SourceTree;
137
diagnostic.
Location
is ExternalFileLocation externalFileLocation)
DiagnosticAnalyzer\AnalyzerExecutor.cs (3)
1548
if (diagnostic.
Location
.IsInSource)
1553
if (syntaxRef.SyntaxTree == diagnostic.
Location
.SourceTree)
1556
if (diagnostic.
Location
.SourceSpan.IntersectsWith(syntax.FullSpan))
DiagnosticAnalyzer\CompilerDiagnosticAnalyzer.CompilationAnalyzer.cs (2)
67
if (locationFilter(diagnostic.
Location
) &&
97
public override Location Location => _original.
Location
;
DiagnosticAnalyzer\DiagnosticAnalysisContextHelpers.cs (1)
77
VerifyDiagnosticLocationInCompilation(diagnostic.Id, diagnostic.
Location
, compilation);
DiagnosticAnalyzer\DiagnosticQueue.cs (2)
111
Debug.Assert(diagnostic.
Location
.Kind == LocationKind.SourceFile || diagnostic.
Location
.Kind == LocationKind.ExternalFile);
DiagnosticAnalyzer\SuppressMessageAttributeState.cs (1)
176
var location = diagnostic.
Location
;
Microsoft.CodeAnalysis.Analyzers (11)
MetaAnalyzers\Fixers\CompareSymbolsCorrectlyFix.cs (2)
46
cancellationToken => ConvertToEqualsAsync(context.Document, diagnostic.
Location
.SourceSpan, cancellationToken),
54
cancellationToken => CallOverloadWithEqualityComparerAsync(context.Document, diagnostic.
Location
.SourceSpan, cancellationToken),
MetaAnalyzers\Fixers\ConfigureGeneratedCodeAnalysisFix.cs (1)
35
cancellationToken => ConfigureGeneratedCodeAnalysisAsync(context.Document, diagnostic.
Location
.SourceSpan, cancellationToken),
MetaAnalyzers\Fixers\EnableConcurrentExecutionFix.cs (1)
34
cancellationToken => EnableConcurrentExecutionAsync(context.Document, diagnostic.
Location
.SourceSpan, cancellationToken),
MetaAnalyzers\Fixers\PreferIsKindFix.cs (2)
29
cancellationToken => ConvertKindToIsKindAsync(context.Document, diagnostic.
Location
.SourceSpan, cancellationToken),
68
var nodeToFix = _fixer.TryGetNodeToFix(editor.OriginalRoot, diagnostic.
Location
.SourceSpan);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeFixes\FixAllContextHelper.cs (1)
140
foreach (var (textDocument, diagnosticsForDocument) in diagnostics.GroupBy(d => solution.GetTextDocumentForLocation(d.
Location
)))
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeFixes\ForkingSyntaxEditorBasedCodeFixProvider.cs (1)
34
/// computed with respect to the original user document, and as such its <see cref="Diagnostic.
Location
"/> and <see
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeFixes\SyntaxEditorBasedCodeFixProvider.cs (2)
43
.Sort((d1, d2) => d1.
Location
.SourceSpan.Start - d2.
Location
.SourceSpan.Start);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\ProjectExtensions.cs (1)
42
var diagnosticFilePath = PathUtilities.GetDirectoryName(diagnostic?.
Location
.SourceTree?.FilePath ?? project.FilePath);
Microsoft.CodeAnalysis.CodeStyle (4)
src\roslyn\src\Analyzers\Core\Analyzers\RemoveUnnecessarySuppressions\AbstractRemoveUnnecessaryPragmaSuppressionsDiagnosticAnalyzer.cs (4)
497
if (diagnostic.
Location
.SourceTree == tree)
554
Debug.Assert(diagnostic.
Location
.IsInSource);
555
Debug.Assert(diagnostic.
Location
.SourceTree == tree);
565
if (pragma.Span.End <= diagnostic.
Location
.SourceSpan.Start)
Microsoft.CodeAnalysis.CodeStyle.Fixes (53)
src\roslyn\src\Analyzers\Core\CodeFixes\AddAnonymousTypeMemberName\AbstractAddAnonymousTypeMemberNameCodeFixProvider.cs (1)
55
var span = diagnostic.
Location
.SourceSpan;
src\roslyn\src\Analyzers\Core\CodeFixes\AddExplicitCast\AbstractAddExplicitCastCodeFixProvider.cs (2)
74
var spanNode = root.FindNode(diagnostic.
Location
.SourceSpan, getInnermostNodeForTie: true).GetAncestorOrThis<TExpressionSyntax>();
218
d => root.FindNode(d.
Location
.SourceSpan, getInnermostNodeForTie: true)
src\roslyn\src\Analyzers\Core\CodeFixes\AddObsoleteAttribute\AbstractAddObsoleteAttributeCodeFixProvider.cs (2)
45
var node = context.Diagnostics[0].
Location
.FindNode(cancellationToken);
81
var containers = diagnostics.Select(d => GetContainer(root, d.
Location
.FindNode(cancellationToken)))
src\roslyn\src\Analyzers\Core\CodeFixes\AddParameter\AbstractAddParameterCodeFixProvider.cs (1)
70
var initialNode = root.FindNode(diagnostic.
Location
.SourceSpan);
src\roslyn\src\Analyzers\Core\CodeFixes\ConflictMarkerResolution\AbstractConflictMarkerCodeFixProvider.cs (3)
403
(d1, d2) => d1.
Location
.SourceSpan.Start - d2.
Location
.SourceSpan.Start).ToImmutableArray();
416
var position = diagnostic.
Location
.SourceSpan.Start;
src\roslyn\src\Analyzers\Core\CodeFixes\ConvertTypeOfToNameOf\AbstractConvertTypeOfToNameOfCodeFixProvider.cs (1)
40
if (editor.OriginalRoot.FindNode(diagnostic.
Location
.SourceSpan, getInnermostNodeForTie: true) is not TMemberAccessExpressionSyntax node)
src\roslyn\src\Analyzers\Core\CodeFixes\ForEachCast\AbstractForEachCastCodeFixProvider.cs (1)
46
var node = editor.OriginalRoot.FindNode(diagnostic.
Location
.SourceSpan, getInnermostNodeForTie: true);
src\roslyn\src\Analyzers\Core\CodeFixes\Formatting\FormattingCodeFixProvider.cs (1)
74
var diagnosticSpan = diagnostic.
Location
.SourceSpan;
src\roslyn\src\Analyzers\Core\CodeFixes\GenerateDefaultConstructors\AbstractGenerateDefaultConstructorCodeFixProvider.cs (1)
30
if (!headerFacts.IsOnTypeHeader(root, diagnostic.
Location
.SourceSpan.Start, fullHeader: true, out var typeDecl))
src\roslyn\src\Analyzers\Core\CodeFixes\MakeFieldReadonly\AbstractMakeFieldReadonlyCodeFixProvider.cs (1)
46
var diagnosticSpan = diagnostic.
Location
.SourceSpan;
src\roslyn\src\Analyzers\Core\CodeFixes\MakeMemberStatic\AbstractMakeMemberStaticCodeFixProvider.cs (2)
22
TryGetMemberDeclaration(context.Diagnostics[0].
Location
.FindNode(context.CancellationToken), out _))
33
var declaration = diagnostics[i].
Location
.FindNode(cancellationToken);
src\roslyn\src\Analyzers\Core\CodeFixes\MakeMethodAsynchronous\AbstractMakeMethodAsynchronousCodeFixProvider.cs (1)
153
var token = diagnostic.
Location
.FindToken(cancellationToken);
src\roslyn\src\Analyzers\Core\CodeFixes\MakeMethodSynchronous\AbstractMakeMethodSynchronousCodeFixProvider.cs (1)
34
var token = diagnostic.
Location
.FindToken(cancellationToken);
src\roslyn\src\Analyzers\Core\CodeFixes\MakeTypeAbstract\AbstractMakeTypeAbstractCodeFixProvider.cs (2)
22
if (IsValidRefactoringContext(context.Diagnostics[0].
Location
?.FindNode(context.CancellationToken), out _))
33
if (IsValidRefactoringContext(diagnostics[i].
Location
?.FindNode(cancellationToken), out var typeDeclaration))
src\roslyn\src\Analyzers\Core\CodeFixes\MakeTypePartial\AbstractMakeTypePartialCodeFixProvider.cs (1)
31
var declaration = syntaxRoot.FindNode(diagnostic.
Location
.SourceSpan);
src\roslyn\src\Analyzers\Core\CodeFixes\MatchFolderAndNamespace\AbstractChangeNamespaceToMatchFolderCodeFixProvider.CustomFixAllProvider.cs (1)
78
.GroupBy(diagnostic => diagnostic.
Location
.SourceTree)
src\roslyn\src\Analyzers\Core\CodeFixes\OrderModifiers\AbstractOrderModifiersCodeFixProvider.cs (1)
55
var memberDeclaration = diagnostic.
Location
.FindNode(cancellationToken);
src\roslyn\src\Analyzers\Core\CodeFixes\RemoveAsyncModifier\AbstractRemoveAsyncModifierCodeFixProvider.cs (3)
35
var token = diagnostic.
Location
.FindToken(cancellationToken);
64
foreach (var diagnostic in diagnostics.OrderByDescending(d => d.
Location
.SourceSpan.Start))
66
var token = diagnostic.
Location
.FindToken(cancellationToken);
src\roslyn\src\Analyzers\Core\CodeFixes\RemoveUnnecessarySuppressions\RemoveUnnecessaryAttributeSuppressionsCodeFixProvider.cs (2)
32
if (root.FindNode(diagnostic.
Location
.SourceSpan) != null)
43
var node = editor.OriginalRoot.FindNode(diagnostic.
Location
.SourceSpan);
src\roslyn\src\Analyzers\Core\CodeFixes\RemoveUnnecessarySuppressions\RemoveUnnecessaryPragmaSuppressionsCodeFixProvider.cs (3)
37
if (root.FindNode(diagnostic.
Location
.SourceSpan) is { } node && syntaxFacts.IsAttribute(node) ||
38
root.FindTrivia(diagnostic.
Location
.SourceSpan.Start).HasStructure)
56
RemoveNode(diagnostic.
Location
, editor, processedNodes, syntaxFacts);
src\roslyn\src\Analyzers\Core\CodeFixes\RemoveUnusedMembers\AbstractRemoveUnusedMembersCodeFixProvider.cs (1)
54
var diagnosticNode = diagnostic.
Location
.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\roslyn\src\Analyzers\Core\CodeFixes\RemoveUnusedParametersAndValues\AbstractRemoveUnusedValuesCodeFixProvider.cs (6)
208
return syntaxFacts.IsForEachStatement(diagnostic.
Location
.FindNode(getInnermostNodeForTie: true, cancellationToken));
269
return diagnostics.GroupBy(d => syntaxFacts.GetContainingMemberDeclaration(root, d.
Location
.SourceSpan.Start) ?? root);
362
diagnostics.OrderByDescending(d => d.
Location
.SourceSpan.Start),
372
diagnostics.OrderBy(d => d.
Location
.SourceSpan.Start),
401
var expressionStatement = root.FindNode(diagnostic.
Location
.SourceSpan).FirstAncestorOrSelf<TExpressionStatementSyntax>();
677
var node = root.FindNode(diagnostic.
Location
.SourceSpan, getInnermostNodeForTie: true);
src\roslyn\src\Analyzers\Core\CodeFixes\SimplifyBooleanExpression\SimplifyConditionalCodeFixProvider.cs (2)
50
diagnostics.OrderByDescending(d => d.
Location
.SourceSpan.Start).ToImmutableArray(),
51
d => d.
Location
.FindNode(getInnermostNodeForTie: true, cancellationToken),
src\roslyn\src\Analyzers\Core\CodeFixes\SimplifyLinqExpression\SimplifyLinqExpressionCodeFixProvider.cs (2)
41
foreach (var diagnostic in diagnostics.OrderByDescending(diagnostics => diagnostics.
Location
.SourceSpan.Start))
43
var invocation = root.FindNode(diagnostic.
Location
.SourceSpan, getInnermostNodeForTie: true);
src\roslyn\src\Analyzers\Core\CodeFixes\UpdateLegacySuppressions\UpdateLegacySuppressionsCodeFixProvider.cs (2)
33
root.FindNode(diagnostic.
Location
.SourceSpan, getInnermostNodeForTie: true) != null)
44
var node = editor.OriginalRoot.FindNode(diagnostic.
Location
.SourceSpan, getInnermostNodeForTie: true);
src\roslyn\src\Analyzers\Core\CodeFixes\UseExplicitTupleName\UseExplicitTupleNameCodeFixProvider.cs (1)
39
var oldNameNode = diagnostic.
Location
.FindNode(
src\roslyn\src\Analyzers\Core\CodeFixes\UseInferredMemberName\AbstractUseInferredMemberNameCodeFixProvider.cs (1)
34
var node = root.FindNode(diagnostic.
Location
.SourceSpan);
src\roslyn\src\Analyzers\Core\CodeFixes\UseIsNullCheck\AbstractUseIsNullForReferenceEqualsCodeFixProvider.cs (2)
40
var title = GetTitle(negated, diagnostic.
Location
.SourceTree!.Options);
54
foreach (var diagnostic in diagnostics.OrderByDescending(d => d.
Location
.SourceSpan.Start))
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeFixes\FixAllContextHelper.cs (1)
140
foreach (var (textDocument, diagnosticsForDocument) in diagnostics.GroupBy(d => solution.GetTextDocumentForLocation(d.
Location
)))
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeFixes\ForkingSyntaxEditorBasedCodeFixProvider.cs (1)
34
/// computed with respect to the original user document, and as such its <see cref="Diagnostic.
Location
"/> and <see
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeFixes\SyntaxEditorBasedCodeFixProvider.cs (2)
43
.Sort((d1, d2) => d1.
Location
.SourceSpan.Start - d2.
Location
.SourceSpan.Start);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\ProjectExtensions.cs (1)
42
var diagnosticFilePath = PathUtilities.GetDirectoryName(diagnostic?.
Location
.SourceTree?.FilePath ?? project.FilePath);
Microsoft.CodeAnalysis.CSharp (8)
CommandLine\CSharpCompiler.cs (1)
404
diag.
Location
));
Compilation\CSharpDiagnosticFilter.cs (2)
84
d.
Location
,
101
d.
Location
,
FlowAnalysis\DefiniteAssignment.cs (1)
578
diagnostics.Add(newCode, diagnostic.
Location
, args);
Symbols\Source\SourceMemberContainerSymbol.cs (4)
2364
(d.
Location
== arg.method1.GetFirstLocation() || d.
Location
== arg.underlying1.AssociatedSymbol?.TryGetFirstLocation() ||
2365
d.
Location
== arg.method2.GetFirstLocation() || d.
Location
== arg.underlying2.AssociatedSymbol?.TryGetFirstLocation()),
Microsoft.CodeAnalysis.CSharp.CodeStyle (3)
src\roslyn\src\Analyzers\CSharp\Analyzers\RemoveUnnecessarySuppressions\UnnecessaryNullableWarningSuppressionsUtilities.cs (1)
172
var intersectingDiagnostics = diagnostics.Where(d => d.
Location
.SourceSpan.IntersectsWith(rewrittenAncestor.Span));
src\roslyn\src\Analyzers\CSharp\Analyzers\RemoveUnreachableCode\CSharpRemoveUnreachableCodeDiagnosticAnalyzer.cs (1)
65
ProcessUnreachableDiagnostic(context, root, diagnostic.
Location
.SourceSpan);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Helpers\RemoveUnnecessaryImports\CSharpUnnecessaryImportsProvider.cs (1)
36
root.FindNode(diagnostic.
Location
.SourceSpan) is UsingDirectiveSyntax node && predicate(node))
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (61)
src\roslyn\src\Analyzers\CSharp\CodeFixes\AddBraces\CSharpAddBracesCodeFixProvider.cs (1)
37
var statement = root.FindNode(diagnostic.
Location
.SourceSpan, getInnermostNodeForTie: true);
src\roslyn\src\Analyzers\CSharp\CodeFixes\AddInheritdoc\AddInheritdocCodeFixProvider.cs (2)
45
var node = root.FindNode(diagnostic.
Location
.SourceSpan);
75
var node = editor.OriginalRoot.FindNode(diagnostic.
Location
.SourceSpan);
src\roslyn\src\Analyzers\CSharp\CodeFixes\AssignOutParameters\AbstractAssignOutParametersCodeFixProvider.cs (1)
101
diagnostics.SelectAsArray(d => GetContainer(root, d.
Location
.SourceSpan))
src\roslyn\src\Analyzers\CSharp\CodeFixes\ConditionalExpressionInStringInterpolation\CSharpAddParenthesesAroundConditionalExpressionInInterpolatedStringCodeFixProvider.cs (1)
37
var diagnosticSpan = diagnostic.
Location
.SourceSpan;
src\roslyn\src\Analyzers\CSharp\CodeFixes\DisambiguateSameVariable\CSharpDisambiguateSameVariableCodeFixProvider.cs (2)
60
var span = diagnostic.
Location
.SourceSpan;
61
var node = diagnostic.
Location
.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\FixIncorrectConstraint\CSharpFixIncorrectConstraintCodeFixProvider.cs (1)
37
constraint = diagnostic.
Location
.FindNode(cancellationToken) as TypeConstraintSyntax;
src\roslyn\src\Analyzers\CSharp\CodeFixes\FixReturnType\CSharpFixReturnTypeCodeFixProvider.cs (1)
65
var location = diagnostics[0].
Location
;
src\roslyn\src\Analyzers\CSharp\CodeFixes\HiddenExplicitCast\CSharpHiddenExplicitCastCodeFixProvider.cs (2)
41
foreach (var diagnostic in diagnostics.OrderByDescending(d => d.
Location
.SourceSpan.Start))
43
if (diagnostic.
Location
.FindNode(getInnermostNodeForTie: true, cancellationToken) is not CastExpressionSyntax castExpression)
src\roslyn\src\Analyzers\CSharp\CodeFixes\HideBase\HideBaseCodeFixProvider.cs (1)
34
var diagnosticSpan = diagnostic.
Location
.SourceSpan;
src\roslyn\src\Analyzers\CSharp\CodeFixes\MakeAnonymousFunctionStatic\CSharpMakeAnonymousFunctionStaticCodeFixProvider.cs (1)
42
var anonymousFunction = diagnostic.
Location
.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\MakeLocalFunctionStatic\PassInCapturedVariablesAsArgumentsCodeFixProvider.cs (1)
75
.Select(d => root.FindNode(d.
Location
.SourceSpan).AncestorsAndSelf().OfType<LocalFunctionStatementSyntax>().FirstOrDefault())
src\roslyn\src\Analyzers\CSharp\CodeFixes\MakeMemberRequired\CSharpMakeMemberRequiredCodeFixProvider.cs (1)
118
var memberDeclarator = root.FindNode(diagnostic.
Location
.SourceSpan);
src\roslyn\src\Analyzers\CSharp\CodeFixes\MakeMethodAsynchronous\CSharpMakeMethodAsynchronousCodeFixProvider.cs (3)
46
if (diagnostic.
Location
.SourceTree is null)
49
var root = diagnostic.
Location
.SourceTree.GetRoot(cancellationToken);
50
var token = root.FindToken(diagnostic.
Location
.SourceSpan.Start);
src\roslyn\src\Analyzers\CSharp\CodeFixes\MakeStatementAsynchronous\CSharpMakeStatementAsynchronousCodeFixProvider.cs (2)
36
var node = root.FindNode(diagnostic.
Location
.SourceSpan, getInnermostNodeForTie: true);
53
var node = diagnostic.
Location
.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\MakeStructFieldsWritable\CSharpMakeStructFieldsWritableCodeFixProvider.cs (1)
41
var diagnosticNode = diagnostic.
Location
.FindNode(cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\NewLines\ArrowExpressionClausePlacement\ArrowExpressionClausePlacementCodeFixProvider.cs (1)
51
var arrowToken = root.FindToken(diagnostic.
Location
.SourceSpan.Start);
src\roslyn\src\Analyzers\CSharp\CodeFixes\NewLines\ConditionalExpressionPlacement\ConditionalExpressionPlacementCodeFixProvider.cs (1)
51
var questionToken = root.FindToken(diagnostic.
Location
.SourceSpan.Start);
src\roslyn\src\Analyzers\CSharp\CodeFixes\NewLines\ConsecutiveBracePlacement\ConsecutiveBracePlacementCodeFixProvider.cs (1)
67
var token = root.FindToken(diagnostic.
Location
.SourceSpan.Start);
src\roslyn\src\Analyzers\CSharp\CodeFixes\Nullable\CSharpDeclareAsNullableCodeFixProvider.cs (3)
46
var node = context.Diagnostics.First().
Location
.FindNode(getInnermostNodeForTie: true, cancellationToken);
86
var node = diagnostic.
Location
.FindNode(getInnermostNodeForTie: true, cancellationToken);
94
var node = diagnostic.
Location
.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\QualifyMemberAccess\CSharpQualifyMemberAccessCodeFixProvider.cs (1)
23
var node = diagnostic.
Location
.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\RemoveInKeyword\RemoveInKeywordCodeFixProvider.cs (1)
38
var diagnosticSpan = diagnostic.
Location
.SourceSpan;
src\roslyn\src\Analyzers\CSharp\CodeFixes\RemoveNewModifier\RemoveNewModifierCodeFixProvider.cs (1)
36
var diagnosticSpan = diagnostic.
Location
.SourceSpan;
src\roslyn\src\Analyzers\CSharp\CodeFixes\RemoveUnnecessaryDiscardDesignation\CSharpRemoveUnnecessaryDiscardDesignationCodeFixProvider.cs (1)
41
var discard = diagnostic.
Location
.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\RemoveUnnecessaryNullableDirective\CSharpRemoveUnnecessaryNullableDirectiveCodeFixProvider.cs (1)
54
.Select(d => d.
Location
.FindNode(findInsideTrivia: true, getInnermostNodeForTie: true, cancellationToken))
src\roslyn\src\Analyzers\CSharp\CodeFixes\RemoveUnusedLocalFunction\CSharpRemoveUnusedLocalFunctionCodeFixProvider.cs (3)
44
var localFunctions = diagnostics.OrderBy(static (d1, d2) => d2.
Location
.SourceSpan.Start - d1.
Location
.SourceSpan.Start)
45
.Select(d => root.FindToken(d.
Location
.SourceSpan.Start))
src\roslyn\src\Analyzers\CSharp\CodeFixes\SimplifyPropertyAccessor\CSharpSimplifyPropertyAccessorCodeFixProvider.cs (1)
42
var accessor = (AccessorDeclarationSyntax)diagnostic.
Location
.FindNode(cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\TransposeRecordKeyword\CSharpTransposeRecordKeywordCodeFixProvider.cs (1)
32
recordDeclaration = diagnostic.
Location
.FindNode(cancellationToken) as RecordDeclarationSyntax;
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseDeconstruction\CSharpUseDeconstructionCodeFixProvider.cs (1)
40
var nodesToProcess = diagnostics.SelectAsArray(d => d.
Location
.FindToken(cancellationToken).GetRequiredParent());
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseDefaultLiteral\CSharpUseDefaultLiteralCodeFixProvider.cs (1)
52
d => (DefaultExpressionSyntax)originalRoot.FindNode(d.
Location
.SourceSpan, getInnermostNodeForTie: true));
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseExplicitArrayInExpressionTree\CSharpUseExplicitArrayInExpressionTreeCodeFixProvider.cs (3)
98
var node = diagnostic.
Location
.FindNode(getInnermostNodeForTie: true, cancellationToken);
122
foreach (var diagnostic in diagnostics.OrderByDescending(d => d.
Location
.SourceSpan.Start))
124
if (diagnostic.
Location
.FindNode(getInnermostNodeForTie: true, cancellationToken) is not InvocationExpressionSyntax invocation)
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseImplicitlyTypedLambdaExpression\CSharpUseImplicitObjectCreationCodeFixProvider.cs (1)
44
.OrderBy(d => d.
Location
.SourceSpan.End)
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseImplicitObjectCreation\CSharpUseImplicitObjectCreationCodeFixProvider.cs (1)
51
.OrderBy(d => d.
Location
.SourceSpan.End)
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseImplicitOrExplicitType\UseExplicitTypeCodeFixProvider.cs (1)
56
var node = root.FindNode(diagnostic.
Location
.SourceSpan, getInnermostNodeForTie: true);
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseImplicitOrExplicitType\UseImplicitTypeCodeFixProvider.cs (1)
47
var typeSyntax = (TypeSyntax)root.FindNode(diagnostic.
Location
.SourceSpan, getInnermostNodeForTie: true);
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseIndexOrRangeOperator\CSharpUseIndexOperatorCodeFixProvider.cs (2)
39
foreach (var diagnostic in diagnostics.OrderByDescending(d => d.
Location
.SourceSpan.Start))
41
var node = diagnostic.
Location
.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseInterpolatedVerbatimString\CSharpUseInterpolatedVerbatimStringCodeFixProvider.cs (1)
50
var verbatimInterpolatedLocation = diagnostic.
Location
;
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseIsNullCheck\CSharpUseIsNullCheckForCastAndEqualityOperatorCodeFixProvider.cs (2)
42
var title = GetTitle(negated, diagnostic.
Location
.SourceTree!.Options);
57
var binary = (BinaryExpressionSyntax)diagnostic.
Location
.FindNode(getInnermostNodeForTie: true, cancellationToken: cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseIsNullCheck\CSharpUseNullCheckOverTypeCheckCodeFixProvider.cs (1)
42
var node = diagnostic.
Location
.FindNode(getInnermostNodeForTie: true, cancellationToken: cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseNameofInAttribute\CSharpUseNameofInAttributeCodeFixProvider.cs (1)
42
var expression = diagnostic.
Location
.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\UsePatternCombinators\CSharpUsePatternCombinatorsCodeFixProvider.cs (1)
77
var location = diagnostic.
Location
;
src\roslyn\src\Analyzers\CSharp\CodeFixes\UsePatternMatching\CSharpAsAndMemberAccessCodeFixProvider.cs (2)
42
foreach (var diagnostic in diagnostics.OrderByDescending(d => d.
Location
.SourceSpan.Start))
48
var node = diagnostic.
Location
.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\UsePrimaryConstructor\CSharpUsePrimaryConstructorCodeFixProvider.cs (1)
63
if (diagnostic.
Location
.FindNode(cancellationToken) is not ConstructorDeclarationSyntax constructorDeclaration)
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseSystemThreadingLock\CSharpUseSystemThreadingLockCodeFixProvider.cs (1)
47
if (diagnostic.
Location
.FindNode(cancellationToken) is not VariableDeclaratorSyntax variableDeclarator)
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseUtf8StringLiteral\UseUtf8StringLiteralCodeFixProvider.cs (3)
55
var node = diagnostic.
Location
.FindNode(getInnermostNodeForTie: true, cancellationToken);
81
editor.ReplaceNode(node, CreateArgumentListWithUtf8String(argumentList, diagnostic.
Location
, stringValue, isConvertedToReadOnlySpan));
119
.Where(a => a.Initializer?.ElementValues.FirstOrDefault()?.Syntax.SpanStart == diagnostic.
Location
.SourceSpan.Start)
Microsoft.CodeAnalysis.CSharp.Features (74)
Copilot\CSharpCopilotCodeFixProvider.cs (1)
79
var containingMethod = CSharpSyntaxFacts.Instance.GetContainingMethodDeclaration(root, diagnostic.
Location
.SourceSpan.Start, useFullSpan: false);
Copilot\CSharpCopilotProposalAdjusterService.cs (2)
43
var closeBraceDiagnostics = newDiagnostics.WhereAsArray(d => d.Id == CS1513 && d.
Location
.SourceSpan.Start >= lastChangeEndPos);
49
d => new TextChange(new TextSpan(d.
Location
.SourceSpan.Start, 0), "}"));
Copilot\CSharpImplementNotImplementedExceptionFixProvider.cs (2)
59
var diagnosticNode = context.Diagnostics[0].
Location
.FindNode(getInnermostNodeForTie: true, cancellationToken);
92
var diagnosticNode = diagnostic.
Location
.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\roslyn\src\Analyzers\CSharp\Analyzers\RemoveUnnecessarySuppressions\UnnecessaryNullableWarningSuppressionsUtilities.cs (1)
172
var intersectingDiagnostics = diagnostics.Where(d => d.
Location
.SourceSpan.IntersectsWith(rewrittenAncestor.Span));
src\roslyn\src\Analyzers\CSharp\Analyzers\RemoveUnreachableCode\CSharpRemoveUnreachableCodeDiagnosticAnalyzer.cs (1)
65
ProcessUnreachableDiagnostic(context, root, diagnostic.
Location
.SourceSpan);
src\roslyn\src\Analyzers\CSharp\CodeFixes\AddBraces\CSharpAddBracesCodeFixProvider.cs (1)
37
var statement = root.FindNode(diagnostic.
Location
.SourceSpan, getInnermostNodeForTie: true);
src\roslyn\src\Analyzers\CSharp\CodeFixes\AddInheritdoc\AddInheritdocCodeFixProvider.cs (2)
45
var node = root.FindNode(diagnostic.
Location
.SourceSpan);
75
var node = editor.OriginalRoot.FindNode(diagnostic.
Location
.SourceSpan);
src\roslyn\src\Analyzers\CSharp\CodeFixes\AssignOutParameters\AbstractAssignOutParametersCodeFixProvider.cs (1)
101
diagnostics.SelectAsArray(d => GetContainer(root, d.
Location
.SourceSpan))
src\roslyn\src\Analyzers\CSharp\CodeFixes\ConditionalExpressionInStringInterpolation\CSharpAddParenthesesAroundConditionalExpressionInInterpolatedStringCodeFixProvider.cs (1)
37
var diagnosticSpan = diagnostic.
Location
.SourceSpan;
src\roslyn\src\Analyzers\CSharp\CodeFixes\DisambiguateSameVariable\CSharpDisambiguateSameVariableCodeFixProvider.cs (2)
60
var span = diagnostic.
Location
.SourceSpan;
61
var node = diagnostic.
Location
.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\FixIncorrectConstraint\CSharpFixIncorrectConstraintCodeFixProvider.cs (1)
37
constraint = diagnostic.
Location
.FindNode(cancellationToken) as TypeConstraintSyntax;
src\roslyn\src\Analyzers\CSharp\CodeFixes\FixReturnType\CSharpFixReturnTypeCodeFixProvider.cs (1)
65
var location = diagnostics[0].
Location
;
src\roslyn\src\Analyzers\CSharp\CodeFixes\HiddenExplicitCast\CSharpHiddenExplicitCastCodeFixProvider.cs (2)
41
foreach (var diagnostic in diagnostics.OrderByDescending(d => d.
Location
.SourceSpan.Start))
43
if (diagnostic.
Location
.FindNode(getInnermostNodeForTie: true, cancellationToken) is not CastExpressionSyntax castExpression)
src\roslyn\src\Analyzers\CSharp\CodeFixes\HideBase\HideBaseCodeFixProvider.cs (1)
34
var diagnosticSpan = diagnostic.
Location
.SourceSpan;
src\roslyn\src\Analyzers\CSharp\CodeFixes\MakeAnonymousFunctionStatic\CSharpMakeAnonymousFunctionStaticCodeFixProvider.cs (1)
42
var anonymousFunction = diagnostic.
Location
.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\MakeLocalFunctionStatic\PassInCapturedVariablesAsArgumentsCodeFixProvider.cs (1)
75
.Select(d => root.FindNode(d.
Location
.SourceSpan).AncestorsAndSelf().OfType<LocalFunctionStatementSyntax>().FirstOrDefault())
src\roslyn\src\Analyzers\CSharp\CodeFixes\MakeMemberRequired\CSharpMakeMemberRequiredCodeFixProvider.cs (1)
118
var memberDeclarator = root.FindNode(diagnostic.
Location
.SourceSpan);
src\roslyn\src\Analyzers\CSharp\CodeFixes\MakeMethodAsynchronous\CSharpMakeMethodAsynchronousCodeFixProvider.cs (3)
46
if (diagnostic.
Location
.SourceTree is null)
49
var root = diagnostic.
Location
.SourceTree.GetRoot(cancellationToken);
50
var token = root.FindToken(diagnostic.
Location
.SourceSpan.Start);
src\roslyn\src\Analyzers\CSharp\CodeFixes\MakeStatementAsynchronous\CSharpMakeStatementAsynchronousCodeFixProvider.cs (2)
36
var node = root.FindNode(diagnostic.
Location
.SourceSpan, getInnermostNodeForTie: true);
53
var node = diagnostic.
Location
.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\MakeStructFieldsWritable\CSharpMakeStructFieldsWritableCodeFixProvider.cs (1)
41
var diagnosticNode = diagnostic.
Location
.FindNode(cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\NewLines\ArrowExpressionClausePlacement\ArrowExpressionClausePlacementCodeFixProvider.cs (1)
51
var arrowToken = root.FindToken(diagnostic.
Location
.SourceSpan.Start);
src\roslyn\src\Analyzers\CSharp\CodeFixes\NewLines\ConditionalExpressionPlacement\ConditionalExpressionPlacementCodeFixProvider.cs (1)
51
var questionToken = root.FindToken(diagnostic.
Location
.SourceSpan.Start);
src\roslyn\src\Analyzers\CSharp\CodeFixes\NewLines\ConsecutiveBracePlacement\ConsecutiveBracePlacementCodeFixProvider.cs (1)
67
var token = root.FindToken(diagnostic.
Location
.SourceSpan.Start);
src\roslyn\src\Analyzers\CSharp\CodeFixes\Nullable\CSharpDeclareAsNullableCodeFixProvider.cs (3)
46
var node = context.Diagnostics.First().
Location
.FindNode(getInnermostNodeForTie: true, cancellationToken);
86
var node = diagnostic.
Location
.FindNode(getInnermostNodeForTie: true, cancellationToken);
94
var node = diagnostic.
Location
.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\QualifyMemberAccess\CSharpQualifyMemberAccessCodeFixProvider.cs (1)
23
var node = diagnostic.
Location
.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\RemoveInKeyword\RemoveInKeywordCodeFixProvider.cs (1)
38
var diagnosticSpan = diagnostic.
Location
.SourceSpan;
src\roslyn\src\Analyzers\CSharp\CodeFixes\RemoveNewModifier\RemoveNewModifierCodeFixProvider.cs (1)
36
var diagnosticSpan = diagnostic.
Location
.SourceSpan;
src\roslyn\src\Analyzers\CSharp\CodeFixes\RemoveUnnecessaryDiscardDesignation\CSharpRemoveUnnecessaryDiscardDesignationCodeFixProvider.cs (1)
41
var discard = diagnostic.
Location
.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\RemoveUnnecessaryNullableDirective\CSharpRemoveUnnecessaryNullableDirectiveCodeFixProvider.cs (1)
54
.Select(d => d.
Location
.FindNode(findInsideTrivia: true, getInnermostNodeForTie: true, cancellationToken))
src\roslyn\src\Analyzers\CSharp\CodeFixes\RemoveUnusedLocalFunction\CSharpRemoveUnusedLocalFunctionCodeFixProvider.cs (3)
44
var localFunctions = diagnostics.OrderBy(static (d1, d2) => d2.
Location
.SourceSpan.Start - d1.
Location
.SourceSpan.Start)
45
.Select(d => root.FindToken(d.
Location
.SourceSpan.Start))
src\roslyn\src\Analyzers\CSharp\CodeFixes\SimplifyPropertyAccessor\CSharpSimplifyPropertyAccessorCodeFixProvider.cs (1)
42
var accessor = (AccessorDeclarationSyntax)diagnostic.
Location
.FindNode(cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\TransposeRecordKeyword\CSharpTransposeRecordKeywordCodeFixProvider.cs (1)
32
recordDeclaration = diagnostic.
Location
.FindNode(cancellationToken) as RecordDeclarationSyntax;
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseDeconstruction\CSharpUseDeconstructionCodeFixProvider.cs (1)
40
var nodesToProcess = diagnostics.SelectAsArray(d => d.
Location
.FindToken(cancellationToken).GetRequiredParent());
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseDefaultLiteral\CSharpUseDefaultLiteralCodeFixProvider.cs (1)
52
d => (DefaultExpressionSyntax)originalRoot.FindNode(d.
Location
.SourceSpan, getInnermostNodeForTie: true));
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseExplicitArrayInExpressionTree\CSharpUseExplicitArrayInExpressionTreeCodeFixProvider.cs (3)
98
var node = diagnostic.
Location
.FindNode(getInnermostNodeForTie: true, cancellationToken);
122
foreach (var diagnostic in diagnostics.OrderByDescending(d => d.
Location
.SourceSpan.Start))
124
if (diagnostic.
Location
.FindNode(getInnermostNodeForTie: true, cancellationToken) is not InvocationExpressionSyntax invocation)
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseImplicitlyTypedLambdaExpression\CSharpUseImplicitObjectCreationCodeFixProvider.cs (1)
44
.OrderBy(d => d.
Location
.SourceSpan.End)
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseImplicitObjectCreation\CSharpUseImplicitObjectCreationCodeFixProvider.cs (1)
51
.OrderBy(d => d.
Location
.SourceSpan.End)
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseImplicitOrExplicitType\UseExplicitTypeCodeFixProvider.cs (1)
56
var node = root.FindNode(diagnostic.
Location
.SourceSpan, getInnermostNodeForTie: true);
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseImplicitOrExplicitType\UseImplicitTypeCodeFixProvider.cs (1)
47
var typeSyntax = (TypeSyntax)root.FindNode(diagnostic.
Location
.SourceSpan, getInnermostNodeForTie: true);
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseIndexOrRangeOperator\CSharpUseIndexOperatorCodeFixProvider.cs (2)
39
foreach (var diagnostic in diagnostics.OrderByDescending(d => d.
Location
.SourceSpan.Start))
41
var node = diagnostic.
Location
.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseInterpolatedVerbatimString\CSharpUseInterpolatedVerbatimStringCodeFixProvider.cs (1)
50
var verbatimInterpolatedLocation = diagnostic.
Location
;
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseIsNullCheck\CSharpUseIsNullCheckForCastAndEqualityOperatorCodeFixProvider.cs (2)
42
var title = GetTitle(negated, diagnostic.
Location
.SourceTree!.Options);
57
var binary = (BinaryExpressionSyntax)diagnostic.
Location
.FindNode(getInnermostNodeForTie: true, cancellationToken: cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseIsNullCheck\CSharpUseNullCheckOverTypeCheckCodeFixProvider.cs (1)
42
var node = diagnostic.
Location
.FindNode(getInnermostNodeForTie: true, cancellationToken: cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseNameofInAttribute\CSharpUseNameofInAttributeCodeFixProvider.cs (1)
42
var expression = diagnostic.
Location
.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\UsePatternCombinators\CSharpUsePatternCombinatorsCodeFixProvider.cs (1)
77
var location = diagnostic.
Location
;
src\roslyn\src\Analyzers\CSharp\CodeFixes\UsePatternMatching\CSharpAsAndMemberAccessCodeFixProvider.cs (2)
42
foreach (var diagnostic in diagnostics.OrderByDescending(d => d.
Location
.SourceSpan.Start))
48
var node = diagnostic.
Location
.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\UsePrimaryConstructor\CSharpUsePrimaryConstructorCodeFixProvider.cs (1)
63
if (diagnostic.
Location
.FindNode(cancellationToken) is not ConstructorDeclarationSyntax constructorDeclaration)
src\roslyn\src\Analyzers\CSharp\CodeFixes\UsePrimaryConstructor\CSharpUsePrimaryConstructorFixAllProvider.cs (2)
50
foreach (var diagnostic in diagnostics.OrderByDescending(d => d.
Location
.SourceSpan.Start))
52
if (diagnostic.
Location
.FindNode(cancellationToken) is not ConstructorDeclarationSyntax constructorDeclaration)
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseSystemThreadingLock\CSharpUseSystemThreadingLockCodeFixProvider.cs (1)
47
if (diagnostic.
Location
.FindNode(cancellationToken) is not VariableDeclaratorSyntax variableDeclarator)
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseSystemThreadingLock\CSharpUseSystemThreadingLockFixAllProvider.cs (2)
42
foreach (var diagnostic in diagnostics.OrderByDescending(d => d.
Location
.SourceSpan.Start))
44
if (diagnostic.
Location
.FindNode(cancellationToken) is not VariableDeclaratorSyntax declarator)
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseUtf8StringLiteral\UseUtf8StringLiteralCodeFixProvider.cs (3)
55
var node = diagnostic.
Location
.FindNode(getInnermostNodeForTie: true, cancellationToken);
81
editor.ReplaceNode(node, CreateArgumentListWithUtf8String(argumentList, diagnostic.
Location
, stringValue, isConvertedToReadOnlySpan));
119
.Where(a => a.Initializer?.ElementValues.FirstOrDefault()?.Syntax.SpanStart == diagnostic.
Location
.SourceSpan.Start)
StringIndentation\CSharpStringIndentationService.cs (1)
103
if (!IsInHole(interpolatedString, error.
Location
.SourceSpan))
UsePatternMatching\CSharpIsAndCastCheckWithoutNameCodeFixProvider.cs (1)
41
var location = diagnostics[0].
Location
;
Microsoft.CodeAnalysis.CSharp.NetAnalyzers (1)
Microsoft.NetCore.Analyzers\InteropServices\CSharpDisableRuntimeMarshalling.FixAllProvider.cs (1)
42
SyntaxNode node = root.FindNode(diagnostic.
Location
.SourceSpan);
Microsoft.CodeAnalysis.CSharp.Workspaces (2)
Simplification\CSharpSimplificationService.cs (1)
194
if (root.FindNode(diagnostic.
Location
.SourceSpan) is UsingDirectiveSyntax node)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Helpers\RemoveUnnecessaryImports\CSharpUnnecessaryImportsProvider.cs (1)
36
root.FindNode(diagnostic.
Location
.SourceSpan) is UsingDirectiveSyntax node && predicate(node))
Microsoft.CodeAnalysis.Features (93)
AddImport\AbstractAddImportFeatureService.cs (1)
554
.GroupBy(diagnostic => diagnostic.
Location
.SourceSpan)
CodeFixes\Configuration\ConfigurationUpdater.cs (1)
431
var diagnosticSourceTree = _diagnostic?.
Location
.SourceTree;
CodeFixes\Configuration\ConfigureCodeStyle\ConfigureCodeStyleOptionCodeFixProvider.cs (2)
43
diagnostic.
Location
.SourceTree == null)
48
var language = diagnostic.
Location
.SourceTree.Options.Language;
CodeFixes\Service\CodeFixService.cs (1)
551
return GetCodeFixesAsync(document, primaryDiagnostic.
Location
.SourceSpan, fixer, fixerMetadata,
CodeFixes\Suppression\AbstractSuppressionBatchFixAllProvider.cs (1)
281
tuple => tuple.action, tuple => tuple.diagnostic?.
Location
.SourceSpan.Start ?? 0);
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.cs (1)
210
if (diagnostic.
Location
.IsInSource && documentOpt != null)
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.GlobalSuppressMessageFixAllCodeAction.cs (3)
159
Contract.ThrowIfFalse(diagnostic.
Location
.IsInSource);
160
var suppressionTargetInfo = await fixer.GetSuppressionTargetInfoAsync(document, diagnostic.
Location
.SourceSpan, cancellationToken).ConfigureAwait(false);
181
Contract.ThrowIfFalse(!diagnostic.
Location
.IsInSource);
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.PragmaBatchFixHelpers.cs (1)
53
currentDiagnosticSpans.Add(diagnostic, diagnostic.
Location
.SourceSpan);
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.PragmaWarningBatchFixAllProvider.cs (2)
34
foreach (var diagnostic in diagnostics.Where(d => d.
Location
.IsInSource && !d.IsSuppressed))
36
var span = diagnostic.
Location
.SourceSpan;
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.PragmaWarningCodeAction.cs (1)
64
_diagnostic.
Location
.SourceSpan,
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.RemoveSuppressionCodeAction.BatchFixer.cs (3)
43
foreach (var diagnostic in diagnostics.Where(d => d.
Location
.IsInSource && d.IsSuppressed))
45
var span = diagnostic.
Location
.SourceSpan;
89
foreach (var diagnostic in diagnostics.Where(d => !d.
Location
.IsInSource && d.IsSuppressed))
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.RemoveSuppressionCodeAction_Pragma.cs (2)
97
_diagnostic.
Location
.SourceSpan,
124
var diagnosticSpan = diagnostic.
Location
.SourceSpan;
CodeFixes\Suppression\WrapperCodeFixProvider.cs (2)
26
var documentDiagnostics = diagnostics.WhereAsArray(d => d.
Location
.IsInSource);
33
var projectDiagnostics = diagnostics.WhereAsArray(d => !d.
Location
.IsInSource);
Diagnostics\Service\DocumentAnalysisExecutor.cs (1)
351
bool shouldInclude(Diagnostic d) => span.Value.IntersectsWith(d.
Location
.SourceSpan) && !IsUnusedImportDiagnostic(d);
Diagnostics\Service\DocumentAnalysisExecutor_Helpers.cs (4)
128
await VerifyDiagnosticLocationAsync(diagnostic.Id, diagnostic.
Location
).ConfigureAwait(false);
226
return x.Id == y.Id && x.
Location
== y.
Location
;
234
return Hash.Combine(obj.Id.GetHashCode(), obj.
Location
.GetHashCode());
EditAndContinue\EmitSolutionUpdateResults.cs (2)
181
Debug.Assert(SyntaxError.
Location
.SourceTree != null);
182
return DiagnosticData.Create(SyntaxError, Solution.GetRequiredDocument(SyntaxError.
Location
.SourceTree));
EditAndContinue\ProjectDiagnostics.cs (1)
26
var document = solution.GetDocument(diagnostic.
Location
.SourceTree);
EmbeddedLanguages\Json\LanguageServices\AbstractJsonDetectionCodeFixProvider.cs (1)
43
var stringLiteral = diagnostic.
Location
.FindToken(cancellationToken);
PreferFrameworkType\PreferFrameworkTypeCodeFixProvider.cs (1)
46
var node = diagnostic.
Location
.FindNode(
RemoveUnusedVariable\AbstractRemoveUnusedVariableCodeFixProvider.cs (3)
45
var node = root.FindNode(diagnostic.
Location
.SourceSpan);
68
var token = diagnostic.
Location
.FindToken(cancellationToken);
69
var node = root.FindNode(diagnostic.
Location
.SourceSpan);
SimplifyTypeNames\AbstractSimplifyTypeNamesCodeFixProvider.cs (1)
102
root, model, diagnostic.
Location
.SourceSpan,
src\roslyn\src\Analyzers\Core\Analyzers\RemoveUnnecessarySuppressions\AbstractRemoveUnnecessaryPragmaSuppressionsDiagnosticAnalyzer.cs (4)
497
if (diagnostic.
Location
.SourceTree == tree)
554
Debug.Assert(diagnostic.
Location
.IsInSource);
555
Debug.Assert(diagnostic.
Location
.SourceTree == tree);
565
if (pragma.Span.End <= diagnostic.
Location
.SourceSpan.Start)
src\roslyn\src\Analyzers\Core\CodeFixes\AddAnonymousTypeMemberName\AbstractAddAnonymousTypeMemberNameCodeFixProvider.cs (1)
55
var span = diagnostic.
Location
.SourceSpan;
src\roslyn\src\Analyzers\Core\CodeFixes\AddExplicitCast\AbstractAddExplicitCastCodeFixProvider.cs (2)
74
var spanNode = root.FindNode(diagnostic.
Location
.SourceSpan, getInnermostNodeForTie: true).GetAncestorOrThis<TExpressionSyntax>();
218
d => root.FindNode(d.
Location
.SourceSpan, getInnermostNodeForTie: true)
src\roslyn\src\Analyzers\Core\CodeFixes\AddObsoleteAttribute\AbstractAddObsoleteAttributeCodeFixProvider.cs (2)
45
var node = context.Diagnostics[0].
Location
.FindNode(cancellationToken);
81
var containers = diagnostics.Select(d => GetContainer(root, d.
Location
.FindNode(cancellationToken)))
src\roslyn\src\Analyzers\Core\CodeFixes\AddParameter\AbstractAddParameterCodeFixProvider.cs (1)
70
var initialNode = root.FindNode(diagnostic.
Location
.SourceSpan);
src\roslyn\src\Analyzers\Core\CodeFixes\ConflictMarkerResolution\AbstractConflictMarkerCodeFixProvider.cs (3)
403
(d1, d2) => d1.
Location
.SourceSpan.Start - d2.
Location
.SourceSpan.Start).ToImmutableArray();
416
var position = diagnostic.
Location
.SourceSpan.Start;
src\roslyn\src\Analyzers\Core\CodeFixes\ConvertTypeOfToNameOf\AbstractConvertTypeOfToNameOfCodeFixProvider.cs (1)
40
if (editor.OriginalRoot.FindNode(diagnostic.
Location
.SourceSpan, getInnermostNodeForTie: true) is not TMemberAccessExpressionSyntax node)
src\roslyn\src\Analyzers\Core\CodeFixes\ForEachCast\AbstractForEachCastCodeFixProvider.cs (1)
46
var node = editor.OriginalRoot.FindNode(diagnostic.
Location
.SourceSpan, getInnermostNodeForTie: true);
src\roslyn\src\Analyzers\Core\CodeFixes\Formatting\FormattingCodeFixProvider.cs (1)
74
var diagnosticSpan = diagnostic.
Location
.SourceSpan;
src\roslyn\src\Analyzers\Core\CodeFixes\GenerateDefaultConstructors\AbstractGenerateDefaultConstructorCodeFixProvider.cs (1)
30
if (!headerFacts.IsOnTypeHeader(root, diagnostic.
Location
.SourceSpan.Start, fullHeader: true, out var typeDecl))
src\roslyn\src\Analyzers\Core\CodeFixes\MakeFieldReadonly\AbstractMakeFieldReadonlyCodeFixProvider.cs (1)
46
var diagnosticSpan = diagnostic.
Location
.SourceSpan;
src\roslyn\src\Analyzers\Core\CodeFixes\MakeMemberStatic\AbstractMakeMemberStaticCodeFixProvider.cs (2)
22
TryGetMemberDeclaration(context.Diagnostics[0].
Location
.FindNode(context.CancellationToken), out _))
33
var declaration = diagnostics[i].
Location
.FindNode(cancellationToken);
src\roslyn\src\Analyzers\Core\CodeFixes\MakeMethodAsynchronous\AbstractMakeMethodAsynchronousCodeFixProvider.cs (1)
153
var token = diagnostic.
Location
.FindToken(cancellationToken);
src\roslyn\src\Analyzers\Core\CodeFixes\MakeMethodSynchronous\AbstractMakeMethodSynchronousCodeFixProvider.cs (1)
34
var token = diagnostic.
Location
.FindToken(cancellationToken);
src\roslyn\src\Analyzers\Core\CodeFixes\MakeTypeAbstract\AbstractMakeTypeAbstractCodeFixProvider.cs (2)
22
if (IsValidRefactoringContext(context.Diagnostics[0].
Location
?.FindNode(context.CancellationToken), out _))
33
if (IsValidRefactoringContext(diagnostics[i].
Location
?.FindNode(cancellationToken), out var typeDeclaration))
src\roslyn\src\Analyzers\Core\CodeFixes\MakeTypePartial\AbstractMakeTypePartialCodeFixProvider.cs (1)
31
var declaration = syntaxRoot.FindNode(diagnostic.
Location
.SourceSpan);
src\roslyn\src\Analyzers\Core\CodeFixes\MatchFolderAndNamespace\AbstractChangeNamespaceToMatchFolderCodeFixProvider.CustomFixAllProvider.cs (1)
78
.GroupBy(diagnostic => diagnostic.
Location
.SourceTree)
src\roslyn\src\Analyzers\Core\CodeFixes\OrderModifiers\AbstractOrderModifiersCodeFixProvider.cs (1)
55
var memberDeclaration = diagnostic.
Location
.FindNode(cancellationToken);
src\roslyn\src\Analyzers\Core\CodeFixes\RemoveAsyncModifier\AbstractRemoveAsyncModifierCodeFixProvider.cs (3)
35
var token = diagnostic.
Location
.FindToken(cancellationToken);
64
foreach (var diagnostic in diagnostics.OrderByDescending(d => d.
Location
.SourceSpan.Start))
66
var token = diagnostic.
Location
.FindToken(cancellationToken);
src\roslyn\src\Analyzers\Core\CodeFixes\RemoveUnnecessarySuppressions\RemoveUnnecessaryAttributeSuppressionsCodeFixProvider.cs (2)
32
if (root.FindNode(diagnostic.
Location
.SourceSpan) != null)
43
var node = editor.OriginalRoot.FindNode(diagnostic.
Location
.SourceSpan);
src\roslyn\src\Analyzers\Core\CodeFixes\RemoveUnnecessarySuppressions\RemoveUnnecessaryPragmaSuppressionsCodeFixProvider.cs (3)
37
if (root.FindNode(diagnostic.
Location
.SourceSpan) is { } node && syntaxFacts.IsAttribute(node) ||
38
root.FindTrivia(diagnostic.
Location
.SourceSpan.Start).HasStructure)
56
RemoveNode(diagnostic.
Location
, editor, processedNodes, syntaxFacts);
src\roslyn\src\Analyzers\Core\CodeFixes\RemoveUnusedMembers\AbstractRemoveUnusedMembersCodeFixProvider.cs (1)
54
var diagnosticNode = diagnostic.
Location
.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\roslyn\src\Analyzers\Core\CodeFixes\RemoveUnusedParametersAndValues\AbstractRemoveUnusedValuesCodeFixProvider.cs (6)
208
return syntaxFacts.IsForEachStatement(diagnostic.
Location
.FindNode(getInnermostNodeForTie: true, cancellationToken));
269
return diagnostics.GroupBy(d => syntaxFacts.GetContainingMemberDeclaration(root, d.
Location
.SourceSpan.Start) ?? root);
362
diagnostics.OrderByDescending(d => d.
Location
.SourceSpan.Start),
372
diagnostics.OrderBy(d => d.
Location
.SourceSpan.Start),
401
var expressionStatement = root.FindNode(diagnostic.
Location
.SourceSpan).FirstAncestorOrSelf<TExpressionStatementSyntax>();
677
var node = root.FindNode(diagnostic.
Location
.SourceSpan, getInnermostNodeForTie: true);
src\roslyn\src\Analyzers\Core\CodeFixes\SimplifyBooleanExpression\SimplifyConditionalCodeFixProvider.cs (2)
50
diagnostics.OrderByDescending(d => d.
Location
.SourceSpan.Start).ToImmutableArray(),
51
d => d.
Location
.FindNode(getInnermostNodeForTie: true, cancellationToken),
src\roslyn\src\Analyzers\Core\CodeFixes\SimplifyLinqExpression\SimplifyLinqExpressionCodeFixProvider.cs (2)
41
foreach (var diagnostic in diagnostics.OrderByDescending(diagnostics => diagnostics.
Location
.SourceSpan.Start))
43
var invocation = root.FindNode(diagnostic.
Location
.SourceSpan, getInnermostNodeForTie: true);
src\roslyn\src\Analyzers\Core\CodeFixes\UpdateLegacySuppressions\UpdateLegacySuppressionsCodeFixProvider.cs (2)
33
root.FindNode(diagnostic.
Location
.SourceSpan, getInnermostNodeForTie: true) != null)
44
var node = editor.OriginalRoot.FindNode(diagnostic.
Location
.SourceSpan, getInnermostNodeForTie: true);
src\roslyn\src\Analyzers\Core\CodeFixes\UseExplicitTupleName\UseExplicitTupleNameCodeFixProvider.cs (1)
39
var oldNameNode = diagnostic.
Location
.FindNode(
src\roslyn\src\Analyzers\Core\CodeFixes\UseInferredMemberName\AbstractUseInferredMemberNameCodeFixProvider.cs (1)
34
var node = root.FindNode(diagnostic.
Location
.SourceSpan);
src\roslyn\src\Analyzers\Core\CodeFixes\UseIsNullCheck\AbstractUseIsNullForReferenceEqualsCodeFixProvider.cs (2)
40
var title = GetTitle(negated, diagnostic.
Location
.SourceTree!.Options);
54
foreach (var diagnostic in diagnostics.OrderByDescending(d => d.
Location
.SourceSpan.Start))
SyncNamespaces\AbstractSyncNamespacesService.cs (5)
107
RoslynDebug.AssertNotNull(firstDiagnostic?.
Location
?.SourceTree);
109
var document = solution.GetRequiredDocument(firstDiagnostic.
Location
.SourceTree);
115
firstDiagnostic.
Location
.SourceSpan,
124
diagnosticSpan: firstDiagnostic.
Location
.SourceSpan,
172
.WhereAsArray(diagnostic => diagnostic.
Location
.SourceTree?.FilePath == document.FilePath);
Wrapping\AbstractWrapper.cs (1)
66
=> declaration.GetDiagnostics().Any(d => d.Severity == DiagnosticSeverity.Error && d.
Location
.SourceSpan.OverlapsWith(headerSpan));
Microsoft.CodeAnalysis.Razor.Compiler (2)
Analyzers\ComponentParameterNullableWarningSuppressor.cs (2)
36
var node = diagnostic.
Location
.SourceTree?.GetRoot(context.CancellationToken).FindNode(diagnostic.
Location
.SourceSpan);
Microsoft.CodeAnalysis.Scripting (2)
Hosting\CommandLine\CommandLineRunner.cs (2)
384
return (delta != 0) ? delta : d1.
Location
.SourceSpan.Start - d2.
Location
.SourceSpan.Start;
Microsoft.CodeAnalysis.VisualBasic (12)
CommandLine\CommandLineDiagnosticFormatter.vb (7)
44
If diagnostic.
Location
<> Location.None Then
131
If diagnostic.
Location
.IsInSource Then
132
text = diagnostic.
Location
.SourceTree.GetText()
133
Return diagnostic.
Location
.SourceSpan
136
If diagnostic.
Location
.Kind = LocationKind.ExternalFile Then
137
Dim path = diagnostic.
Location
.GetLineSpan().Path
147
Return diagnostic.
Location
.SourceSpan
CommandLine\VisualBasicCompiler.vb (1)
325
newDiagnostics.Add(New VBDiagnostic(ErrorFactory.ErrorInfo(ERRID.ERR_SymbolDefinedInAssembly, symbol, symbol.ContainingAssembly), diag.
Location
))
Compilation\VisualBasicDiagnosticFilter.vb (2)
74
diagnostic.
Location
,
86
diagnostic.
Location
,
GlobalImport.vb (1)
117
Dim unmappedSpan = unmappedDiag.
Location
.SourceSpan
Symbols\Source\SourceModuleSymbol.vb (1)
1023
Dim loc = d.
Location
Microsoft.CodeAnalysis.VisualBasic.CodeStyle (2)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Helpers\RemoveUnnecessaryImports\VisualBasicUnnecessaryImportsProvider.vb (2)
37
Dim node = TryCast(root.FindNode(diagnostic.
Location
.SourceSpan), ImportsClauseSyntax)
44
Dim node = TryCast(root.FindNode(diagnostic.
Location
.SourceSpan), ImportsStatementSyntax)
Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes (3)
src\roslyn\src\Analyzers\VisualBasic\CodeFixes\GenerateParameterizedMember\GenerateParameterizedMemberCodeFixProvider.vb (1)
61
Dim diagnosticSpan = diagnostic.
Location
.SourceSpan
src\roslyn\src\Analyzers\VisualBasic\CodeFixes\QualifyMemberAccess\VisualBasicQualifyMemberAccessCodeFixProvider.vb (1)
28
Dim node = diagnostic.
Location
.FindNode(True, cancellationToken)
src\roslyn\src\Analyzers\VisualBasic\CodeFixes\SimplifyObjectCreation\VisualBasicSimplifyObjectCreationCodeFixProvider.vb (1)
37
Dim node = DirectCast(root.FindNode(diagnostic.
Location
.SourceSpan, getInnermostNodeForTie:=True), VariableDeclaratorSyntax)
Microsoft.CodeAnalysis.VisualBasic.Features (6)
RemoveSharedFromModuleMembers\VisualBasicRemoveSharedFromModuleMembersCodeFixProvider.vb (3)
41
Dim tokenToRemove = diagnostic.
Location
.FindToken(context.CancellationToken)
46
Dim node = diagnostic.
Location
.FindNode(context.CancellationToken)
59
Dim node = diagnostic.
Location
.FindNode(cancellationToken)
src\roslyn\src\Analyzers\VisualBasic\CodeFixes\GenerateParameterizedMember\GenerateParameterizedMemberCodeFixProvider.vb (1)
61
Dim diagnosticSpan = diagnostic.
Location
.SourceSpan
src\roslyn\src\Analyzers\VisualBasic\CodeFixes\QualifyMemberAccess\VisualBasicQualifyMemberAccessCodeFixProvider.vb (1)
28
Dim node = diagnostic.
Location
.FindNode(True, cancellationToken)
src\roslyn\src\Analyzers\VisualBasic\CodeFixes\SimplifyObjectCreation\VisualBasicSimplifyObjectCreationCodeFixProvider.vb (1)
37
Dim node = DirectCast(root.FindNode(diagnostic.
Location
.SourceSpan, getInnermostNodeForTie:=True), VariableDeclaratorSyntax)
Microsoft.CodeAnalysis.VisualBasic.Workspaces (3)
Simplification\VisualBasicSimplificationService.vb (1)
170
Dim node = root.FindNode(diagnostic.
Location
.SourceSpan)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Helpers\RemoveUnnecessaryImports\VisualBasicUnnecessaryImportsProvider.vb (2)
37
Dim node = TryCast(root.FindNode(diagnostic.
Location
.SourceSpan), ImportsClauseSyntax)
44
Dim node = TryCast(root.FindNode(diagnostic.
Location
.SourceSpan), ImportsStatementSyntax)
Microsoft.CodeAnalysis.Workspaces (38)
CodeFixes\CodeFixContext.cs (3)
150
(diagnostic ?? throw new ArgumentNullException(nameof(diagnostic))).
Location
.SourceSpan,
174
(diagnostic ?? throw new ArgumentNullException(nameof(diagnostic))).
Location
.SourceSpan,
250
if (diagnostics.Any((d, span) => d.
Location
.SourceSpan != span, span))
CodeFixes\FixAllOccurrences\BatchFixAllProvider.cs (5)
117
.Where(d => d.
Location
.IsInSource)
118
.OrderBy(d => d.
Location
.SourceTree!.FilePath)
119
.ThenBy(d => d.
Location
.SourceSpan.Start)
147
var document = solution.GetRequiredDocument(diagnostic.
Location
.SourceTree!);
155
var context = new CodeFixContext(document, diagnostic.
Location
.SourceSpan, [diagnostic], action, cancellationToken);
CodeFixes\FixAllOccurrences\FixAllContext.cs (1)
249
&& (filterSpan == null || filterSpan.Value.Contains(d.
Location
.SourceSpan)))];
CodeFixes\FixAllOccurrences\FixAllState.cs (1)
69
var diagnosticSpan = diagnosticsToFix.First().Value.FirstOrDefault()?.
Location
.SourceSpan;
Diagnostics\DiagnosticAnalysisResultBuilder.cs (7)
53
switch (diagnostic.
Location
.Kind)
57
var diagnosticDocumentId = Project.GetDocumentForExternalLocation(diagnostic.
Location
);
112
=> AddDiagnostic(ref _lazySemanticLocals, diagnostic.
Location
.SourceTree, diagnostic);
130
switch (diagnostic.
Location
.Kind)
133
var diagnosticDocumentId = Project.GetDocumentForExternalLocation(diagnostic.
Location
);
150
var diagnosticTree = diagnostic.
Location
.SourceTree;
175
throw ExceptionUtilities.UnexpectedValue(diagnostic.
Location
.Kind);
Diagnostics\DiagnosticData.cs (4)
212
var document = project.GetDocument(diagnostic.
Location
.SourceTree);
216
if (diagnostic.
Location
.Kind == LocationKind.ExternalFile)
218
document = project.Documents.FirstOrDefault(d => d.FilePath == diagnostic.
Location
.GetLineSpan().Path);
231
var location = CreateLocation(document, diagnostic.
Location
);
Diagnostics\Extensions.cs (10)
223
var diagnostics = additionalPragmaSuppressionDiagnostics.WhereAsArray(d => d.
Location
.SourceTree == treeToAnalyze);
230
foreach (var group in additionalPragmaSuppressionDiagnostics.GroupBy(d => d.
Location
.SourceTree!))
283
Debug.Assert(diagnostics.All(d => d.
Location
.SourceTree == tree));
295
Debug.Assert(diagnostics.All(d => d.
Location
.SourceTree == tree));
322
filterSpan.HasValue && !filterSpan.Value.IntersectsWith(diagnostic.
Location
.SourceSpan));
440
if (span.HasValue && !span.Value.IntersectsWith(diagnostic.
Location
.SourceSpan))
451
if (diagnostic.
Location
.SourceTree != null)
453
return targetTextDocument.Project.GetDocument(diagnostic.
Location
.SourceTree) == targetTextDocument;
455
else if (diagnostic.
Location
.Kind == LocationKind.ExternalFile)
457
var lineSpan = diagnostic.
Location
.GetLineSpan();
Diagnostics\GeneratorDiagnosticsPlaceholderAnalyzer.cs (1)
42
else if (diagnostic.
Location
.Kind == LocationKind.None &&
Log\WorkspaceStructureLogger.cs (1)
193
new XAttribute("path", SanitizePath(diagnostic.
Location
.GetLineSpan().Path)),
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeFixes\FixAllContextHelper.cs (1)
140
foreach (var (textDocument, diagnosticsForDocument) in diagnostics.GroupBy(d => solution.GetTextDocumentForLocation(d.
Location
)))
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeFixes\ForkingSyntaxEditorBasedCodeFixProvider.cs (1)
34
/// computed with respect to the original user document, and as such its <see cref="Diagnostic.
Location
"/> and <see
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeFixes\SyntaxEditorBasedCodeFixProvider.cs (2)
43
.Sort((d1, d2) => d1.
Location
.SourceSpan.Start - d2.
Location
.SourceSpan.Start);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\ProjectExtensions.cs (1)
42
var diagnosticFilePath = PathUtilities.GetDirectoryName(diagnostic?.
Location
.SourceTree?.FilePath ?? project.FilePath);
Microsoft.Extensions.Logging.Generators (2)
LoggerMessageGenerator.Roslyn4.0.cs (2)
121
if ((seen ??= new()).Add((diagnostic.Id, diagnostic.
Location
?.SourceSpan, diagnostic.
Location
?.SourceTree?.FilePath, diagnostic.GetMessage())))
Microsoft.Gen.BuildMetadata.Unit.Tests (10)
test\Generators\Shared\RoslynTestUtils.cs (10)
142
Assert.True(expectedSpan.Equals(actual.
Location
.SourceSpan),
143
$"Span {spanNum} doesn't match: expected {expectedSpan} but got {actual.
Location
.SourceSpan}");
157
if (d.
Location
!= Location.None)
169
Assert.True(expectedSpan.Equals(d.
Location
.SourceSpan),
170
$"Span {spanNum} doesn't match: expected {expectedSpan} but got {d.
Location
.SourceSpan}");
418
if (x.
Location
.SourceSpan.Start < y.
Location
.SourceSpan.Start)
422
else if (x.
Location
.SourceSpan.Start > y.
Location
.SourceSpan.Start)
484
var doc = proj.GetDocument(d.
Location
.SourceTree);
Microsoft.Gen.ComplianceReports.Unit.Tests (10)
test\Generators\Shared\RoslynTestUtils.cs (10)
142
Assert.True(expectedSpan.Equals(actual.
Location
.SourceSpan),
143
$"Span {spanNum} doesn't match: expected {expectedSpan} but got {actual.
Location
.SourceSpan}");
157
if (d.
Location
!= Location.None)
169
Assert.True(expectedSpan.Equals(d.
Location
.SourceSpan),
170
$"Span {spanNum} doesn't match: expected {expectedSpan} but got {d.
Location
.SourceSpan}");
418
if (x.
Location
.SourceSpan.Start < y.
Location
.SourceSpan.Start)
422
else if (x.
Location
.SourceSpan.Start > y.
Location
.SourceSpan.Start)
484
var doc = proj.GetDocument(d.
Location
.SourceTree);
Microsoft.Gen.ContextualOptions.Unit.Tests (10)
test\Generators\Shared\RoslynTestUtils.cs (10)
142
Assert.True(expectedSpan.Equals(actual.
Location
.SourceSpan),
143
$"Span {spanNum} doesn't match: expected {expectedSpan} but got {actual.
Location
.SourceSpan}");
157
if (d.
Location
!= Location.None)
169
Assert.True(expectedSpan.Equals(d.
Location
.SourceSpan),
170
$"Span {spanNum} doesn't match: expected {expectedSpan} but got {d.
Location
.SourceSpan}");
418
if (x.
Location
.SourceSpan.Start < y.
Location
.SourceSpan.Start)
422
else if (x.
Location
.SourceSpan.Start > y.
Location
.SourceSpan.Start)
484
var doc = proj.GetDocument(d.
Location
.SourceTree);
Microsoft.Gen.Logging.Unit.Tests (10)
test\Generators\Shared\RoslynTestUtils.cs (10)
142
Assert.True(expectedSpan.Equals(actual.
Location
.SourceSpan),
143
$"Span {spanNum} doesn't match: expected {expectedSpan} but got {actual.
Location
.SourceSpan}");
157
if (d.
Location
!= Location.None)
169
Assert.True(expectedSpan.Equals(d.
Location
.SourceSpan),
170
$"Span {spanNum} doesn't match: expected {expectedSpan} but got {d.
Location
.SourceSpan}");
418
if (x.
Location
.SourceSpan.Start < y.
Location
.SourceSpan.Start)
422
else if (x.
Location
.SourceSpan.Start > y.
Location
.SourceSpan.Start)
484
var doc = proj.GetDocument(d.
Location
.SourceTree);
Microsoft.Gen.MetadataExtractor.Unit.Tests (10)
test\Generators\Shared\RoslynTestUtils.cs (10)
142
Assert.True(expectedSpan.Equals(actual.
Location
.SourceSpan),
143
$"Span {spanNum} doesn't match: expected {expectedSpan} but got {actual.
Location
.SourceSpan}");
157
if (d.
Location
!= Location.None)
169
Assert.True(expectedSpan.Equals(d.
Location
.SourceSpan),
170
$"Span {spanNum} doesn't match: expected {expectedSpan} but got {d.
Location
.SourceSpan}");
418
if (x.
Location
.SourceSpan.Start < y.
Location
.SourceSpan.Start)
422
else if (x.
Location
.SourceSpan.Start > y.
Location
.SourceSpan.Start)
484
var doc = proj.GetDocument(d.
Location
.SourceTree);
Microsoft.Gen.Metrics.Unit.Tests (10)
test\Generators\Shared\RoslynTestUtils.cs (10)
142
Assert.True(expectedSpan.Equals(actual.
Location
.SourceSpan),
143
$"Span {spanNum} doesn't match: expected {expectedSpan} but got {actual.
Location
.SourceSpan}");
157
if (d.
Location
!= Location.None)
169
Assert.True(expectedSpan.Equals(d.
Location
.SourceSpan),
170
$"Span {spanNum} doesn't match: expected {expectedSpan} but got {d.
Location
.SourceSpan}");
418
if (x.
Location
.SourceSpan.Start < y.
Location
.SourceSpan.Start)
422
else if (x.
Location
.SourceSpan.Start > y.
Location
.SourceSpan.Start)
484
var doc = proj.GetDocument(d.
Location
.SourceTree);
Microsoft.Gen.MetricsReports.Unit.Tests (10)
test\Generators\Shared\RoslynTestUtils.cs (10)
142
Assert.True(expectedSpan.Equals(actual.
Location
.SourceSpan),
143
$"Span {spanNum} doesn't match: expected {expectedSpan} but got {actual.
Location
.SourceSpan}");
157
if (d.
Location
!= Location.None)
169
Assert.True(expectedSpan.Equals(d.
Location
.SourceSpan),
170
$"Span {spanNum} doesn't match: expected {expectedSpan} but got {d.
Location
.SourceSpan}");
418
if (x.
Location
.SourceSpan.Start < y.
Location
.SourceSpan.Start)
422
else if (x.
Location
.SourceSpan.Start > y.
Location
.SourceSpan.Start)
484
var doc = proj.GetDocument(d.
Location
.SourceTree);
Microsoft.Interop.ComInterfaceGenerator (3)
src\runtime\src\libraries\System.Runtime.InteropServices\gen\Common\ConvertToSourceGeneratedInteropFixer.cs (3)
195
DocumentId documentId = solutionEditor.OriginalSolution.GetDocumentId(diagnostic.
Location
.SourceTree)!;
196
SyntaxNode root = await diagnostic.
Location
.SourceTree.GetRootAsync(ct).ConfigureAwait(false);
198
SyntaxNode node = root.FindNode(diagnostic.
Location
.SourceSpan);
Microsoft.Interop.LibraryImportGenerator (11)
Analyzers\CustomMarshallerAttributeFixer.cs (5)
36
Document doc = fixAllContext.Solution.GetDocument(diagnostic.
Location
.SourceTree);
39
var entryPointTypeSymbol = (INamedTypeSymbol)model.GetEnclosingSymbol(diagnostic.
Location
.SourceSpan.Start, fixAllContext.CancellationToken);
40
ITypeSymbol? managedType = GetManagedTypeInAttributeSyntax(diagnostic.
Location
, entryPointTypeSymbol);
42
SyntaxNode root = await diagnostic.
Location
.SourceTree.GetRootAsync(fixAllContext.CancellationToken).ConfigureAwait(false);
44
SyntaxNode node = root.FindNode(diagnostic.
Location
.SourceSpan);
Analyzers\ShapeBreakingDiagnosticSuppressor.cs (3)
35
SemanticModel model = context.GetSemanticModel(diagnostic.
Location
.SourceTree);
36
ISymbol diagnosedSymbol = model.GetDeclaredSymbol(diagnostic.
Location
.SourceTree.GetRoot(context.CancellationToken).FindNode(diagnostic.
Location
.SourceSpan), context.CancellationToken);
src\runtime\src\libraries\System.Runtime.InteropServices\gen\Common\ConvertToSourceGeneratedInteropFixer.cs (3)
195
DocumentId documentId = solutionEditor.OriginalSolution.GetDocumentId(diagnostic.
Location
.SourceTree)!;
196
SyntaxNode root = await diagnostic.
Location
.SourceTree.GetRootAsync(ct).ConfigureAwait(false);
198
SyntaxNode node = root.FindNode(diagnostic.
Location
.SourceSpan);
Microsoft.ML.InternalCodeAnalyzer (4)
ContractsCheckNameofFixProvider.cs (1)
41
var diagnosticSpan = diagnostic.
Location
.SourceSpan;
NameFixProvider.cs (1)
60
var token = root.FindToken(diagnostic.
Location
.SourceSpan.Start);
RelaxTestNamingSuppressor.cs (2)
36
if (!(diagnostic.
Location
.SourceTree is { } tree))
42
var node = root.FindNode(diagnostic.
Location
.SourceSpan, getInnermostNodeForTie: true);
Roslyn.Diagnostics.Analyzers (19)
ExportedPartsShouldHaveImportingConstructorCodeFixProvider.cs (3)
50
createChangedDocument = cancellationToken => AddExplicitImportingConstructorAsync(context.Document, diagnostic.
Location
.SourceSpan, cancellationToken);
55
createChangedDocument = cancellationToken => MakeConstructorPublicAsync(context.Document, diagnostic.
Location
.SourceSpan, cancellationToken);
60
createChangedDocument = cancellationToken => AddImportingConstructorAttributeAsync(context.Document, diagnostic.
Location
.SourceSpan, cancellationToken);
ImportingConstructorShouldBeObsoleteCodeFixProvider.cs (5)
47
createChangedDocument = cancellationToken => AddObsoleteAttributeAsync(context.Document, diagnostic.
Location
.SourceSpan, cancellationToken);
52
createChangedDocument = cancellationToken => AddDescriptionAndErrorAsync(context.Document, diagnostic.
Location
.SourceSpan, cancellationToken);
57
createChangedDocument = cancellationToken => UpdateDescriptionAsync(context.Document, diagnostic.
Location
.SourceSpan, cancellationToken);
62
createChangedDocument = cancellationToken => AddErrorAsync(context.Document, diagnostic.
Location
.SourceSpan, cancellationToken);
67
createChangedDocument = cancellationToken => SetErrorToTrueAsync(context.Document, diagnostic.
Location
.SourceSpan, cancellationToken);
NamedTypeFullNameNotNullSuppressor.cs (2)
41
if (diagnostic.
Location
.SourceTree is not { } tree)
47
var node = root.FindNode(diagnostic.
Location
.SourceSpan, getInnermostNodeForTie: true);
PartsExportedWithMEFv2MustBeMarkedAsShared.Fixer.cs (1)
46
if (TryGetDeclaration(root!.FindNode(diagnostic.
Location
.SourceSpan), out var declaration))
RelaxTestNamingSuppressor.cs (2)
44
if (diagnostic.
Location
.SourceTree is not { } tree)
50
var node = root.FindNode(diagnostic.
Location
.SourceSpan, getInnermostNodeForTie: true);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeFixes\FixAllContextHelper.cs (1)
140
foreach (var (textDocument, diagnosticsForDocument) in diagnostics.GroupBy(d => solution.GetTextDocumentForLocation(d.
Location
)))
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeFixes\ForkingSyntaxEditorBasedCodeFixProvider.cs (1)
34
/// computed with respect to the original user document, and as such its <see cref="Diagnostic.
Location
"/> and <see
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeFixes\SyntaxEditorBasedCodeFixProvider.cs (2)
43
.Sort((d1, d2) => d1.
Location
.SourceSpan.Start - d2.
Location
.SourceSpan.Start);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\ProjectExtensions.cs (1)
42
var diagnosticFilePath = PathUtilities.GetDirectoryName(diagnostic?.
Location
.SourceTree?.FilePath ?? project.FilePath);
TestExportsShouldNotBeDiscoverableCodeFixProvider.cs (1)
42
cancellationToken => AddPartNotDiscoverableAttributeAsync(context.Document, diagnostic.
Location
.SourceSpan, cancellationToken),
Roslyn.Diagnostics.CSharp.Analyzers (5)
CSharpAvoidOptSuffixForNullableEnableCodeCodeFixProvider.cs (2)
38
var variable = root.FindNode(diagnostic.
Location
.SourceSpan, getInnermostNodeForTie: true);
54
if (semanticModel.LookupSymbols(diagnostic.
Location
.SourceSpan.Start, variableSymbol.ContainingType, newName).IsEmpty)
CSharpDoNotUseDebugAssertForInterpolatedStringsFixer.cs (1)
50
ct => ReplaceWithDebugAssertAsync(context.Document, diagnostic.
Location
, roslynDebugSymbol, ct),
PreferNullLiteralCodeFixProvider.cs (1)
40
cancellationToken => ReplaceWithNullLiteralAsync(context.Document, diagnostic.
Location
, cancellationToken),
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Helpers\RemoveUnnecessaryImports\CSharpUnnecessaryImportsProvider.cs (1)
36
root.FindNode(diagnostic.
Location
.SourceSpan) is UsingDirectiveSyntax node && predicate(node))
System.Windows.Forms.Analyzers.CodeFixes.CSharp (1)
System\Windows\Forms\CSharp\CodeFixes\AddDesignerSerializationVisibility\AddDesignerSerializationVisibilityCodeFixProvider.cs (1)
39
TextSpan diagnosticSpan = diagnostic.
Location
.SourceSpan;