6 overrides of Location
Microsoft.CodeAnalysis (5)
CommandLine\CommonCompiler.SuppressionDiagnostic.cs (1)
66public override Location Location => _originalDiagnostic.Location;
Diagnostic\Diagnostic.DiagnosticWithProgrammaticSuppression.cs (1)
71public override Location Location
Diagnostic\Diagnostic_SimpleDiagnostic.cs (1)
130public override Location Location
Diagnostic\DiagnosticWithInfo.cs (1)
33public override Location Location
DiagnosticAnalyzer\CompilerDiagnosticAnalyzer.CompilationAnalyzer.cs (1)
97public override Location Location => _original.Location;
Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler (1)
EvaluationContextBase.cs (1)
126public override Location Location
618 references to Location
AnalyzerRunner (3)
DiagnosticAnalyzerRunner.cs (3)
205.ThenBy(tuple => tuple.Item2.Location.SourceTree?.FilePath, StringComparer.OrdinalIgnoreCase) 206.ThenBy(tuple => tuple.Item2.Location.SourceSpan.Start) 207.ThenBy(tuple => tuple.Item2.Location.SourceSpan.End);
ILLink.CodeFixProvider (1)
BaseAttributeCodeFixProvider.cs (1)
42 SyntaxNode targetNode = root.FindNode (diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
Microsoft.Analyzers.Extra.Tests (8)
Resources\RoslynTestUtils.cs (8)
144Assert.True(expectedSpan.Equals(actual.Location.SourceSpan), 145$"Span {spanNum} doesn't match: expected {expectedSpan} but got {actual.Location.SourceSpan}"); 269if (x.Location.SourceSpan.Start < y.Location.SourceSpan.Start) 273else if (x.Location.SourceSpan.Start > y.Location.SourceSpan.Start) 348var doc = proj.GetDocument(d.Location.SourceTree); 530return diagnostics.Where(d => d.Location.SourceTree!.FilePath.EndsWith(document.Name));
Microsoft.Analyzers.Local.Tests (9)
InternalReferencedInPublicDocAnalyzerTests.cs (1)
468var location = detected[i].Location;
Resources\RoslynTestUtils.cs (8)
144Assert.True(expectedSpan.Equals(actual.Location.SourceSpan), 145$"Span {spanNum} doesn't match: expected {expectedSpan} but got {actual.Location.SourceSpan}"); 270if (x.Location.SourceSpan.Start < y.Location.SourceSpan.Start) 274else if (x.Location.SourceSpan.Start > y.Location.SourceSpan.Start) 349var doc = proj.GetDocument(d.Location.SourceTree); 531return diagnostics.Where(d => d.Location.SourceTree!.FilePath.EndsWith(document.Name));
Microsoft.AspNetCore.Analyzer.Testing (8)
DiagnosticAnalyzerRunner.cs (4)
90if (diag.Location == Location.None || diag.Location.IsInMetadata) 99if (tree == diag.Location.SourceTree) 113return diagnostics.OrderBy(d => d.Location.SourceSpan.Start).ToArray();
DiagnosticVerifier.cs (4)
113if (diag.Location == Location.None || diag.Location.IsInMetadata) 122if (tree == diag.Location.SourceTree) 131return diagnostics.OrderBy(d => d.Location.SourceSpan.Start).ToArray();
Microsoft.AspNetCore.App.Analyzers.Test (51)
Components\DisallowNonLiteralSequenceNumbersTest.cs (3)
47AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location); 68AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location); 89AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location);
RouteEmbeddedLanguage\RoutePatternAnalyzerTests.cs (6)
46AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location); 78AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location); 111AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location); 139AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location); 167AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location); 196AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location);
RouteHandlers\DetectMisplacedLambdaAttributeTest.cs (6)
49AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location); 71AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location); 97AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location); 103AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location); 130AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location); 219AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location);
RouteHandlers\DisallowMvcBindArgumentsOnParametersTest.cs (2)
62AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location); 84AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location);
RouteHandlers\DisallowReturningActionResultsFromMapMethodsTest.cs (6)
131AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location); 154AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location); 182AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location); 214AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location); 252AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location); 290AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location);
WebApplicationBuilder\DisallowConfigureHostBuilderConfigureWebHostTest.cs (7)
46AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location); 67AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location); 89AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location); 129AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location); 157AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location); 186AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location); 220AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location);
WebApplicationBuilder\DisallowConfigureHostLoggingTest.cs (1)
274AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location);
WebApplicationBuilder\DisallowConfigureServicesTest.cs (1)
285AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location);
WebApplicationBuilder\DisallowConfigureWebHostBuilderConfigureTest.cs (4)
48AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location); 69AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location); 96AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location); 124AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location);
WebApplicationBuilder\DisallowConfigureWebHostBuilderUseStartupTest.cs (6)
47AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location); 68AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location); 88AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location); 109AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location); 136AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location); 164AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location);
WebApplicationBuilder\UseTopLevelRouteRegistrationInsteadOfUseEndpointsTest.cs (9)
123AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location); 164AnalyzerAssert.DiagnosticLocation(source.MarkerLocations["MM1"], diagnostic1.Location); 168AnalyzerAssert.DiagnosticLocation(source.MarkerLocations["MM2"], diagnostic2.Location); 172AnalyzerAssert.DiagnosticLocation(source.MarkerLocations["MM3"], diagnostic3.Location); 176AnalyzerAssert.DiagnosticLocation(source.MarkerLocations["MM4"], diagnostic4.Location); 208AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location); 234AnalyzerAssert.DiagnosticLocation(source.DefaultMarkerLocation, diagnostic.Location); 264AnalyzerAssert.DiagnosticLocation(source.MarkerLocations["MM1"], diagnostic1.Location); 268AnalyzerAssert.DiagnosticLocation(source.MarkerLocations["MM2"], diagnostic2.Location);
Microsoft.AspNetCore.App.CodeFixes (14)
Authorization\AddAuthorizationBuilderFixer.cs (2)
59var diagnosticTarget = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true); 136var diagnosticTarget = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
Dependencies\AddPackageFixer.cs (2)
49var location = diagnostic.Location.SourceSpan; 83var position = diagnostic.Location.SourceSpan.Start;
DetectMismatchedParameterOptionalityFixer.cs (1)
45var param = root.FindNode(diagnostic.Location.SourceSpan);
Http\HeaderDictionaryAddFixer.cs (4)
70var diagnosticTarget = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true); 87var diagnosticTarget = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true); 101var diagnosticTarget = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true); 115var diagnosticTarget = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
Http\HeaderDictionaryIndexerFixer.cs (1)
51var param = root.FindNode(diagnostic.Location.SourceSpan);
PublicPartialProgramClassFixer.cs (1)
38var classDeclaration = root.FindNode(diagnostic.Location.SourceSpan)
RouteParameterUnusedParameterFixer.cs (1)
60var param = root.FindNode(diagnostic.Location.SourceSpan);
WebApplicationBuilderFixer.cs (2)
79var diagnosticTarget = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true); 94var diagnosticTarget = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
Microsoft.AspNetCore.Components.Analyzers (1)
ComponentParametersShouldBePublicCodeFixProvider.cs (1)
35var diagnosticSpan = diagnostic.Location.SourceSpan;
Microsoft.AspNetCore.Components.Analyzers.Tests (22)
ComponentInternalUsageDiagnosticsAnalyzerTest.cs (11)
35AnalyzerAssert.DiagnosticLocation(source.MarkerLocations["MMBaseClass"], diagnostic.Location); 40AnalyzerAssert.DiagnosticLocation(source.MarkerLocations["MMField"], diagnostic.Location); 45AnalyzerAssert.DiagnosticLocation(source.MarkerLocations["MMInvocation"], diagnostic.Location); 50AnalyzerAssert.DiagnosticLocation(source.MarkerLocations["MMProperty"], diagnostic.Location); 55AnalyzerAssert.DiagnosticLocation(source.MarkerLocations["MMParameter"], diagnostic.Location); 60AnalyzerAssert.DiagnosticLocation(source.MarkerLocations["MMReturnType"], diagnostic.Location); 79AnalyzerAssert.DiagnosticLocation(source.MarkerLocations["MMField"], diagnostic.Location); 84AnalyzerAssert.DiagnosticLocation(source.MarkerLocations["MMNewObject"], diagnostic.Location); 89AnalyzerAssert.DiagnosticLocation(source.MarkerLocations["MMProperty"], diagnostic.Location); 94AnalyzerAssert.DiagnosticLocation(source.MarkerLocations["MMNewObject2"], diagnostic.Location); 99AnalyzerAssert.DiagnosticLocation(source.MarkerLocations["MMInvocation"], diagnostic.Location);
Helpers\CodeFixVerifier.Helper.cs (2)
43var oldArray = diagnostics.OrderBy(d => d.Location.SourceSpan.Start).ToArray(); 44var newArray = newDiagnostics.OrderBy(d => d.Location.SourceSpan.Start).ToArray();
Helpers\DiagnosticVerifier.Helper.cs (4)
66if (diag.Location == Location.None || diag.Location.IsInMetadata) 76if (tree == diag.Location.SourceTree) 97return diagnostics.OrderBy(d => d.Location.SourceSpan.Start).ToArray();
Verifiers\DiagnosticVerifier.cs (5)
126if (actual.Location != Location.None) 135VerifyDiagnosticLocation(analyzer, actual, actual.Location, expected.Locations.First()); 251var location = diagnostics[i].Location; 261string resultMethodName = diagnostics[i].Location.SourceTree.FilePath.EndsWith(".cs", StringComparison.Ordinal) ? "GetCSharpResultAt" : "GetBasicResultAt"; 262var linePosition = diagnostics[i].Location.GetLineSpan().StartLinePosition;
Microsoft.AspNetCore.Components.SdkAnalyzers (1)
ComponentParametersShouldBePublicCodeFixProvider.cs (1)
35var diagnosticSpan = diagnostic.Location.SourceSpan;
Microsoft.AspNetCore.Components.SdkAnalyzers.Tests (22)
ComponentInternalUsageDiagnosticsAnalyzerTest.cs (11)
35AnalyzerAssert.DiagnosticLocation(source.MarkerLocations["MMBaseClass"], diagnostic.Location); 40AnalyzerAssert.DiagnosticLocation(source.MarkerLocations["MMField"], diagnostic.Location); 45AnalyzerAssert.DiagnosticLocation(source.MarkerLocations["MMInvocation"], diagnostic.Location); 50AnalyzerAssert.DiagnosticLocation(source.MarkerLocations["MMProperty"], diagnostic.Location); 55AnalyzerAssert.DiagnosticLocation(source.MarkerLocations["MMParameter"], diagnostic.Location); 60AnalyzerAssert.DiagnosticLocation(source.MarkerLocations["MMReturnType"], diagnostic.Location); 79AnalyzerAssert.DiagnosticLocation(source.MarkerLocations["MMField"], diagnostic.Location); 84AnalyzerAssert.DiagnosticLocation(source.MarkerLocations["MMNewObject"], diagnostic.Location); 89AnalyzerAssert.DiagnosticLocation(source.MarkerLocations["MMProperty"], diagnostic.Location); 94AnalyzerAssert.DiagnosticLocation(source.MarkerLocations["MMNewObject2"], diagnostic.Location); 99AnalyzerAssert.DiagnosticLocation(source.MarkerLocations["MMInvocation"], diagnostic.Location);
Helpers\CodeFixVerifier.Helper.cs (2)
43var oldArray = diagnostics.OrderBy(d => d.Location.SourceSpan.Start).ToArray(); 44var newArray = newDiagnostics.OrderBy(d => d.Location.SourceSpan.Start).ToArray();
Helpers\DiagnosticVerifier.Helper.cs (4)
66if (diag.Location == Location.None || diag.Location.IsInMetadata) 76if (tree == diag.Location.SourceTree) 97return diagnostics.OrderBy(d => d.Location.SourceSpan.Start).ToArray();
Verifiers\DiagnosticVerifier.cs (5)
126if (actual.Location != Location.None) 135VerifyDiagnosticLocation(analyzer, actual, actual.Location, expected.Locations.First()); 251var location = diagnostics[i].Location; 261string resultMethodName = diagnostics[i].Location.SourceTree.FilePath.EndsWith(".cs", StringComparison.Ordinal) ? "GetCSharpResultAt" : "GetBasicResultAt"; 262var linePosition = diagnostics[i].Location.GetLineSpan().StartLinePosition;
Microsoft.AspNetCore.Http.RequestDelegateGenerator (1)
RequestDelegateGeneratorSuppressor.cs (1)
47: diagnostic.Location;
Microsoft.AspNetCore.Mvc.Api.Analyzers (2)
AddResponseTypeAttributeCodeFixAction.cs (2)
41public override string EquivalenceKey => _diagnostic.Location.ToString(); 131var diagnosticNode = root.FindNode(_diagnostic.Location.SourceSpan);
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation (3)
CompilationFailedExceptionFactory.cs (3)
119var mappedLineSpan = diagnostic.Location.GetMappedLineSpan(); 148if (diagnostic.Location == Location.None) 153return diagnostic.Location.GetMappedLineSpan().Path;
Microsoft.CodeAnalysis (41)
CommandLine\CommonCompiler.SuppressionDiagnostic.cs (1)
66public override Location Location => _originalDiagnostic.Location;
CommandLine\SarifV1ErrorLogger.cs (1)
85WriteLocations(diagnostic.Location, diagnostic.AdditionalLocations);
CommandLine\SarifV2ErrorLogger.cs (1)
113WriteLocations(diagnostic.Location, diagnostic.AdditionalLocations);
Diagnostic\CommonDiagnosticComparer.cs (3)
30return x.Location == y.Location && x.Id == y.Id; 40return Hash.Combine(obj.Location, obj.Id.GetHashCode());
Diagnostic\Diagnostic.cs (10)
43/// <param name="location">An optional primary location of the diagnostic. If null, <see cref="Location"/> will return <see cref="Location.None"/>.</param> 58/// <param name="location">An optional primary location of the diagnostic. If null, <see cref="Location"/> will return <see cref="Location.None"/>.</param> 79/// <param name="location">An optional primary location of the diagnostic. If null, <see cref="Location"/> will return <see cref="Location.None"/>.</param> 100/// <param name="location">An optional primary location of the diagnostic. If null, <see cref="Location"/> will return <see cref="Location.None"/>.</param> 127/// <param name="location">An optional primary location of the diagnostic. If null, <see cref="Location"/> will return <see cref="Location.None"/>.</param> 178/// <param name="location">An optional primary location of the diagnostic. If null, <see cref="Location"/> will return <see cref="Location.None"/>.</param> 228/// <param name="location">An optional primary location of the diagnostic. If null, <see cref="Location"/> will return <see cref="Location.None"/>.</param> 438return "Unresolved diagnostic at " + this.Location; 443return "Void diagnostic at " + this.Location; 495if (isLocationWithinSpan(Location, tree, filterSpanWithinTree))
Diagnostic\Diagnostic.DiagnosticWithProgrammaticSuppression.cs (1)
73get { return _originalUnsuppressedDiagnostic.Location; }
Diagnostic\DiagnosticFormatter.cs (3)
32switch (diagnostic.Location.Kind) 37var span = diagnostic.Location.GetLineSpan(); 38var mappedSpan = diagnostic.Location.GetMappedLineSpan();
DiagnosticAnalyzer\AnalysisResultBuilder.cs (2)
303=> diagnostic.Location.SourceTree; 308if (diagnostic.Location is ExternalFileLocation externalFileLocation)
DiagnosticAnalyzer\AnalysisScope.cs (4)
300if (diagnostic.Location.IsInSource) 302if (diagnostic.Location.SourceTree != filterFile.SourceTree) 307else if (diagnostic.Location is ExternalFileLocation externalFileLocation) 316return ShouldInclude(diagnostic.Location.SourceSpan);
DiagnosticAnalyzer\AnalyzerDriver.cs (2)
625return suppressInGeneratedCode && IsInGeneratedCode(diagnostic.Location, compilation, cancellationToken); 2007if (diagnostic?.Location.SourceTree is { } tree &&
DiagnosticAnalyzer\AnalyzerExecutor.AnalyzerDiagnosticReporter.cs (4)
113(!FilterSpanForLocalDiagnostics.HasValue || FilterSpanForLocalDiagnostics.Value.IntersectsWith(diagnostic.Location.SourceSpan))) 126if (diagnostic.Location.IsInSource) 129_contextFile.Value.SourceTree == diagnostic.Location.SourceTree; 133diagnostic.Location is ExternalFileLocation externalFileLocation)
DiagnosticAnalyzer\AnalyzerExecutor.cs (3)
1404if (diagnostic.Location.IsInSource) 1408if (syntaxRef.SyntaxTree == diagnostic.Location.SourceTree) 1411if (diagnostic.Location.SourceSpan.IntersectsWith(syntax.FullSpan))
DiagnosticAnalyzer\CompilerDiagnosticAnalyzer.CompilationAnalyzer.cs (2)
67if (locationFilter(diagnostic.Location) && 97public override Location Location => _original.Location;
DiagnosticAnalyzer\DiagnosticAnalysisContextHelpers.cs (1)
77VerifyDiagnosticLocationInCompilation(diagnostic.Id, diagnostic.Location, compilation);
DiagnosticAnalyzer\DiagnosticQueue.cs (2)
111Debug.Assert(diagnostic.Location.Kind == LocationKind.SourceFile || diagnostic.Location.Kind == LocationKind.ExternalFile);
DiagnosticAnalyzer\SuppressMessageAttributeState.cs (1)
153var location = diagnostic.Location;
Microsoft.CodeAnalysis.CodeStyle (4)
src\Analyzers\Core\Analyzers\RemoveUnnecessarySuppressions\AbstractRemoveUnnecessaryPragmaSuppressionsDiagnosticAnalyzer.cs (4)
497if (diagnostic.Location.SourceTree == tree) 554Debug.Assert(diagnostic.Location.IsInSource); 555Debug.Assert(diagnostic.Location.SourceTree == tree); 565if (pragma.Span.End <= diagnostic.Location.SourceSpan.Start)
Microsoft.CodeAnalysis.CodeStyle.Fixes (46)
src\Analyzers\Core\CodeFixes\AddAnonymousTypeMemberName\AbstractAddAnonymousTypeMemberNameCodeFixProvider.cs (1)
56var span = diagnostic.Location.SourceSpan;
src\Analyzers\Core\CodeFixes\AddExplicitCast\AbstractAddExplicitCastCodeFixProvider.cs (1)
75var spanNode = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true)
src\Analyzers\Core\CodeFixes\AddObsoleteAttribute\AbstractAddObsoleteAttributeCodeFixProvider.cs (2)
46var node = context.Diagnostics[0].Location.FindNode(cancellationToken); 82var containers = diagnostics.Select(d => GetContainer(root, d.Location.FindNode(cancellationToken)))
src\Analyzers\Core\CodeFixes\AddParameter\AbstractAddParameterCodeFixProvider.cs (1)
60var initialNode = root.FindNode(diagnostic.Location.SourceSpan);
src\Analyzers\Core\CodeFixes\ConflictMarkerResolution\AbstractConflictMarkerCodeFixProvider.cs (1)
415var position = diagnostic.Location.SourceSpan.Start;
src\Analyzers\Core\CodeFixes\ConvertTypeOfToNameOf\AbstractConvertTypeOfToNameOfCodeFixProvider.cs (1)
41if (editor.OriginalRoot.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true) is not TMemberAccessExpressionSyntax node)
src\Analyzers\Core\CodeFixes\ForEachCast\AbstractForEachCastCodeFixProvider.cs (1)
51var node = editor.OriginalRoot.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
src\Analyzers\Core\CodeFixes\Formatting\FormattingCodeFixProvider.cs (1)
68var diagnosticSpan = diagnostic.Location.SourceSpan;
src\Analyzers\Core\CodeFixes\GenerateDefaultConstructors\AbstractGenerateDefaultConstructorCodeFixProvider.cs (1)
30if (!headerFacts.IsOnTypeHeader(root, diagnostic.Location.SourceSpan.Start, fullHeader: true, out var typeDecl))
src\Analyzers\Core\CodeFixes\MakeFieldReadonly\AbstractMakeFieldReadonlyCodeFixProvider.cs (1)
48var diagnosticSpan = diagnostic.Location.SourceSpan;
src\Analyzers\Core\CodeFixes\MakeMemberStatic\AbstractMakeMemberStaticCodeFixProvider.cs (2)
24TryGetMemberDeclaration(context.Diagnostics[0].Location.FindNode(context.CancellationToken), out _)) 37var declaration = diagnostics[i].Location.FindNode(cancellationToken);
src\Analyzers\Core\CodeFixes\MakeMethodAsynchronous\AbstractMakeMethodAsynchronousCodeFixProvider.cs (1)
149var token = diagnostic.Location.FindToken(cancellationToken);
src\Analyzers\Core\CodeFixes\MakeMethodSynchronous\AbstractMakeMethodSynchronousCodeFixProvider.cs (1)
34var token = diagnostic.Location.FindToken(cancellationToken);
src\Analyzers\Core\CodeFixes\MakeTypeAbstract\AbstractMakeTypeAbstractCodeFixProvider.cs (2)
24if (IsValidRefactoringContext(context.Diagnostics[0].Location?.FindNode(context.CancellationToken), out _)) 37if (IsValidRefactoringContext(diagnostics[i].Location?.FindNode(cancellationToken), out var typeDeclaration))
src\Analyzers\Core\CodeFixes\MakeTypePartial\AbstractMakeTypePartialCodeFixProvider.cs (1)
37var declaration = syntaxRoot.FindNode(diagnostic.Location.SourceSpan);
src\Analyzers\Core\CodeFixes\MatchFolderAndNamespace\AbstractChangeNamespaceToMatchFolderCodeFixProvider.CustomFixAllProvider.cs (1)
78.GroupBy(diagnostic => diagnostic.Location.SourceTree)
src\Analyzers\Core\CodeFixes\OrderModifiers\AbstractOrderModifiersCodeFixProvider.cs (1)
64var memberDeclaration = diagnostic.Location.FindNode(cancellationToken);
src\Analyzers\Core\CodeFixes\RemoveAsyncModifier\AbstractRemoveAsyncModifierCodeFixProvider.cs (3)
37var token = diagnostic.Location.FindToken(cancellationToken); 75foreach (var diagnostic in diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start)) 77var token = diagnostic.Location.FindToken(cancellationToken);
src\Analyzers\Core\CodeFixes\RemoveUnnecessarySuppressions\RemoveUnnecessaryAttributeSuppressionsCodeFixProvider.cs (2)
33if (root.FindNode(diagnostic.Location.SourceSpan) != null) 44var node = editor.OriginalRoot.FindNode(diagnostic.Location.SourceSpan);
src\Analyzers\Core\CodeFixes\RemoveUnnecessarySuppressions\RemoveUnnecessaryPragmaSuppressionsCodeFixProvider.cs (3)
39if (root.FindNode(diagnostic.Location.SourceSpan) is { } node && syntaxFacts.IsAttribute(node) || 40root.FindTrivia(diagnostic.Location.SourceSpan.Start).HasStructure) 58RemoveNode(diagnostic.Location, editor, processedNodes, syntaxFacts);
src\Analyzers\Core\CodeFixes\RemoveUnusedMembers\AbstractRemoveUnusedMembersCodeFixProvider.cs (1)
57var diagnosticNode = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\Analyzers\Core\CodeFixes\RemoveUnusedParametersAndValues\AbstractRemoveUnusedValuesCodeFixProvider.cs (6)
209return syntaxFacts.IsForEachStatement(diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken)); 270return diagnostics.GroupBy(d => syntaxFacts.GetContainingMemberDeclaration(root, d.Location.SourceSpan.Start) ?? root); 363diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start), 373diagnostics.OrderBy(d => d.Location.SourceSpan.Start), 402var expressionStatement = root.FindNode(diagnostic.Location.SourceSpan).FirstAncestorOrSelf<TExpressionStatementSyntax>(); 678var node = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
src\Analyzers\Core\CodeFixes\SimplifyBooleanExpression\SimplifyConditionalCodeFixProvider.cs (2)
53diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start).ToImmutableArray(), 54d => d.Location.FindNode(getInnermostNodeForTie: true, cancellationToken),
src\Analyzers\Core\CodeFixes\SimplifyLinqExpression\AbstractSimplifyLinqExpressionCodeFixProvider`3.cs (1)
57return (TInvocationExpressionSyntax)root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
src\Analyzers\Core\CodeFixes\UpdateLegacySuppressions\UpdateLegacySuppressionsCodeFixProvider.cs (2)
34root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true) != null) 45var node = editor.OriginalRoot.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
src\Analyzers\Core\CodeFixes\UseExplicitTupleName\UseExplicitTupleNameCodeFixProvider.cs (1)
42var oldNameNode = diagnostic.Location.FindNode(
src\Analyzers\Core\CodeFixes\UseInferredMemberName\AbstractUseInferredMemberNameCodeFixProvider.cs (1)
39var node = root.FindNode(diagnostic.Location.SourceSpan);
src\Analyzers\Core\CodeFixes\UseIsNullCheck\AbstractUseIsNullForReferenceEqualsCodeFixProvider.cs (2)
41var title = GetTitle(negated, diagnostic.Location.SourceTree!.Options); 59foreach (var diagnostic in diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start))
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeFixes\ForkingSyntaxEditorBasedCodeFixProvider.cs (1)
36/// computed with respect to the original user document, and as such its <see cref="Diagnostic.Location"/> and <see
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\ProjectExtensions.cs (1)
58var diagnosticFilePath = PathUtilities.GetDirectoryName(diagnostic?.Location.SourceTree?.FilePath ?? project.FilePath);
Microsoft.CodeAnalysis.CSharp (5)
CommandLine\CSharpCompiler.cs (1)
404diag.Location));
Compilation\CSharpDiagnosticFilter.cs (2)
84d.Location, 101d.Location,
FlowAnalysis\DefiniteAssignment.cs (1)
674Hash.Combine(Hash.CombineValues(obj.Arguments), Hash.Combine(obj.Location.GetHashCode(), obj.Code));
Symbols\Symbol_Attributes.cs (1)
493Location location = withInfo.Location;
Microsoft.CodeAnalysis.CSharp.CodeStyle (2)
src\Analyzers\CSharp\Analyzers\RemoveUnreachableCode\CSharpRemoveUnreachableCodeDiagnosticAnalyzer.cs (1)
67ProcessUnreachableDiagnostic(context, root, diagnostic.Location.SourceSpan);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Helpers\RemoveUnnecessaryImports\CSharpUnnecessaryImportsProvider.cs (1)
36root.FindNode(diagnostic.Location.SourceSpan) is UsingDirectiveSyntax node && predicate(node))
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (48)
src\Analyzers\CSharp\CodeFixes\AddBraces\CSharpAddBracesCodeFixProvider.cs (1)
38var statement = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
src\Analyzers\CSharp\CodeFixes\AddInheritdoc\AddInheritdocCodeFixProvider.cs (2)
49var node = root.FindNode(diagnostic.Location.SourceSpan); 85var node = editor.OriginalRoot.FindNode(diagnostic.Location.SourceSpan);
src\Analyzers\CSharp\CodeFixes\ConditionalExpressionInStringInterpolation\CSharpAddParenthesesAroundConditionalExpressionInInterpolatedStringCodeFixProvider.cs (1)
39var diagnosticSpan = diagnostic.Location.SourceSpan;
src\Analyzers\CSharp\CodeFixes\DisambiguateSameVariable\CSharpDisambiguateSameVariableCodeFixProvider.cs (2)
60var span = diagnostic.Location.SourceSpan; 61var node = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\Analyzers\CSharp\CodeFixes\FixIncorrectConstraint\CSharpFixIncorrectConstraintCodeFixProvider.cs (1)
37constraint = diagnostic.Location.FindNode(cancellationToken) as TypeConstraintSyntax;
src\Analyzers\CSharp\CodeFixes\FixReturnType\CSharpFixReturnTypeCodeFixProvider.cs (1)
65var location = diagnostics[0].Location;
src\Analyzers\CSharp\CodeFixes\HideBase\HideBaseCodeFixProvider.cs (1)
33var diagnosticSpan = diagnostic.Location.SourceSpan;
src\Analyzers\CSharp\CodeFixes\MakeAnonymousFunctionStatic\CSharpMakeAnonymousFunctionStaticCodeFixProvider.cs (1)
44var anonymousFunction = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\Analyzers\CSharp\CodeFixes\MakeLocalFunctionStatic\PassInCapturedVariablesAsArgumentsCodeFixProvider.cs (1)
77.Select(d => root.FindNode(d.Location.SourceSpan).AncestorsAndSelf().OfType<LocalFunctionStatementSyntax>().FirstOrDefault())
src\Analyzers\CSharp\CodeFixes\MakeMemberRequired\CSharpMakeMemberRequiredCodeFixProvider.cs (1)
115var memberDeclarator = root.FindNode(diagnostic.Location.SourceSpan);
src\Analyzers\CSharp\CodeFixes\MakeMethodAsynchronous\CSharpMakeMethodAsynchronousCodeFixProvider.cs (3)
44if (diagnostic.Location.SourceTree is null) 47var root = diagnostic.Location.SourceTree.GetRoot(cancellationToken); 48var token = root.FindToken(diagnostic.Location.SourceSpan.Start);
src\Analyzers\CSharp\CodeFixes\MakeStatementAsynchronous\CSharpMakeStatementAsynchronousCodeFixProvider.cs (2)
36var node = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true); 53var node = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\Analyzers\CSharp\CodeFixes\MakeStructFieldsWritable\CSharpMakeStructFieldsWritableCodeFixProvider.cs (1)
42var diagnosticNode = diagnostic.Location.FindNode(cancellationToken);
src\Analyzers\CSharp\CodeFixes\NewLines\ArrowExpressionClausePlacement\ArrowExpressionClausePlacementCodeFixProvider.cs (1)
53var arrowToken = root.FindToken(diagnostic.Location.SourceSpan.Start);
src\Analyzers\CSharp\CodeFixes\NewLines\ConditionalExpressionPlacement\ConditionalExpressionPlacementCodeFixProvider.cs (1)
53var questionToken = root.FindToken(diagnostic.Location.SourceSpan.Start);
src\Analyzers\CSharp\CodeFixes\NewLines\ConsecutiveBracePlacement\ConsecutiveBracePlacementCodeFixProvider.cs (1)
68var token = root.FindToken(diagnostic.Location.SourceSpan.Start);
src\Analyzers\CSharp\CodeFixes\Nullable\CSharpDeclareAsNullableCodeFixProvider.cs (3)
47var node = context.Diagnostics.First().Location.FindNode(getInnermostNodeForTie: true, cancellationToken); 87var node = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken); 95var node = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\Analyzers\CSharp\CodeFixes\QualifyMemberAccess\CSharpQualifyMemberAccessCodeFixProvider.cs (1)
23var node = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\Analyzers\CSharp\CodeFixes\RemoveInKeyword\RemoveInKeywordCodeFixProvider.cs (1)
38var diagnosticSpan = diagnostic.Location.SourceSpan;
src\Analyzers\CSharp\CodeFixes\RemoveNewModifier\RemoveNewModifierCodeFixProvider.cs (1)
36var diagnosticSpan = diagnostic.Location.SourceSpan;
src\Analyzers\CSharp\CodeFixes\RemoveUnnecessaryDiscardDesignation\CSharpRemoveUnnecessaryDiscardDesignationCodeFixProvider.cs (1)
42var discard = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\Analyzers\CSharp\CodeFixes\RemoveUnnecessaryNullableDirective\CSharpRemoveUnnecessaryNullableDirectiveCodeFixProvider.cs (1)
58.Select(d => d.Location.FindNode(findInsideTrivia: true, getInnermostNodeForTie: true, cancellationToken))
src\Analyzers\CSharp\CodeFixes\TransposeRecordKeyword\CSharpTransposeRecordKeywordCodeFixProvider.cs (1)
32recordDeclaration = diagnostic.Location.FindNode(cancellationToken) as RecordDeclarationSyntax;
src\Analyzers\CSharp\CodeFixes\UseImplicitObjectCreation\CSharpUseImplicitObjectCreationCodeFixProvider.cs (1)
50.OrderBy(d => d.Location.SourceSpan.End)
src\Analyzers\CSharp\CodeFixes\UseImplicitOrExplicitType\UseExplicitTypeCodeFixProvider.cs (1)
48var node = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
src\Analyzers\CSharp\CodeFixes\UseImplicitOrExplicitType\UseImplicitTypeCodeFixProvider.cs (1)
40var typeSyntax = (TypeSyntax)root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
src\Analyzers\CSharp\CodeFixes\UseIndexOrRangeOperator\CSharpUseIndexOperatorCodeFixProvider.cs (2)
40foreach (var diagnostic in diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start)) 42var node = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\Analyzers\CSharp\CodeFixes\UseInterpolatedVerbatimString\CSharpUseInterpolatedVerbatimStringCodeFixProvider.cs (1)
53var verbatimInterpolatedLocation = diagnostic.Location;
src\Analyzers\CSharp\CodeFixes\UseIsNullCheck\CSharpUseIsNullCheckForCastAndEqualityOperatorCodeFixProvider.cs (2)
43var title = GetTitle(negated, diagnostic.Location.SourceTree!.Options); 62var binary = (BinaryExpressionSyntax)diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken: cancellationToken);
src\Analyzers\CSharp\CodeFixes\UseIsNullCheck\CSharpUseNullCheckOverTypeCheckCodeFixProvider.cs (1)
44var node = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken: cancellationToken);
src\Analyzers\CSharp\CodeFixes\UseNameofInAttribute\CSharpUseNameofInAttributeCodeFixProvider.cs (1)
44var expression = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\Analyzers\CSharp\CodeFixes\UsePatternCombinators\CSharpUsePatternCombinatorsCodeFixProvider.cs (1)
79var location = diagnostic.Location;
src\Analyzers\CSharp\CodeFixes\UsePatternMatching\CSharpAsAndMemberAccessCodeFixProvider.cs (2)
43foreach (var diagnostic in diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start)) 51var node = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\Analyzers\CSharp\CodeFixes\UsePrimaryConstructor\CSharpUsePrimaryConstructorCodeFixProvider.cs (1)
56if (diagnostic.Location.FindNode(cancellationToken) is not ConstructorDeclarationSyntax constructorDeclaration)
src\Analyzers\CSharp\CodeFixes\UseSystemThreadingLock\CSharpUseSystemThreadingLockCodeFixProvider.cs (1)
47if (diagnostic.Location.FindNode(cancellationToken) is not VariableDeclaratorSyntax variableDeclarator)
src\Analyzers\CSharp\CodeFixes\UseUtf8StringLiteral\UseUtf8StringLiteralCodeFixProvider.cs (3)
56var node = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken); 82editor.ReplaceNode(node, CreateArgumentListWithUtf8String(argumentList, diagnostic.Location, stringValue, isConvertedToReadOnlySpan)); 120.Where(a => a.Initializer?.ElementValues.FirstOrDefault()?.Syntax.SpanStart == diagnostic.Location.SourceSpan.Start)
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (2)
Formatting\CodeCleanupTests.TestFixers.cs (2)
34var sourceTree = diagnostic.Location.SourceTree; 36var node = (await sourceTree.GetRootAsync(cancellationToken)).FindNode(diagnostic.Location.SourceSpan);
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (8)
Diagnostics\DiagnosticAnalyzerTests.cs (3)
3720Assert.Equal(field1.GetLocation(), diagnostic.Location); 3904Assert.Equal(LocationKind.ExternalFile, diagnostic.Location.Kind); 3905var location = (ExternalFileLocation)diagnostic.Location;
Diagnostics\GetDiagnosticsTests.cs (5)
447Assert.True(diagnostics[0].Location.SourceTree.Equals(syntaxTree1)); 448Assert.True(diagnostics[1].Location.SourceTree.Equals(syntaxTree2)); 449Assert.True(diagnostics[2].Location.SourceTree.Equals(syntaxTree3)); 473Assert.True(diagnostics[0].Location.SourceTree.Equals(syntaxTree1)); 474Assert.True(diagnostics[1].Location.SourceTree.Equals(syntaxTree2));
Microsoft.CodeAnalysis.CSharp.Features (52)
Copilot\CSharpCopilotCodeFixProvider.cs (1)
81var containingMethod = CSharpSyntaxFacts.Instance.GetContainingMethodDeclaration(root, diagnostic.Location.SourceSpan.Start, useFullSpan: false);
src\Analyzers\CSharp\Analyzers\RemoveUnreachableCode\CSharpRemoveUnreachableCodeDiagnosticAnalyzer.cs (1)
67ProcessUnreachableDiagnostic(context, root, diagnostic.Location.SourceSpan);
src\Analyzers\CSharp\CodeFixes\AddBraces\CSharpAddBracesCodeFixProvider.cs (1)
38var statement = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
src\Analyzers\CSharp\CodeFixes\AddInheritdoc\AddInheritdocCodeFixProvider.cs (2)
49var node = root.FindNode(diagnostic.Location.SourceSpan); 85var node = editor.OriginalRoot.FindNode(diagnostic.Location.SourceSpan);
src\Analyzers\CSharp\CodeFixes\ConditionalExpressionInStringInterpolation\CSharpAddParenthesesAroundConditionalExpressionInInterpolatedStringCodeFixProvider.cs (1)
39var diagnosticSpan = diagnostic.Location.SourceSpan;
src\Analyzers\CSharp\CodeFixes\DisambiguateSameVariable\CSharpDisambiguateSameVariableCodeFixProvider.cs (2)
60var span = diagnostic.Location.SourceSpan; 61var node = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\Analyzers\CSharp\CodeFixes\FixIncorrectConstraint\CSharpFixIncorrectConstraintCodeFixProvider.cs (1)
37constraint = diagnostic.Location.FindNode(cancellationToken) as TypeConstraintSyntax;
src\Analyzers\CSharp\CodeFixes\FixReturnType\CSharpFixReturnTypeCodeFixProvider.cs (1)
65var location = diagnostics[0].Location;
src\Analyzers\CSharp\CodeFixes\HideBase\HideBaseCodeFixProvider.cs (1)
33var diagnosticSpan = diagnostic.Location.SourceSpan;
src\Analyzers\CSharp\CodeFixes\MakeAnonymousFunctionStatic\CSharpMakeAnonymousFunctionStaticCodeFixProvider.cs (1)
44var anonymousFunction = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\Analyzers\CSharp\CodeFixes\MakeLocalFunctionStatic\PassInCapturedVariablesAsArgumentsCodeFixProvider.cs (1)
77.Select(d => root.FindNode(d.Location.SourceSpan).AncestorsAndSelf().OfType<LocalFunctionStatementSyntax>().FirstOrDefault())
src\Analyzers\CSharp\CodeFixes\MakeMemberRequired\CSharpMakeMemberRequiredCodeFixProvider.cs (1)
115var memberDeclarator = root.FindNode(diagnostic.Location.SourceSpan);
src\Analyzers\CSharp\CodeFixes\MakeMethodAsynchronous\CSharpMakeMethodAsynchronousCodeFixProvider.cs (3)
44if (diagnostic.Location.SourceTree is null) 47var root = diagnostic.Location.SourceTree.GetRoot(cancellationToken); 48var token = root.FindToken(diagnostic.Location.SourceSpan.Start);
src\Analyzers\CSharp\CodeFixes\MakeStatementAsynchronous\CSharpMakeStatementAsynchronousCodeFixProvider.cs (2)
36var node = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true); 53var node = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\Analyzers\CSharp\CodeFixes\MakeStructFieldsWritable\CSharpMakeStructFieldsWritableCodeFixProvider.cs (1)
42var diagnosticNode = diagnostic.Location.FindNode(cancellationToken);
src\Analyzers\CSharp\CodeFixes\NewLines\ArrowExpressionClausePlacement\ArrowExpressionClausePlacementCodeFixProvider.cs (1)
53var arrowToken = root.FindToken(diagnostic.Location.SourceSpan.Start);
src\Analyzers\CSharp\CodeFixes\NewLines\ConditionalExpressionPlacement\ConditionalExpressionPlacementCodeFixProvider.cs (1)
53var questionToken = root.FindToken(diagnostic.Location.SourceSpan.Start);
src\Analyzers\CSharp\CodeFixes\NewLines\ConsecutiveBracePlacement\ConsecutiveBracePlacementCodeFixProvider.cs (1)
68var token = root.FindToken(diagnostic.Location.SourceSpan.Start);
src\Analyzers\CSharp\CodeFixes\Nullable\CSharpDeclareAsNullableCodeFixProvider.cs (3)
47var node = context.Diagnostics.First().Location.FindNode(getInnermostNodeForTie: true, cancellationToken); 87var node = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken); 95var node = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\Analyzers\CSharp\CodeFixes\QualifyMemberAccess\CSharpQualifyMemberAccessCodeFixProvider.cs (1)
23var node = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\Analyzers\CSharp\CodeFixes\RemoveInKeyword\RemoveInKeywordCodeFixProvider.cs (1)
38var diagnosticSpan = diagnostic.Location.SourceSpan;
src\Analyzers\CSharp\CodeFixes\RemoveNewModifier\RemoveNewModifierCodeFixProvider.cs (1)
36var diagnosticSpan = diagnostic.Location.SourceSpan;
src\Analyzers\CSharp\CodeFixes\RemoveUnnecessaryDiscardDesignation\CSharpRemoveUnnecessaryDiscardDesignationCodeFixProvider.cs (1)
42var discard = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\Analyzers\CSharp\CodeFixes\RemoveUnnecessaryNullableDirective\CSharpRemoveUnnecessaryNullableDirectiveCodeFixProvider.cs (1)
58.Select(d => d.Location.FindNode(findInsideTrivia: true, getInnermostNodeForTie: true, cancellationToken))
src\Analyzers\CSharp\CodeFixes\TransposeRecordKeyword\CSharpTransposeRecordKeywordCodeFixProvider.cs (1)
32recordDeclaration = diagnostic.Location.FindNode(cancellationToken) as RecordDeclarationSyntax;
src\Analyzers\CSharp\CodeFixes\UseImplicitObjectCreation\CSharpUseImplicitObjectCreationCodeFixProvider.cs (1)
50.OrderBy(d => d.Location.SourceSpan.End)
src\Analyzers\CSharp\CodeFixes\UseImplicitOrExplicitType\UseExplicitTypeCodeFixProvider.cs (1)
48var node = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
src\Analyzers\CSharp\CodeFixes\UseImplicitOrExplicitType\UseImplicitTypeCodeFixProvider.cs (1)
40var typeSyntax = (TypeSyntax)root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
src\Analyzers\CSharp\CodeFixes\UseIndexOrRangeOperator\CSharpUseIndexOperatorCodeFixProvider.cs (2)
40foreach (var diagnostic in diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start)) 42var node = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\Analyzers\CSharp\CodeFixes\UseInterpolatedVerbatimString\CSharpUseInterpolatedVerbatimStringCodeFixProvider.cs (1)
53var verbatimInterpolatedLocation = diagnostic.Location;
src\Analyzers\CSharp\CodeFixes\UseIsNullCheck\CSharpUseIsNullCheckForCastAndEqualityOperatorCodeFixProvider.cs (2)
43var title = GetTitle(negated, diagnostic.Location.SourceTree!.Options); 62var binary = (BinaryExpressionSyntax)diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken: cancellationToken);
src\Analyzers\CSharp\CodeFixes\UseIsNullCheck\CSharpUseNullCheckOverTypeCheckCodeFixProvider.cs (1)
44var node = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken: cancellationToken);
src\Analyzers\CSharp\CodeFixes\UseNameofInAttribute\CSharpUseNameofInAttributeCodeFixProvider.cs (1)
44var expression = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\Analyzers\CSharp\CodeFixes\UsePatternCombinators\CSharpUsePatternCombinatorsCodeFixProvider.cs (1)
79var location = diagnostic.Location;
src\Analyzers\CSharp\CodeFixes\UsePatternMatching\CSharpAsAndMemberAccessCodeFixProvider.cs (2)
43foreach (var diagnostic in diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start)) 51var node = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\Analyzers\CSharp\CodeFixes\UsePrimaryConstructor\CSharpUsePrimaryConstructorCodeFixProvider.cs (1)
56if (diagnostic.Location.FindNode(cancellationToken) is not ConstructorDeclarationSyntax constructorDeclaration)
src\Analyzers\CSharp\CodeFixes\UseSystemThreadingLock\CSharpUseSystemThreadingLockCodeFixProvider.cs (1)
47if (diagnostic.Location.FindNode(cancellationToken) is not VariableDeclaratorSyntax variableDeclarator)
src\Analyzers\CSharp\CodeFixes\UseUtf8StringLiteral\UseUtf8StringLiteralCodeFixProvider.cs (3)
56var node = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken); 82editor.ReplaceNode(node, CreateArgumentListWithUtf8String(argumentList, diagnostic.Location, stringValue, isConvertedToReadOnlySpan)); 120.Where(a => a.Initializer?.ElementValues.FirstOrDefault()?.Syntax.SpanStart == diagnostic.Location.SourceSpan.Start)
StringIndentation\CSharpStringIndentationService.cs (1)
102if (!IsInHole(interpolatedString, error.Location.SourceSpan))
UsePatternMatching\CSharpIsAndCastCheckWithoutNameCodeFixProvider.cs (1)
52var location = diagnostics[0].Location;
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (1)
SourceGeneration\GeneratorDriverTests.cs (1)
4134Assert.Equal(NoLocation.Singleton, diagnostic.Location);
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (25)
Diagnostics\DiagnosticTest.cs (5)
85Assert.Equal(l1, d1.Location); 86Assert.Same(syntaxTree, d1.Location.SourceTree); 87Assert.Equal(new TextSpan(5, 8), d1.Location.SourceSpan); 100Assert.Same(syntaxTree, d3.Location.SourceTree); 101Assert.Equal(new TextSpan(1, 1), d3.Location.SourceSpan);
Diagnostics\LocationsTests.cs (18)
314FileLinePositionSpan flps = diag.Location.GetLineSpan(); 332flps = diag.Location.GetLineSpan(); 352flps = diag.Location.GetLineSpan(); 377FileLinePositionSpan flps = diag.Location.GetLineSpan(); 400Assert.InRange(diag.Location.SourceSpan.End, diag.Location.SourceSpan.Start, syntaxTree.GetText().Length); 418var span = syntaxTree.GetDiagnostics().ElementAt(3).Location.GetLineSpan(); 460expressionDiags.First().Location.GetLineSpan(); 465Assert.InRange(diag.Location.SourceSpan.Start, 0, syntaxTree.GetText().Length); 466Assert.InRange(diag.Location.SourceSpan.End, 0, syntaxTree.GetText().Length); 567Assert.Equal(5, diagnostics[0].Location.SourceSpan.Start); 568Assert.Equal(0, diagnostics[0].Location.SourceSpan.Length); 570Assert.True(treeSpan.Contains(diagnostics[0].Location.SourceSpan)); 572var lineSpan = diagnostics[0].Location.GetLineSpan(); 595Assert.Equal(0, diagnostics[0].Location.SourceSpan.Start); 596Assert.Equal(0, diagnostics[0].Location.SourceSpan.Length); 598Assert.True(treeSpan.Contains(diagnostics[0].Location.SourceSpan)); 600var lineSpan = diagnostics[0].Location.GetLineSpan();
LexicalAndXml\PreprocessorTests.cs (1)
3560var lineSpan = diagnostics.First().Location.GetMappedLineSpan();
LexicalAndXml\RawStringLiteralLexingTests.cs (1)
224var actualDiagnosticsSpans = diagnostics.Select(d => d.Location.SourceSpan).OrderBy(d => d.Start);
Microsoft.CodeAnalysis.CSharp.Test.Utilities (1)
DiagnosticTestUtilities.cs (1)
115let lineSpan = e.Location.GetMappedLineSpan()
Microsoft.CodeAnalysis.CSharp.Workspaces (2)
Simplification\CSharpSimplificationService.cs (1)
194if (root.FindNode(diagnostic.Location.SourceSpan) is UsingDirectiveSyntax node)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Helpers\RemoveUnnecessaryImports\CSharpUnnecessaryImportsProvider.cs (1)
36root.FindNode(diagnostic.Location.SourceSpan) is UsingDirectiveSyntax node && predicate(node))
Microsoft.CodeAnalysis.ExternalAccess.Copilot (1)
Internal\Analyzer\CSharp\CSharpCopilotCodeAnalysisService.cs (1)
75var containingMethod = syntaxFacts.GetContainingMethodDeclaration(root, diagnostic.Location.SourceSpan.Start, useFullSpan: false);
Microsoft.CodeAnalysis.Features (77)
CodeFixes\Configuration\ConfigurationUpdater.cs (1)
431var diagnosticSourceTree = _diagnostic?.Location.SourceTree;
CodeFixes\Configuration\ConfigureCodeStyle\ConfigureCodeStyleOptionCodeFixProvider.cs (2)
44diagnostic.Location.SourceTree == null) 49var language = diagnostic.Location.SourceTree.Options.Language;
CodeFixes\Suppression\AbstractSuppressionBatchFixAllProvider.cs (1)
281tuple => tuple.action, tuple => tuple.diagnostic?.Location.SourceSpan.Start ?? 0);
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.cs (1)
212if (diagnostic.Location.IsInSource && documentOpt != null)
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.GlobalSuppressMessageFixAllCodeAction.cs (3)
159Contract.ThrowIfFalse(diagnostic.Location.IsInSource); 160var suppressionTargetInfo = await fixer.GetSuppressionTargetInfoAsync(document, diagnostic.Location.SourceSpan, cancellationToken).ConfigureAwait(false); 181Contract.ThrowIfFalse(!diagnostic.Location.IsInSource);
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.PragmaBatchFixHelpers.cs (1)
53currentDiagnosticSpans.Add(diagnostic, diagnostic.Location.SourceSpan);
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.PragmaWarningBatchFixAllProvider.cs (2)
34foreach (var diagnostic in diagnostics.Where(d => d.Location.IsInSource && !d.IsSuppressed)) 36var span = diagnostic.Location.SourceSpan;
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.PragmaWarningCodeAction.cs (1)
66_diagnostic.Location.SourceSpan,
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.RemoveSuppressionCodeAction.BatchFixer.cs (3)
43foreach (var diagnostic in diagnostics.Where(d => d.Location.IsInSource && d.IsSuppressed)) 45var span = diagnostic.Location.SourceSpan; 89foreach (var diagnostic in diagnostics.Where(d => !d.Location.IsInSource && d.IsSuppressed))
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.RemoveSuppressionCodeAction_Pragma.cs (2)
97_diagnostic.Location.SourceSpan, 124var diagnosticSpan = diagnostic.Location.SourceSpan;
EditAndContinue\ProjectDiagnostics.cs (1)
26var document = solution.GetDocument(diagnostic.Location.SourceTree);
EmbeddedLanguages\Json\LanguageServices\AbstractJsonDetectionCodeFixProvider.cs (1)
48var stringLiteral = diagnostic.Location.FindToken(cancellationToken);
PreferFrameworkType\PreferFrameworkTypeCodeFixProvider.cs (1)
55var node = diagnostic.Location.FindNode(
RemoveUnusedVariable\AbstractRemoveUnusedVariableCodeFixProvider.cs (3)
45var node = root.FindNode(diagnostic.Location.SourceSpan); 73var token = diagnostic.Location.FindToken(cancellationToken); 74var node = root.FindNode(diagnostic.Location.SourceSpan);
SimplifyTypeNames\AbstractSimplifyTypeNamesCodeFixProvider.cs (1)
112root, model, diagnostic.Location.SourceSpan,
src\Analyzers\Core\Analyzers\RemoveUnnecessarySuppressions\AbstractRemoveUnnecessaryPragmaSuppressionsDiagnosticAnalyzer.cs (4)
497if (diagnostic.Location.SourceTree == tree) 554Debug.Assert(diagnostic.Location.IsInSource); 555Debug.Assert(diagnostic.Location.SourceTree == tree); 565if (pragma.Span.End <= diagnostic.Location.SourceSpan.Start)
src\Analyzers\Core\CodeFixes\AddAnonymousTypeMemberName\AbstractAddAnonymousTypeMemberNameCodeFixProvider.cs (1)
56var span = diagnostic.Location.SourceSpan;
src\Analyzers\Core\CodeFixes\AddExplicitCast\AbstractAddExplicitCastCodeFixProvider.cs (1)
75var spanNode = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true)
src\Analyzers\Core\CodeFixes\AddObsoleteAttribute\AbstractAddObsoleteAttributeCodeFixProvider.cs (2)
46var node = context.Diagnostics[0].Location.FindNode(cancellationToken); 82var containers = diagnostics.Select(d => GetContainer(root, d.Location.FindNode(cancellationToken)))
src\Analyzers\Core\CodeFixes\AddParameter\AbstractAddParameterCodeFixProvider.cs (1)
60var initialNode = root.FindNode(diagnostic.Location.SourceSpan);
src\Analyzers\Core\CodeFixes\ConflictMarkerResolution\AbstractConflictMarkerCodeFixProvider.cs (1)
415var position = diagnostic.Location.SourceSpan.Start;
src\Analyzers\Core\CodeFixes\ConvertTypeOfToNameOf\AbstractConvertTypeOfToNameOfCodeFixProvider.cs (1)
41if (editor.OriginalRoot.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true) is not TMemberAccessExpressionSyntax node)
src\Analyzers\Core\CodeFixes\ForEachCast\AbstractForEachCastCodeFixProvider.cs (1)
51var node = editor.OriginalRoot.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
src\Analyzers\Core\CodeFixes\Formatting\FormattingCodeFixProvider.cs (1)
68var diagnosticSpan = diagnostic.Location.SourceSpan;
src\Analyzers\Core\CodeFixes\GenerateDefaultConstructors\AbstractGenerateDefaultConstructorCodeFixProvider.cs (1)
30if (!headerFacts.IsOnTypeHeader(root, diagnostic.Location.SourceSpan.Start, fullHeader: true, out var typeDecl))
src\Analyzers\Core\CodeFixes\MakeFieldReadonly\AbstractMakeFieldReadonlyCodeFixProvider.cs (1)
48var diagnosticSpan = diagnostic.Location.SourceSpan;
src\Analyzers\Core\CodeFixes\MakeMemberStatic\AbstractMakeMemberStaticCodeFixProvider.cs (2)
24TryGetMemberDeclaration(context.Diagnostics[0].Location.FindNode(context.CancellationToken), out _)) 37var declaration = diagnostics[i].Location.FindNode(cancellationToken);
src\Analyzers\Core\CodeFixes\MakeMethodAsynchronous\AbstractMakeMethodAsynchronousCodeFixProvider.cs (1)
149var token = diagnostic.Location.FindToken(cancellationToken);
src\Analyzers\Core\CodeFixes\MakeMethodSynchronous\AbstractMakeMethodSynchronousCodeFixProvider.cs (1)
34var token = diagnostic.Location.FindToken(cancellationToken);
src\Analyzers\Core\CodeFixes\MakeTypeAbstract\AbstractMakeTypeAbstractCodeFixProvider.cs (2)
24if (IsValidRefactoringContext(context.Diagnostics[0].Location?.FindNode(context.CancellationToken), out _)) 37if (IsValidRefactoringContext(diagnostics[i].Location?.FindNode(cancellationToken), out var typeDeclaration))
src\Analyzers\Core\CodeFixes\MakeTypePartial\AbstractMakeTypePartialCodeFixProvider.cs (1)
37var declaration = syntaxRoot.FindNode(diagnostic.Location.SourceSpan);
src\Analyzers\Core\CodeFixes\MatchFolderAndNamespace\AbstractChangeNamespaceToMatchFolderCodeFixProvider.CustomFixAllProvider.cs (1)
78.GroupBy(diagnostic => diagnostic.Location.SourceTree)
src\Analyzers\Core\CodeFixes\OrderModifiers\AbstractOrderModifiersCodeFixProvider.cs (1)
64var memberDeclaration = diagnostic.Location.FindNode(cancellationToken);
src\Analyzers\Core\CodeFixes\RemoveAsyncModifier\AbstractRemoveAsyncModifierCodeFixProvider.cs (3)
37var token = diagnostic.Location.FindToken(cancellationToken); 75foreach (var diagnostic in diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start)) 77var token = diagnostic.Location.FindToken(cancellationToken);
src\Analyzers\Core\CodeFixes\RemoveUnnecessarySuppressions\RemoveUnnecessaryAttributeSuppressionsCodeFixProvider.cs (2)
33if (root.FindNode(diagnostic.Location.SourceSpan) != null) 44var node = editor.OriginalRoot.FindNode(diagnostic.Location.SourceSpan);
src\Analyzers\Core\CodeFixes\RemoveUnnecessarySuppressions\RemoveUnnecessaryPragmaSuppressionsCodeFixProvider.cs (3)
39if (root.FindNode(diagnostic.Location.SourceSpan) is { } node && syntaxFacts.IsAttribute(node) || 40root.FindTrivia(diagnostic.Location.SourceSpan.Start).HasStructure) 58RemoveNode(diagnostic.Location, editor, processedNodes, syntaxFacts);
src\Analyzers\Core\CodeFixes\RemoveUnusedMembers\AbstractRemoveUnusedMembersCodeFixProvider.cs (1)
57var diagnosticNode = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\Analyzers\Core\CodeFixes\RemoveUnusedParametersAndValues\AbstractRemoveUnusedValuesCodeFixProvider.cs (6)
209return syntaxFacts.IsForEachStatement(diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken)); 270return diagnostics.GroupBy(d => syntaxFacts.GetContainingMemberDeclaration(root, d.Location.SourceSpan.Start) ?? root); 363diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start), 373diagnostics.OrderBy(d => d.Location.SourceSpan.Start), 402var expressionStatement = root.FindNode(diagnostic.Location.SourceSpan).FirstAncestorOrSelf<TExpressionStatementSyntax>(); 678var node = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
src\Analyzers\Core\CodeFixes\SimplifyBooleanExpression\SimplifyConditionalCodeFixProvider.cs (1)
53diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start).ToImmutableArray(),
src\Analyzers\Core\CodeFixes\SimplifyLinqExpression\AbstractSimplifyLinqExpressionCodeFixProvider`3.cs (1)
57return (TInvocationExpressionSyntax)root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
src\Analyzers\Core\CodeFixes\UpdateLegacySuppressions\UpdateLegacySuppressionsCodeFixProvider.cs (2)
34root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true) != null) 45var node = editor.OriginalRoot.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
src\Analyzers\Core\CodeFixes\UseExplicitTupleName\UseExplicitTupleNameCodeFixProvider.cs (1)
42var oldNameNode = diagnostic.Location.FindNode(
src\Analyzers\Core\CodeFixes\UseInferredMemberName\AbstractUseInferredMemberNameCodeFixProvider.cs (1)
39var node = root.FindNode(diagnostic.Location.SourceSpan);
src\Analyzers\Core\CodeFixes\UseIsNullCheck\AbstractUseIsNullForReferenceEqualsCodeFixProvider.cs (2)
41var title = GetTitle(negated, diagnostic.Location.SourceTree!.Options); 59foreach (var diagnostic in diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start))
SyncNamespaces\AbstractSyncNamespacesService.cs (5)
107RoslynDebug.AssertNotNull(firstDiagnostic?.Location?.SourceTree); 109var document = solution.GetRequiredDocument(firstDiagnostic.Location.SourceTree); 115firstDiagnostic.Location.SourceSpan, 124diagnosticSpan: firstDiagnostic.Location.SourceSpan, 172.Where(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.InteractiveHost (2)
Interactive\Core\InteractiveHost.Service.cs (2)
782displayedDiagnostics.Sort((d1, d2) => d1.Location.SourceSpan.Start - d2.Location.SourceSpan.Start);
Microsoft.CodeAnalysis.LanguageServer.Protocol (11)
Features\Diagnostics\DocumentAnalysisExecutor.cs (1)
385bool shouldInclude(Diagnostic d) => span.Value.IntersectsWith(d.Location.SourceSpan) && !IsUnusedImportDiagnostic(d);
Features\Diagnostics\DocumentAnalysisExecutor_Helpers.cs (9)
321await VerifyDiagnosticLocationAsync(diagnostic.Id, diagnostic.Location).ConfigureAwait(false); 410if (span.HasValue && !span.Value.IntersectsWith(diagnostic.Location.SourceSpan)) 420if (diagnostic.Location.SourceTree != null) 422return targetTextDocument.Project.GetDocument(diagnostic.Location.SourceTree) == targetTextDocument; 424else if (diagnostic.Location.Kind == LocationKind.ExternalFile) 426var lineSpan = diagnostic.Location.GetLineSpan(); 454return x.Id == y.Id && x.Location == y.Location; 462return Hash.Combine(obj.Id.GetHashCode(), obj.Location.GetHashCode());
Features\UnifiedSuggestions\UnifiedSuggestedActionsSource.cs (1)
246document, firstDiagnostic.Location.SourceSpan, scope, cancellationToken).ConfigureAwait(false);
Microsoft.CodeAnalysis.Test.Utilities (5)
Diagnostics\DiagnosticDescription.cs (3)
128_location = d.Location; 538var l = d.Location; 584return diagnostics.OrderBy(d => d.Location.GetMappedLineSpan().StartLinePosition, LinePositionComparer.Instance);
Diagnostics\DiagnosticExtensions.cs (2)
446=> e.Location.IsInSource ? $"{e.Severity} {e.Id}: {e.GetMessage(CultureInfo.CurrentCulture)}" : 447e.Location.IsInMetadata ? "metadata: " : "no location: ";
Microsoft.CodeAnalysis.VisualBasic (12)
CommandLine\CommandLineDiagnosticFormatter.vb (7)
44If diagnostic.Location <> Location.None Then 131If diagnostic.Location.IsInSource Then 132text = diagnostic.Location.SourceTree.GetText() 133Return diagnostic.Location.SourceSpan 136If diagnostic.Location.Kind = LocationKind.ExternalFile Then 137Dim path = diagnostic.Location.GetLineSpan().Path 147Return diagnostic.Location.SourceSpan
CommandLine\VisualBasicCompiler.vb (1)
324newDiagnostics.Add(New VBDiagnostic(ErrorFactory.ErrorInfo(ERRID.ERR_SymbolDefinedInAssembly, symbol, symbol.ContainingAssembly), diag.Location))
Compilation\VisualBasicDiagnosticFilter.vb (2)
74diagnostic.Location, 86diagnostic.Location,
GlobalImport.vb (1)
117Dim unmappedSpan = unmappedDiag.Location.SourceSpan
Symbols\Source\SourceModuleSymbol.vb (1)
1023Dim loc = d.Location
Microsoft.CodeAnalysis.VisualBasic.CodeStyle (2)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Helpers\RemoveUnnecessaryImports\VisualBasicUnnecessaryImportsProvider.vb (2)
38Dim node = TryCast(root.FindNode(diagnostic.Location.SourceSpan), ImportsClauseSyntax) 45Dim node = TryCast(root.FindNode(diagnostic.Location.SourceSpan), ImportsStatementSyntax)
Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes (3)
src\Analyzers\VisualBasic\CodeFixes\GenerateParameterizedMember\GenerateParameterizedMemberCodeFixProvider.vb (1)
62Dim diagnosticSpan = diagnostic.Location.SourceSpan
src\Analyzers\VisualBasic\CodeFixes\QualifyMemberAccess\VisualBasicQualifyMemberAccessCodeFixProvider.vb (1)
28Dim node = diagnostic.Location.FindNode(True, cancellationToken)
src\Analyzers\VisualBasic\CodeFixes\SimplifyObjectCreation\VisualBasicSimplifyObjectCreationCodeFixProvider.vb (1)
38Dim node = DirectCast(root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie:=True), VariableDeclaratorSyntax)
Microsoft.CodeAnalysis.VisualBasic.Features (6)
RemoveSharedFromModuleMembers\VisualBasicRemoveSharedFromModuleMembersCodeFixProvider.vb (3)
41Dim tokenToRemove = diagnostic.Location.FindToken(context.CancellationToken) 46Dim node = diagnostic.Location.FindNode(context.CancellationToken) 64Dim node = diagnostic.Location.FindNode(cancellationToken)
src\Analyzers\VisualBasic\CodeFixes\GenerateParameterizedMember\GenerateParameterizedMemberCodeFixProvider.vb (1)
62Dim diagnosticSpan = diagnostic.Location.SourceSpan
src\Analyzers\VisualBasic\CodeFixes\QualifyMemberAccess\VisualBasicQualifyMemberAccessCodeFixProvider.vb (1)
28Dim node = diagnostic.Location.FindNode(True, cancellationToken)
src\Analyzers\VisualBasic\CodeFixes\SimplifyObjectCreation\VisualBasicSimplifyObjectCreationCodeFixProvider.vb (1)
38Dim node = DirectCast(root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie:=True), VariableDeclaratorSyntax)
Microsoft.CodeAnalysis.VisualBasic.Semantic.UnitTests (1)
SourceGeneration\GeneratorDriverTests.vb (1)
735Assert.Equal(NoLocation.Singleton, diagnostic.Location)
Microsoft.CodeAnalysis.VisualBasic.Syntax.UnitTests (2)
TestSyntaxNodes.vb (2)
932Dim span1 = err1.Location.SourceSpan 933Dim span2 = err2.Location.SourceSpan
Microsoft.CodeAnalysis.VisualBasic.Test.Utilities (7)
CompilationTestUtils.vb (6)
1006If e.Location.IsInSource Then 1007Dim sourceLocation = e.Location 1014ElseIf e.Location.IsInMetadata Then 1017e.Location.MetadataModule.ContainingAssembly.Identity.Name) 1035Dim loc1 = diag1.Location 1036Dim loc2 = diag2.Location
ParserTestUtilities.vb (1)
614Dim syntaxErrorSpan = syntaxError.Location.SourceSpan
Microsoft.CodeAnalysis.VisualBasic.Workspaces (3)
Simplification\VisualBasicSimplificationService.vb (1)
170Dim node = root.FindNode(diagnostic.Location.SourceSpan)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Helpers\RemoveUnnecessaryImports\VisualBasicUnnecessaryImportsProvider.vb (2)
38Dim node = TryCast(root.FindNode(diagnostic.Location.SourceSpan), ImportsClauseSyntax) 45Dim node = TryCast(root.FindNode(diagnostic.Location.SourceSpan), ImportsStatementSyntax)
Microsoft.CodeAnalysis.Workspaces (30)
CodeFixes\CodeFix.cs (4)
62if (diagnostic.Location.IsInSource) 64var document = Project.GetDocument(diagnostic.Location.SourceTree); 70else if (diagnostic.Location.Kind == LocationKind.ExternalFile) 72var document = Project.Documents.FirstOrDefault(d => d.FilePath == diagnostic.Location.GetLineSpan().Path);
CodeFixes\CodeFixContext.cs (3)
150(diagnostic ?? throw new ArgumentNullException(nameof(diagnostic))).Location.SourceSpan, 174(diagnostic ?? throw new ArgumentNullException(nameof(diagnostic))).Location.SourceSpan, 250if (diagnostics.Any((d, span) => d.Location.SourceSpan != span, span))
CodeFixes\FixAllOccurrences\BatchFixAllProvider.cs (5)
118.Where(d => d.Location.IsInSource) 119.OrderBy(d => d.Location.SourceTree!.FilePath) 120.ThenBy(d => d.Location.SourceSpan.Start) 148var document = solution.GetRequiredDocument(diagnostic.Location.SourceTree!); 156var context = new CodeFixContext(document, diagnostic.Location.SourceSpan, [diagnostic], action, cancellationToken);
CodeFixes\FixAllOccurrences\FixAllContext.cs (1)
252&& (filterSpan == null || filterSpan.Value.Contains(d.Location.SourceSpan))).ToImmutableArray();
CodeFixes\FixAllOccurrences\FixAllContextHelper.cs (1)
134foreach (var (textDocument, diagnosticsForDocument) in diagnostics.GroupBy(d => solution.GetTextDocumentForLocation(d.Location)))
CodeFixes\FixAllOccurrences\FixAllState.cs (1)
70var diagnosticSpan = diagnosticsToFix.First().Value.FirstOrDefault()?.Location.SourceSpan;
Diagnostics\DiagnosticAnalysisResultBuilder.cs (7)
57switch (diagnostic.Location.Kind) 61var diagnosticDocumentId = Project.GetDocumentForExternalLocation(diagnostic.Location); 121=> AddDiagnostic(ref _lazySemanticLocals, diagnostic.Location.SourceTree, diagnostic); 139switch (diagnostic.Location.Kind) 142var diagnosticDocumentId = Project.GetDocumentForExternalLocation(diagnostic.Location); 159var diagnosticTree = diagnostic.Location.SourceTree; 184throw ExceptionUtilities.UnexpectedValue(diagnostic.Location.Kind);
Diagnostics\DiagnosticData.cs (1)
197var location = CreateLocation(document, diagnostic.Location);
Diagnostics\Extensions.cs (5)
215var diagnostics = additionalPragmaSuppressionDiagnostics.WhereAsArray(d => d.Location.SourceTree == treeToAnalyze); 222foreach (var group in additionalPragmaSuppressionDiagnostics.GroupBy(d => d.Location.SourceTree!)) 280Debug.Assert(diagnostics.All(d => d.Location.SourceTree == tree)); 292Debug.Assert(diagnostics.All(d => d.Location.SourceTree == tree)); 322filterSpan.HasValue && !filterSpan.Value.IntersectsWith(diagnostic.Location.SourceSpan));
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeFixes\ForkingSyntaxEditorBasedCodeFixProvider.cs (1)
36/// computed with respect to the original user document, and as such its <see cref="Diagnostic.Location"/> and <see
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\ProjectExtensions.cs (1)
58var diagnosticFilePath = PathUtilities.GetDirectoryName(diagnostic?.Location.SourceTree?.FilePath ?? project.FilePath);
Microsoft.CodeAnalysis.Workspaces.UnitTests (1)
BatchFixAllProviderTests.cs (1)
104cancellationToken => CreateChangedDocument(context.Document, diagnostic.Location.SourceSpan, replacement, cancellationToken),
Microsoft.Gen.ComplianceReports.Unit.Tests (10)
test\Generators\Shared\RoslynTestUtils.cs (10)
142Assert.True(expectedSpan.Equals(actual.Location.SourceSpan), 143$"Span {spanNum} doesn't match: expected {expectedSpan} but got {actual.Location.SourceSpan}"); 157if (d.Location != Location.None) 169Assert.True(expectedSpan.Equals(d.Location.SourceSpan), 170$"Span {spanNum} doesn't match: expected {expectedSpan} but got {d.Location.SourceSpan}"); 418if (x.Location.SourceSpan.Start < y.Location.SourceSpan.Start) 422else if (x.Location.SourceSpan.Start > y.Location.SourceSpan.Start) 484var doc = proj.GetDocument(d.Location.SourceTree);
Microsoft.Gen.ContextualOptions.Unit.Tests (10)
test\Generators\Shared\RoslynTestUtils.cs (10)
142Assert.True(expectedSpan.Equals(actual.Location.SourceSpan), 143$"Span {spanNum} doesn't match: expected {expectedSpan} but got {actual.Location.SourceSpan}"); 157if (d.Location != Location.None) 169Assert.True(expectedSpan.Equals(d.Location.SourceSpan), 170$"Span {spanNum} doesn't match: expected {expectedSpan} but got {d.Location.SourceSpan}"); 418if (x.Location.SourceSpan.Start < y.Location.SourceSpan.Start) 422else if (x.Location.SourceSpan.Start > y.Location.SourceSpan.Start) 484var doc = proj.GetDocument(d.Location.SourceTree);
Microsoft.Gen.Logging.Unit.Tests (10)
test\Generators\Shared\RoslynTestUtils.cs (10)
142Assert.True(expectedSpan.Equals(actual.Location.SourceSpan), 143$"Span {spanNum} doesn't match: expected {expectedSpan} but got {actual.Location.SourceSpan}"); 157if (d.Location != Location.None) 169Assert.True(expectedSpan.Equals(d.Location.SourceSpan), 170$"Span {spanNum} doesn't match: expected {expectedSpan} but got {d.Location.SourceSpan}"); 418if (x.Location.SourceSpan.Start < y.Location.SourceSpan.Start) 422else if (x.Location.SourceSpan.Start > y.Location.SourceSpan.Start) 484var doc = proj.GetDocument(d.Location.SourceTree);
Microsoft.Gen.Metrics.Unit.Tests (10)
test\Generators\Shared\RoslynTestUtils.cs (10)
142Assert.True(expectedSpan.Equals(actual.Location.SourceSpan), 143$"Span {spanNum} doesn't match: expected {expectedSpan} but got {actual.Location.SourceSpan}"); 157if (d.Location != Location.None) 169Assert.True(expectedSpan.Equals(d.Location.SourceSpan), 170$"Span {spanNum} doesn't match: expected {expectedSpan} but got {d.Location.SourceSpan}"); 418if (x.Location.SourceSpan.Start < y.Location.SourceSpan.Start) 422else if (x.Location.SourceSpan.Start > y.Location.SourceSpan.Start) 484var doc = proj.GetDocument(d.Location.SourceTree);
Microsoft.Gen.MetricsReports.Unit.Tests (10)
test\Generators\Shared\RoslynTestUtils.cs (10)
142Assert.True(expectedSpan.Equals(actual.Location.SourceSpan), 143$"Span {spanNum} doesn't match: expected {expectedSpan} but got {actual.Location.SourceSpan}"); 157if (d.Location != Location.None) 169Assert.True(expectedSpan.Equals(d.Location.SourceSpan), 170$"Span {spanNum} doesn't match: expected {expectedSpan} but got {d.Location.SourceSpan}"); 418if (x.Location.SourceSpan.Start < y.Location.SourceSpan.Start) 422else if (x.Location.SourceSpan.Start > y.Location.SourceSpan.Start) 484var doc = proj.GetDocument(d.Location.SourceTree);
Microsoft.Interop.ComInterfaceGenerator (3)
src\libraries\System.Runtime.InteropServices\gen\Common\ConvertToSourceGeneratedInteropFixer.cs (3)
198DocumentId documentId = solutionEditor.OriginalSolution.GetDocumentId(diagnostic.Location.SourceTree)!; 200SyntaxNode root = await diagnostic.Location.SourceTree.GetRootAsync(ct).ConfigureAwait(false); 202SyntaxNode node = root.FindNode(diagnostic.Location.SourceSpan);
Microsoft.Interop.LibraryImportGenerator (11)
Analyzers\CustomMarshallerAttributeFixer.cs (5)
36Document doc = fixAllContext.Solution.GetDocument(diagnostic.Location.SourceTree); 39var entryPointTypeSymbol = (INamedTypeSymbol)model.GetEnclosingSymbol(diagnostic.Location.SourceSpan.Start, fixAllContext.CancellationToken); 40ITypeSymbol? managedType = GetManagedTypeInAttributeSyntax(diagnostic.Location, entryPointTypeSymbol); 42SyntaxNode root = await diagnostic.Location.SourceTree.GetRootAsync(fixAllContext.CancellationToken).ConfigureAwait(false); 44SyntaxNode node = root.FindNode(diagnostic.Location.SourceSpan);
Analyzers\ShapeBreakingDiagnosticSuppressor.cs (3)
35SemanticModel model = context.GetSemanticModel(diagnostic.Location.SourceTree); 36ISymbol diagnosedSymbol = model.GetDeclaredSymbol(diagnostic.Location.SourceTree.GetRoot(context.CancellationToken).FindNode(diagnostic.Location.SourceSpan), context.CancellationToken);
src\libraries\System.Runtime.InteropServices\gen\Common\ConvertToSourceGeneratedInteropFixer.cs (3)
198DocumentId documentId = solutionEditor.OriginalSolution.GetDocumentId(diagnostic.Location.SourceTree)!; 200SyntaxNode root = await diagnostic.Location.SourceTree.GetRootAsync(ct).ConfigureAwait(false); 202SyntaxNode node = root.FindNode(diagnostic.Location.SourceSpan);
Microsoft.ML.InternalCodeAnalyzer (4)
ContractsCheckNameofFixProvider.cs (1)
41var diagnosticSpan = diagnostic.Location.SourceSpan;
NameFixProvider.cs (1)
60var token = root.FindToken(diagnostic.Location.SourceSpan.Start);
RelaxTestNamingSuppressor.cs (2)
36if (!(diagnostic.Location.SourceTree is { } tree)) 42var node = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
Mvc.Api.Analyzers.Test (2)
ApiActionsDoNotRequireExplicitModelValidationCheckAnalyzerIntegrationTest.cs (1)
79AnalyzerAssert.DiagnosticLocation(expectedLocation, diagnostic.Location);
ApiConventionAnalyzerIntegrationTest.cs (1)
295AnalyzerAssert.DiagnosticLocation(expectedLocation, diagnostic.Location);
System.Windows.Forms.Analyzers.CodeFixes.CSharp (1)
System\Windows\Forms\CSharp\CodeFixes\AddDesignerSerializationVisibility\AddDesignerSerializationVisibilityCodeFixProvider.cs (1)
39TextSpan diagnosticSpan = diagnostic.Location.SourceSpan;
System.Windows.Forms.Analyzers.CodeFixes.VisualBasic (1)
AddDesignerSerializationVisibility\AddDesignerSerializationVisibilityCodeFixProvider.vb (1)
45Dim diagnosticSpan As TextSpan = diagnostic.Location.SourceSpan