5 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)
131public override Location Location
Diagnostic\DiagnosticWithInfo.cs (1)
33public override Location Location
DiagnosticAnalyzer\CompilerDiagnosticAnalyzer.CompilationAnalyzer.cs (1)
97public override Location Location => _original.Location;
586 references to Location
dotnet-format (8)
Analyzers\AnalyzerFormatter.cs (2)
178var document = solution.GetDocument(diagnostic.Location.SourceTree); 184var mappedLineSpan = diagnostic.Location.GetMappedLineSpan();
Analyzers\AnalyzerRunner.cs (3)
86diagnostic.Location.IsInSource && 87diagnostic.Location.SourceTree != null && 88formattableDocumentPaths.Contains(diagnostic.Location.SourceTree.FilePath))
Analyzers\SolutionCodeFixApplier.cs (3)
33.Where(diagnostic => diagnostic.Location.SourceTree != null) 41var document = solution.GetDocument(diagnostic.Location.SourceTree); 112return projectDiagnostics.Where(diagnostic => diagnostic.Location.SourceTree?.FilePath == document.FilePath).ToImmutableArray();
GenerateDocumentationAndConfigFiles (5)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeFixes\FixAllContextHelper.cs (1)
140foreach (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)
42var diagnosticFilePath = PathUtilities.GetDirectoryName(diagnostic?.Location.SourceTree?.FilePath ?? project.FilePath);
ILLink.CodeFixProvider (3)
BaseAttributeCodeFixProvider.cs (1)
42SyntaxNode targetNode = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
RequiresUnsafeCodeFixProvider.cs (1)
50SyntaxNode targetNode = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
UnsafeMethodMissingRequiresUnsafeCodeFixProvider.cs (1)
40var node = 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.App.CodeFixes (15)
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);
Kestrel\ListenOnIPv6AnyFixer.cs (1)
40var argumentSyntax = root.FindNode(diagnostic.Location.SourceSpan).FirstAncestorOrSelf<ArgumentSyntax>();
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.SdkAnalyzers (1)
ComponentParametersShouldBePublicCodeFixProvider.cs (1)
35var diagnosticSpan = diagnostic.Location.SourceSpan;
Microsoft.AspNetCore.Mvc.Api.Analyzers (2)
AddResponseTypeAttributeCodeFixAction.cs (2)
41public override string EquivalenceKey => _diagnostic.Location.ToString(); 131var diagnosticNode = root.FindNode(_diagnostic.Location.SourceSpan);
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)
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> 439return "Unresolved diagnostic at " + this.Location; 444return "Void diagnostic at " + this.Location; 496if (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)
304=> diagnostic.Location.SourceTree; 309if (diagnostic.Location is ExternalFileLocation externalFileLocation)
DiagnosticAnalyzer\AnalysisScope.cs (4)
299if (diagnostic.Location.IsInSource) 301if (diagnostic.Location.SourceTree != filterFile.SourceTree) 306else if (diagnostic.Location is ExternalFileLocation externalFileLocation) 315return ShouldInclude(diagnostic.Location.SourceSpan);
DiagnosticAnalyzer\AnalyzerDriver.cs (2)
635return suppressInGeneratedCode && IsInGeneratedCode(diagnostic.Location, compilation, cancellationToken); 2027if (diagnostic?.Location.SourceTree is { } tree &&
DiagnosticAnalyzer\AnalyzerExecutor.AnalyzerDiagnosticReporter.cs (4)
117(!FilterSpanForLocalDiagnostics.HasValue || FilterSpanForLocalDiagnostics.Value.IntersectsWith(diagnostic.Location.SourceSpan))) 130if (diagnostic.Location.IsInSource) 133_contextFile.Value.SourceTree == diagnostic.Location.SourceTree; 137diagnostic.Location is ExternalFileLocation externalFileLocation)
DiagnosticAnalyzer\AnalyzerExecutor.cs (3)
1548if (diagnostic.Location.IsInSource) 1553if (syntaxRef.SyntaxTree == diagnostic.Location.SourceTree) 1556if (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)
176var location = diagnostic.Location;
Microsoft.CodeAnalysis.Analyzers (11)
MetaAnalyzers\Fixers\CompareSymbolsCorrectlyFix.cs (2)
46cancellationToken => ConvertToEqualsAsync(context.Document, diagnostic.Location.SourceSpan, cancellationToken), 54cancellationToken => CallOverloadWithEqualityComparerAsync(context.Document, diagnostic.Location.SourceSpan, cancellationToken),
MetaAnalyzers\Fixers\ConfigureGeneratedCodeAnalysisFix.cs (1)
35cancellationToken => ConfigureGeneratedCodeAnalysisAsync(context.Document, diagnostic.Location.SourceSpan, cancellationToken),
MetaAnalyzers\Fixers\EnableConcurrentExecutionFix.cs (1)
34cancellationToken => EnableConcurrentExecutionAsync(context.Document, diagnostic.Location.SourceSpan, cancellationToken),
MetaAnalyzers\Fixers\PreferIsKindFix.cs (2)
29cancellationToken => ConvertKindToIsKindAsync(context.Document, diagnostic.Location.SourceSpan, cancellationToken), 68var nodeToFix = _fixer.TryGetNodeToFix(editor.OriginalRoot, diagnostic.Location.SourceSpan);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeFixes\FixAllContextHelper.cs (1)
140foreach (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)
42var diagnosticFilePath = PathUtilities.GetDirectoryName(diagnostic?.Location.SourceTree?.FilePath ?? project.FilePath);
Microsoft.CodeAnalysis.CodeStyle (4)
src\roslyn\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 (53)
src\roslyn\src\Analyzers\Core\CodeFixes\AddAnonymousTypeMemberName\AbstractAddAnonymousTypeMemberNameCodeFixProvider.cs (1)
55var span = diagnostic.Location.SourceSpan;
src\roslyn\src\Analyzers\Core\CodeFixes\AddExplicitCast\AbstractAddExplicitCastCodeFixProvider.cs (2)
74var spanNode = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true).GetAncestorOrThis<TExpressionSyntax>(); 218d => root.FindNode(d.Location.SourceSpan, getInnermostNodeForTie: true)
src\roslyn\src\Analyzers\Core\CodeFixes\AddObsoleteAttribute\AbstractAddObsoleteAttributeCodeFixProvider.cs (2)
45var node = context.Diagnostics[0].Location.FindNode(cancellationToken); 81var containers = diagnostics.Select(d => GetContainer(root, d.Location.FindNode(cancellationToken)))
src\roslyn\src\Analyzers\Core\CodeFixes\AddParameter\AbstractAddParameterCodeFixProvider.cs (1)
70var 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(); 416var position = diagnostic.Location.SourceSpan.Start;
src\roslyn\src\Analyzers\Core\CodeFixes\ConvertTypeOfToNameOf\AbstractConvertTypeOfToNameOfCodeFixProvider.cs (1)
40if (editor.OriginalRoot.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true) is not TMemberAccessExpressionSyntax node)
src\roslyn\src\Analyzers\Core\CodeFixes\ForEachCast\AbstractForEachCastCodeFixProvider.cs (1)
46var node = editor.OriginalRoot.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
src\roslyn\src\Analyzers\Core\CodeFixes\Formatting\FormattingCodeFixProvider.cs (1)
74var diagnosticSpan = diagnostic.Location.SourceSpan;
src\roslyn\src\Analyzers\Core\CodeFixes\GenerateDefaultConstructors\AbstractGenerateDefaultConstructorCodeFixProvider.cs (1)
30if (!headerFacts.IsOnTypeHeader(root, diagnostic.Location.SourceSpan.Start, fullHeader: true, out var typeDecl))
src\roslyn\src\Analyzers\Core\CodeFixes\MakeFieldReadonly\AbstractMakeFieldReadonlyCodeFixProvider.cs (1)
46var diagnosticSpan = diagnostic.Location.SourceSpan;
src\roslyn\src\Analyzers\Core\CodeFixes\MakeMemberStatic\AbstractMakeMemberStaticCodeFixProvider.cs (2)
22TryGetMemberDeclaration(context.Diagnostics[0].Location.FindNode(context.CancellationToken), out _)) 33var declaration = diagnostics[i].Location.FindNode(cancellationToken);
src\roslyn\src\Analyzers\Core\CodeFixes\MakeMethodAsynchronous\AbstractMakeMethodAsynchronousCodeFixProvider.cs (1)
153var token = diagnostic.Location.FindToken(cancellationToken);
src\roslyn\src\Analyzers\Core\CodeFixes\MakeMethodSynchronous\AbstractMakeMethodSynchronousCodeFixProvider.cs (1)
34var token = diagnostic.Location.FindToken(cancellationToken);
src\roslyn\src\Analyzers\Core\CodeFixes\MakeTypeAbstract\AbstractMakeTypeAbstractCodeFixProvider.cs (2)
22if (IsValidRefactoringContext(context.Diagnostics[0].Location?.FindNode(context.CancellationToken), out _)) 33if (IsValidRefactoringContext(diagnostics[i].Location?.FindNode(cancellationToken), out var typeDeclaration))
src\roslyn\src\Analyzers\Core\CodeFixes\MakeTypePartial\AbstractMakeTypePartialCodeFixProvider.cs (1)
31var 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)
55var memberDeclaration = diagnostic.Location.FindNode(cancellationToken);
src\roslyn\src\Analyzers\Core\CodeFixes\RemoveAsyncModifier\AbstractRemoveAsyncModifierCodeFixProvider.cs (3)
35var token = diagnostic.Location.FindToken(cancellationToken); 64foreach (var diagnostic in diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start)) 66var token = diagnostic.Location.FindToken(cancellationToken);
src\roslyn\src\Analyzers\Core\CodeFixes\RemoveUnnecessarySuppressions\RemoveUnnecessaryAttributeSuppressionsCodeFixProvider.cs (2)
32if (root.FindNode(diagnostic.Location.SourceSpan) != null) 43var node = editor.OriginalRoot.FindNode(diagnostic.Location.SourceSpan);
src\roslyn\src\Analyzers\Core\CodeFixes\RemoveUnnecessarySuppressions\RemoveUnnecessaryPragmaSuppressionsCodeFixProvider.cs (3)
37if (root.FindNode(diagnostic.Location.SourceSpan) is { } node && syntaxFacts.IsAttribute(node) || 38root.FindTrivia(diagnostic.Location.SourceSpan.Start).HasStructure) 56RemoveNode(diagnostic.Location, editor, processedNodes, syntaxFacts);
src\roslyn\src\Analyzers\Core\CodeFixes\RemoveUnusedMembers\AbstractRemoveUnusedMembersCodeFixProvider.cs (1)
54var diagnosticNode = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\roslyn\src\Analyzers\Core\CodeFixes\RemoveUnusedParametersAndValues\AbstractRemoveUnusedValuesCodeFixProvider.cs (6)
208return syntaxFacts.IsForEachStatement(diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken)); 269return diagnostics.GroupBy(d => syntaxFacts.GetContainingMemberDeclaration(root, d.Location.SourceSpan.Start) ?? root); 362diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start), 372diagnostics.OrderBy(d => d.Location.SourceSpan.Start), 401var expressionStatement = root.FindNode(diagnostic.Location.SourceSpan).FirstAncestorOrSelf<TExpressionStatementSyntax>(); 677var node = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
src\roslyn\src\Analyzers\Core\CodeFixes\SimplifyBooleanExpression\SimplifyConditionalCodeFixProvider.cs (2)
50diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start).ToImmutableArray(), 51d => d.Location.FindNode(getInnermostNodeForTie: true, cancellationToken),
src\roslyn\src\Analyzers\Core\CodeFixes\SimplifyLinqExpression\SimplifyLinqExpressionCodeFixProvider.cs (2)
41foreach (var diagnostic in diagnostics.OrderByDescending(diagnostics => diagnostics.Location.SourceSpan.Start)) 43var invocation = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
src\roslyn\src\Analyzers\Core\CodeFixes\UpdateLegacySuppressions\UpdateLegacySuppressionsCodeFixProvider.cs (2)
33root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true) != null) 44var node = editor.OriginalRoot.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
src\roslyn\src\Analyzers\Core\CodeFixes\UseExplicitTupleName\UseExplicitTupleNameCodeFixProvider.cs (1)
39var oldNameNode = diagnostic.Location.FindNode(
src\roslyn\src\Analyzers\Core\CodeFixes\UseInferredMemberName\AbstractUseInferredMemberNameCodeFixProvider.cs (1)
34var node = root.FindNode(diagnostic.Location.SourceSpan);
src\roslyn\src\Analyzers\Core\CodeFixes\UseIsNullCheck\AbstractUseIsNullForReferenceEqualsCodeFixProvider.cs (2)
40var title = GetTitle(negated, diagnostic.Location.SourceTree!.Options); 54foreach (var diagnostic in diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start))
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeFixes\FixAllContextHelper.cs (1)
140foreach (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)
42var diagnosticFilePath = PathUtilities.GetDirectoryName(diagnostic?.Location.SourceTree?.FilePath ?? project.FilePath);
Microsoft.CodeAnalysis.CSharp (8)
CommandLine\CSharpCompiler.cs (1)
404diag.Location));
Compilation\CSharpDiagnosticFilter.cs (2)
84d.Location, 101d.Location,
FlowAnalysis\DefiniteAssignment.cs (1)
578diagnostics.Add(newCode, diagnostic.Location, args);
Symbols\Source\SourceMemberContainerSymbol.cs (4)
2364(d.Location == arg.method1.GetFirstLocation() || d.Location == arg.underlying1.AssociatedSymbol?.TryGetFirstLocation() || 2365d.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)
172var intersectingDiagnostics = diagnostics.Where(d => d.Location.SourceSpan.IntersectsWith(rewrittenAncestor.Span));
src\roslyn\src\Analyzers\CSharp\Analyzers\RemoveUnreachableCode\CSharpRemoveUnreachableCodeDiagnosticAnalyzer.cs (1)
65ProcessUnreachableDiagnostic(context, root, diagnostic.Location.SourceSpan);
src\roslyn\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 (61)
src\roslyn\src\Analyzers\CSharp\CodeFixes\AddBraces\CSharpAddBracesCodeFixProvider.cs (1)
37var statement = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
src\roslyn\src\Analyzers\CSharp\CodeFixes\AddInheritdoc\AddInheritdocCodeFixProvider.cs (2)
45var node = root.FindNode(diagnostic.Location.SourceSpan); 75var node = editor.OriginalRoot.FindNode(diagnostic.Location.SourceSpan);
src\roslyn\src\Analyzers\CSharp\CodeFixes\AssignOutParameters\AbstractAssignOutParametersCodeFixProvider.cs (1)
101diagnostics.SelectAsArray(d => GetContainer(root, d.Location.SourceSpan))
src\roslyn\src\Analyzers\CSharp\CodeFixes\ConditionalExpressionInStringInterpolation\CSharpAddParenthesesAroundConditionalExpressionInInterpolatedStringCodeFixProvider.cs (1)
37var diagnosticSpan = diagnostic.Location.SourceSpan;
src\roslyn\src\Analyzers\CSharp\CodeFixes\DisambiguateSameVariable\CSharpDisambiguateSameVariableCodeFixProvider.cs (2)
60var span = diagnostic.Location.SourceSpan; 61var node = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\FixIncorrectConstraint\CSharpFixIncorrectConstraintCodeFixProvider.cs (1)
37constraint = diagnostic.Location.FindNode(cancellationToken) as TypeConstraintSyntax;
src\roslyn\src\Analyzers\CSharp\CodeFixes\FixReturnType\CSharpFixReturnTypeCodeFixProvider.cs (1)
65var location = diagnostics[0].Location;
src\roslyn\src\Analyzers\CSharp\CodeFixes\HiddenExplicitCast\CSharpHiddenExplicitCastCodeFixProvider.cs (2)
41foreach (var diagnostic in diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start)) 43if (diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken) is not CastExpressionSyntax castExpression)
src\roslyn\src\Analyzers\CSharp\CodeFixes\HideBase\HideBaseCodeFixProvider.cs (1)
34var diagnosticSpan = diagnostic.Location.SourceSpan;
src\roslyn\src\Analyzers\CSharp\CodeFixes\MakeAnonymousFunctionStatic\CSharpMakeAnonymousFunctionStaticCodeFixProvider.cs (1)
42var 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)
118var memberDeclarator = root.FindNode(diagnostic.Location.SourceSpan);
src\roslyn\src\Analyzers\CSharp\CodeFixes\MakeMethodAsynchronous\CSharpMakeMethodAsynchronousCodeFixProvider.cs (3)
46if (diagnostic.Location.SourceTree is null) 49var root = diagnostic.Location.SourceTree.GetRoot(cancellationToken); 50var token = root.FindToken(diagnostic.Location.SourceSpan.Start);
src\roslyn\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\roslyn\src\Analyzers\CSharp\CodeFixes\MakeStructFieldsWritable\CSharpMakeStructFieldsWritableCodeFixProvider.cs (1)
41var diagnosticNode = diagnostic.Location.FindNode(cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\NewLines\ArrowExpressionClausePlacement\ArrowExpressionClausePlacementCodeFixProvider.cs (1)
51var arrowToken = root.FindToken(diagnostic.Location.SourceSpan.Start);
src\roslyn\src\Analyzers\CSharp\CodeFixes\NewLines\ConditionalExpressionPlacement\ConditionalExpressionPlacementCodeFixProvider.cs (1)
51var questionToken = root.FindToken(diagnostic.Location.SourceSpan.Start);
src\roslyn\src\Analyzers\CSharp\CodeFixes\NewLines\ConsecutiveBracePlacement\ConsecutiveBracePlacementCodeFixProvider.cs (1)
67var token = root.FindToken(diagnostic.Location.SourceSpan.Start);
src\roslyn\src\Analyzers\CSharp\CodeFixes\Nullable\CSharpDeclareAsNullableCodeFixProvider.cs (3)
46var node = context.Diagnostics.First().Location.FindNode(getInnermostNodeForTie: true, cancellationToken); 86var node = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken); 94var node = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\QualifyMemberAccess\CSharpQualifyMemberAccessCodeFixProvider.cs (1)
23var node = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\RemoveInKeyword\RemoveInKeywordCodeFixProvider.cs (1)
38var diagnosticSpan = diagnostic.Location.SourceSpan;
src\roslyn\src\Analyzers\CSharp\CodeFixes\RemoveNewModifier\RemoveNewModifierCodeFixProvider.cs (1)
36var diagnosticSpan = diagnostic.Location.SourceSpan;
src\roslyn\src\Analyzers\CSharp\CodeFixes\RemoveUnnecessaryDiscardDesignation\CSharpRemoveUnnecessaryDiscardDesignationCodeFixProvider.cs (1)
41var 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)
44var 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)
42var accessor = (AccessorDeclarationSyntax)diagnostic.Location.FindNode(cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\TransposeRecordKeyword\CSharpTransposeRecordKeywordCodeFixProvider.cs (1)
32recordDeclaration = diagnostic.Location.FindNode(cancellationToken) as RecordDeclarationSyntax;
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseDeconstruction\CSharpUseDeconstructionCodeFixProvider.cs (1)
40var nodesToProcess = diagnostics.SelectAsArray(d => d.Location.FindToken(cancellationToken).GetRequiredParent());
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseDefaultLiteral\CSharpUseDefaultLiteralCodeFixProvider.cs (1)
52d => (DefaultExpressionSyntax)originalRoot.FindNode(d.Location.SourceSpan, getInnermostNodeForTie: true));
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseExplicitArrayInExpressionTree\CSharpUseExplicitArrayInExpressionTreeCodeFixProvider.cs (3)
98var node = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken); 122foreach (var diagnostic in diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start)) 124if (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)
56var node = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseImplicitOrExplicitType\UseImplicitTypeCodeFixProvider.cs (1)
47var typeSyntax = (TypeSyntax)root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseIndexOrRangeOperator\CSharpUseIndexOperatorCodeFixProvider.cs (2)
39foreach (var diagnostic in diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start)) 41var node = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseInterpolatedVerbatimString\CSharpUseInterpolatedVerbatimStringCodeFixProvider.cs (1)
50var verbatimInterpolatedLocation = diagnostic.Location;
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseIsNullCheck\CSharpUseIsNullCheckForCastAndEqualityOperatorCodeFixProvider.cs (2)
42var title = GetTitle(negated, diagnostic.Location.SourceTree!.Options); 57var binary = (BinaryExpressionSyntax)diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken: cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseIsNullCheck\CSharpUseNullCheckOverTypeCheckCodeFixProvider.cs (1)
42var node = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken: cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseNameofInAttribute\CSharpUseNameofInAttributeCodeFixProvider.cs (1)
42var expression = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\UsePatternCombinators\CSharpUsePatternCombinatorsCodeFixProvider.cs (1)
77var location = diagnostic.Location;
src\roslyn\src\Analyzers\CSharp\CodeFixes\UsePatternMatching\CSharpAsAndMemberAccessCodeFixProvider.cs (2)
42foreach (var diagnostic in diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start)) 48var node = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\UsePrimaryConstructor\CSharpUsePrimaryConstructorCodeFixProvider.cs (1)
63if (diagnostic.Location.FindNode(cancellationToken) is not ConstructorDeclarationSyntax constructorDeclaration)
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseSystemThreadingLock\CSharpUseSystemThreadingLockCodeFixProvider.cs (1)
47if (diagnostic.Location.FindNode(cancellationToken) is not VariableDeclaratorSyntax variableDeclarator)
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseUtf8StringLiteral\UseUtf8StringLiteralCodeFixProvider.cs (3)
55var node = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken); 81editor.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)
79var containingMethod = CSharpSyntaxFacts.Instance.GetContainingMethodDeclaration(root, diagnostic.Location.SourceSpan.Start, useFullSpan: false);
Copilot\CSharpCopilotProposalAdjusterService.cs (2)
43var closeBraceDiagnostics = newDiagnostics.WhereAsArray(d => d.Id == CS1513 && d.Location.SourceSpan.Start >= lastChangeEndPos); 49d => new TextChange(new TextSpan(d.Location.SourceSpan.Start, 0), "}"));
Copilot\CSharpImplementNotImplementedExceptionFixProvider.cs (2)
59var diagnosticNode = context.Diagnostics[0].Location.FindNode(getInnermostNodeForTie: true, cancellationToken); 92var diagnosticNode = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\roslyn\src\Analyzers\CSharp\Analyzers\RemoveUnnecessarySuppressions\UnnecessaryNullableWarningSuppressionsUtilities.cs (1)
172var intersectingDiagnostics = diagnostics.Where(d => d.Location.SourceSpan.IntersectsWith(rewrittenAncestor.Span));
src\roslyn\src\Analyzers\CSharp\Analyzers\RemoveUnreachableCode\CSharpRemoveUnreachableCodeDiagnosticAnalyzer.cs (1)
65ProcessUnreachableDiagnostic(context, root, diagnostic.Location.SourceSpan);
src\roslyn\src\Analyzers\CSharp\CodeFixes\AddBraces\CSharpAddBracesCodeFixProvider.cs (1)
37var statement = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
src\roslyn\src\Analyzers\CSharp\CodeFixes\AddInheritdoc\AddInheritdocCodeFixProvider.cs (2)
45var node = root.FindNode(diagnostic.Location.SourceSpan); 75var node = editor.OriginalRoot.FindNode(diagnostic.Location.SourceSpan);
src\roslyn\src\Analyzers\CSharp\CodeFixes\AssignOutParameters\AbstractAssignOutParametersCodeFixProvider.cs (1)
101diagnostics.SelectAsArray(d => GetContainer(root, d.Location.SourceSpan))
src\roslyn\src\Analyzers\CSharp\CodeFixes\ConditionalExpressionInStringInterpolation\CSharpAddParenthesesAroundConditionalExpressionInInterpolatedStringCodeFixProvider.cs (1)
37var diagnosticSpan = diagnostic.Location.SourceSpan;
src\roslyn\src\Analyzers\CSharp\CodeFixes\DisambiguateSameVariable\CSharpDisambiguateSameVariableCodeFixProvider.cs (2)
60var span = diagnostic.Location.SourceSpan; 61var node = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\FixIncorrectConstraint\CSharpFixIncorrectConstraintCodeFixProvider.cs (1)
37constraint = diagnostic.Location.FindNode(cancellationToken) as TypeConstraintSyntax;
src\roslyn\src\Analyzers\CSharp\CodeFixes\FixReturnType\CSharpFixReturnTypeCodeFixProvider.cs (1)
65var location = diagnostics[0].Location;
src\roslyn\src\Analyzers\CSharp\CodeFixes\HiddenExplicitCast\CSharpHiddenExplicitCastCodeFixProvider.cs (2)
41foreach (var diagnostic in diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start)) 43if (diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken) is not CastExpressionSyntax castExpression)
src\roslyn\src\Analyzers\CSharp\CodeFixes\HideBase\HideBaseCodeFixProvider.cs (1)
34var diagnosticSpan = diagnostic.Location.SourceSpan;
src\roslyn\src\Analyzers\CSharp\CodeFixes\MakeAnonymousFunctionStatic\CSharpMakeAnonymousFunctionStaticCodeFixProvider.cs (1)
42var 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)
118var memberDeclarator = root.FindNode(diagnostic.Location.SourceSpan);
src\roslyn\src\Analyzers\CSharp\CodeFixes\MakeMethodAsynchronous\CSharpMakeMethodAsynchronousCodeFixProvider.cs (3)
46if (diagnostic.Location.SourceTree is null) 49var root = diagnostic.Location.SourceTree.GetRoot(cancellationToken); 50var token = root.FindToken(diagnostic.Location.SourceSpan.Start);
src\roslyn\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\roslyn\src\Analyzers\CSharp\CodeFixes\MakeStructFieldsWritable\CSharpMakeStructFieldsWritableCodeFixProvider.cs (1)
41var diagnosticNode = diagnostic.Location.FindNode(cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\NewLines\ArrowExpressionClausePlacement\ArrowExpressionClausePlacementCodeFixProvider.cs (1)
51var arrowToken = root.FindToken(diagnostic.Location.SourceSpan.Start);
src\roslyn\src\Analyzers\CSharp\CodeFixes\NewLines\ConditionalExpressionPlacement\ConditionalExpressionPlacementCodeFixProvider.cs (1)
51var questionToken = root.FindToken(diagnostic.Location.SourceSpan.Start);
src\roslyn\src\Analyzers\CSharp\CodeFixes\NewLines\ConsecutiveBracePlacement\ConsecutiveBracePlacementCodeFixProvider.cs (1)
67var token = root.FindToken(diagnostic.Location.SourceSpan.Start);
src\roslyn\src\Analyzers\CSharp\CodeFixes\Nullable\CSharpDeclareAsNullableCodeFixProvider.cs (3)
46var node = context.Diagnostics.First().Location.FindNode(getInnermostNodeForTie: true, cancellationToken); 86var node = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken); 94var node = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\QualifyMemberAccess\CSharpQualifyMemberAccessCodeFixProvider.cs (1)
23var node = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\RemoveInKeyword\RemoveInKeywordCodeFixProvider.cs (1)
38var diagnosticSpan = diagnostic.Location.SourceSpan;
src\roslyn\src\Analyzers\CSharp\CodeFixes\RemoveNewModifier\RemoveNewModifierCodeFixProvider.cs (1)
36var diagnosticSpan = diagnostic.Location.SourceSpan;
src\roslyn\src\Analyzers\CSharp\CodeFixes\RemoveUnnecessaryDiscardDesignation\CSharpRemoveUnnecessaryDiscardDesignationCodeFixProvider.cs (1)
41var 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)
44var 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)
42var accessor = (AccessorDeclarationSyntax)diagnostic.Location.FindNode(cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\TransposeRecordKeyword\CSharpTransposeRecordKeywordCodeFixProvider.cs (1)
32recordDeclaration = diagnostic.Location.FindNode(cancellationToken) as RecordDeclarationSyntax;
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseDeconstruction\CSharpUseDeconstructionCodeFixProvider.cs (1)
40var nodesToProcess = diagnostics.SelectAsArray(d => d.Location.FindToken(cancellationToken).GetRequiredParent());
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseDefaultLiteral\CSharpUseDefaultLiteralCodeFixProvider.cs (1)
52d => (DefaultExpressionSyntax)originalRoot.FindNode(d.Location.SourceSpan, getInnermostNodeForTie: true));
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseExplicitArrayInExpressionTree\CSharpUseExplicitArrayInExpressionTreeCodeFixProvider.cs (3)
98var node = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken); 122foreach (var diagnostic in diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start)) 124if (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)
56var node = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseImplicitOrExplicitType\UseImplicitTypeCodeFixProvider.cs (1)
47var typeSyntax = (TypeSyntax)root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseIndexOrRangeOperator\CSharpUseIndexOperatorCodeFixProvider.cs (2)
39foreach (var diagnostic in diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start)) 41var node = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseInterpolatedVerbatimString\CSharpUseInterpolatedVerbatimStringCodeFixProvider.cs (1)
50var verbatimInterpolatedLocation = diagnostic.Location;
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseIsNullCheck\CSharpUseIsNullCheckForCastAndEqualityOperatorCodeFixProvider.cs (2)
42var title = GetTitle(negated, diagnostic.Location.SourceTree!.Options); 57var binary = (BinaryExpressionSyntax)diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken: cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseIsNullCheck\CSharpUseNullCheckOverTypeCheckCodeFixProvider.cs (1)
42var node = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken: cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseNameofInAttribute\CSharpUseNameofInAttributeCodeFixProvider.cs (1)
42var expression = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\UsePatternCombinators\CSharpUsePatternCombinatorsCodeFixProvider.cs (1)
77var location = diagnostic.Location;
src\roslyn\src\Analyzers\CSharp\CodeFixes\UsePatternMatching\CSharpAsAndMemberAccessCodeFixProvider.cs (2)
42foreach (var diagnostic in diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start)) 48var node = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\UsePrimaryConstructor\CSharpUsePrimaryConstructorCodeFixProvider.cs (1)
63if (diagnostic.Location.FindNode(cancellationToken) is not ConstructorDeclarationSyntax constructorDeclaration)
src\roslyn\src\Analyzers\CSharp\CodeFixes\UsePrimaryConstructor\CSharpUsePrimaryConstructorFixAllProvider.cs (2)
50foreach (var diagnostic in diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start)) 52if (diagnostic.Location.FindNode(cancellationToken) is not ConstructorDeclarationSyntax constructorDeclaration)
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseSystemThreadingLock\CSharpUseSystemThreadingLockCodeFixProvider.cs (1)
47if (diagnostic.Location.FindNode(cancellationToken) is not VariableDeclaratorSyntax variableDeclarator)
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseSystemThreadingLock\CSharpUseSystemThreadingLockFixAllProvider.cs (2)
42foreach (var diagnostic in diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start)) 44if (diagnostic.Location.FindNode(cancellationToken) is not VariableDeclaratorSyntax declarator)
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseUtf8StringLiteral\UseUtf8StringLiteralCodeFixProvider.cs (3)
55var node = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken); 81editor.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)
103if (!IsInHole(interpolatedString, error.Location.SourceSpan))
UsePatternMatching\CSharpIsAndCastCheckWithoutNameCodeFixProvider.cs (1)
41var location = diagnostics[0].Location;
Microsoft.CodeAnalysis.CSharp.NetAnalyzers (1)
Microsoft.NetCore.Analyzers\InteropServices\CSharpDisableRuntimeMarshalling.FixAllProvider.cs (1)
42SyntaxNode node = root.FindNode(diagnostic.Location.SourceSpan);
Microsoft.CodeAnalysis.CSharp.Workspaces (2)
Simplification\CSharpSimplificationService.cs (1)
194if (root.FindNode(diagnostic.Location.SourceSpan) is UsingDirectiveSyntax node)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Helpers\RemoveUnnecessaryImports\CSharpUnnecessaryImportsProvider.cs (1)
36root.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)
431var diagnosticSourceTree = _diagnostic?.Location.SourceTree;
CodeFixes\Configuration\ConfigureCodeStyle\ConfigureCodeStyleOptionCodeFixProvider.cs (2)
43diagnostic.Location.SourceTree == null) 48var language = diagnostic.Location.SourceTree.Options.Language;
CodeFixes\Service\CodeFixService.cs (1)
551return GetCodeFixesAsync(document, primaryDiagnostic.Location.SourceSpan, fixer, fixerMetadata,
CodeFixes\Suppression\AbstractSuppressionBatchFixAllProvider.cs (1)
281tuple => tuple.action, tuple => tuple.diagnostic?.Location.SourceSpan.Start ?? 0);
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.cs (1)
210if (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)
64_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;
CodeFixes\Suppression\WrapperCodeFixProvider.cs (2)
26var documentDiagnostics = diagnostics.WhereAsArray(d => d.Location.IsInSource); 33var projectDiagnostics = diagnostics.WhereAsArray(d => !d.Location.IsInSource);
Diagnostics\Service\DocumentAnalysisExecutor.cs (1)
351bool shouldInclude(Diagnostic d) => span.Value.IntersectsWith(d.Location.SourceSpan) && !IsUnusedImportDiagnostic(d);
Diagnostics\Service\DocumentAnalysisExecutor_Helpers.cs (4)
128await VerifyDiagnosticLocationAsync(diagnostic.Id, diagnostic.Location).ConfigureAwait(false); 226return x.Id == y.Id && x.Location == y.Location; 234return Hash.Combine(obj.Id.GetHashCode(), obj.Location.GetHashCode());
EditAndContinue\EmitSolutionUpdateResults.cs (2)
181Debug.Assert(SyntaxError.Location.SourceTree != null); 182return DiagnosticData.Create(SyntaxError, Solution.GetRequiredDocument(SyntaxError.Location.SourceTree));
EditAndContinue\ProjectDiagnostics.cs (1)
26var document = solution.GetDocument(diagnostic.Location.SourceTree);
EmbeddedLanguages\Json\LanguageServices\AbstractJsonDetectionCodeFixProvider.cs (1)
43var stringLiteral = diagnostic.Location.FindToken(cancellationToken);
PreferFrameworkType\PreferFrameworkTypeCodeFixProvider.cs (1)
46var node = diagnostic.Location.FindNode(
RemoveUnusedVariable\AbstractRemoveUnusedVariableCodeFixProvider.cs (3)
45var node = root.FindNode(diagnostic.Location.SourceSpan); 68var token = diagnostic.Location.FindToken(cancellationToken); 69var node = root.FindNode(diagnostic.Location.SourceSpan);
SimplifyTypeNames\AbstractSimplifyTypeNamesCodeFixProvider.cs (1)
102root, model, diagnostic.Location.SourceSpan,
src\roslyn\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\roslyn\src\Analyzers\Core\CodeFixes\AddAnonymousTypeMemberName\AbstractAddAnonymousTypeMemberNameCodeFixProvider.cs (1)
55var span = diagnostic.Location.SourceSpan;
src\roslyn\src\Analyzers\Core\CodeFixes\AddExplicitCast\AbstractAddExplicitCastCodeFixProvider.cs (2)
74var spanNode = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true).GetAncestorOrThis<TExpressionSyntax>(); 218d => root.FindNode(d.Location.SourceSpan, getInnermostNodeForTie: true)
src\roslyn\src\Analyzers\Core\CodeFixes\AddObsoleteAttribute\AbstractAddObsoleteAttributeCodeFixProvider.cs (2)
45var node = context.Diagnostics[0].Location.FindNode(cancellationToken); 81var containers = diagnostics.Select(d => GetContainer(root, d.Location.FindNode(cancellationToken)))
src\roslyn\src\Analyzers\Core\CodeFixes\AddParameter\AbstractAddParameterCodeFixProvider.cs (1)
70var 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(); 416var position = diagnostic.Location.SourceSpan.Start;
src\roslyn\src\Analyzers\Core\CodeFixes\ConvertTypeOfToNameOf\AbstractConvertTypeOfToNameOfCodeFixProvider.cs (1)
40if (editor.OriginalRoot.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true) is not TMemberAccessExpressionSyntax node)
src\roslyn\src\Analyzers\Core\CodeFixes\ForEachCast\AbstractForEachCastCodeFixProvider.cs (1)
46var node = editor.OriginalRoot.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
src\roslyn\src\Analyzers\Core\CodeFixes\Formatting\FormattingCodeFixProvider.cs (1)
74var diagnosticSpan = diagnostic.Location.SourceSpan;
src\roslyn\src\Analyzers\Core\CodeFixes\GenerateDefaultConstructors\AbstractGenerateDefaultConstructorCodeFixProvider.cs (1)
30if (!headerFacts.IsOnTypeHeader(root, diagnostic.Location.SourceSpan.Start, fullHeader: true, out var typeDecl))
src\roslyn\src\Analyzers\Core\CodeFixes\MakeFieldReadonly\AbstractMakeFieldReadonlyCodeFixProvider.cs (1)
46var diagnosticSpan = diagnostic.Location.SourceSpan;
src\roslyn\src\Analyzers\Core\CodeFixes\MakeMemberStatic\AbstractMakeMemberStaticCodeFixProvider.cs (2)
22TryGetMemberDeclaration(context.Diagnostics[0].Location.FindNode(context.CancellationToken), out _)) 33var declaration = diagnostics[i].Location.FindNode(cancellationToken);
src\roslyn\src\Analyzers\Core\CodeFixes\MakeMethodAsynchronous\AbstractMakeMethodAsynchronousCodeFixProvider.cs (1)
153var token = diagnostic.Location.FindToken(cancellationToken);
src\roslyn\src\Analyzers\Core\CodeFixes\MakeMethodSynchronous\AbstractMakeMethodSynchronousCodeFixProvider.cs (1)
34var token = diagnostic.Location.FindToken(cancellationToken);
src\roslyn\src\Analyzers\Core\CodeFixes\MakeTypeAbstract\AbstractMakeTypeAbstractCodeFixProvider.cs (2)
22if (IsValidRefactoringContext(context.Diagnostics[0].Location?.FindNode(context.CancellationToken), out _)) 33if (IsValidRefactoringContext(diagnostics[i].Location?.FindNode(cancellationToken), out var typeDeclaration))
src\roslyn\src\Analyzers\Core\CodeFixes\MakeTypePartial\AbstractMakeTypePartialCodeFixProvider.cs (1)
31var 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)
55var memberDeclaration = diagnostic.Location.FindNode(cancellationToken);
src\roslyn\src\Analyzers\Core\CodeFixes\RemoveAsyncModifier\AbstractRemoveAsyncModifierCodeFixProvider.cs (3)
35var token = diagnostic.Location.FindToken(cancellationToken); 64foreach (var diagnostic in diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start)) 66var token = diagnostic.Location.FindToken(cancellationToken);
src\roslyn\src\Analyzers\Core\CodeFixes\RemoveUnnecessarySuppressions\RemoveUnnecessaryAttributeSuppressionsCodeFixProvider.cs (2)
32if (root.FindNode(diagnostic.Location.SourceSpan) != null) 43var node = editor.OriginalRoot.FindNode(diagnostic.Location.SourceSpan);
src\roslyn\src\Analyzers\Core\CodeFixes\RemoveUnnecessarySuppressions\RemoveUnnecessaryPragmaSuppressionsCodeFixProvider.cs (3)
37if (root.FindNode(diagnostic.Location.SourceSpan) is { } node && syntaxFacts.IsAttribute(node) || 38root.FindTrivia(diagnostic.Location.SourceSpan.Start).HasStructure) 56RemoveNode(diagnostic.Location, editor, processedNodes, syntaxFacts);
src\roslyn\src\Analyzers\Core\CodeFixes\RemoveUnusedMembers\AbstractRemoveUnusedMembersCodeFixProvider.cs (1)
54var diagnosticNode = diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken);
src\roslyn\src\Analyzers\Core\CodeFixes\RemoveUnusedParametersAndValues\AbstractRemoveUnusedValuesCodeFixProvider.cs (6)
208return syntaxFacts.IsForEachStatement(diagnostic.Location.FindNode(getInnermostNodeForTie: true, cancellationToken)); 269return diagnostics.GroupBy(d => syntaxFacts.GetContainingMemberDeclaration(root, d.Location.SourceSpan.Start) ?? root); 362diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start), 372diagnostics.OrderBy(d => d.Location.SourceSpan.Start), 401var expressionStatement = root.FindNode(diagnostic.Location.SourceSpan).FirstAncestorOrSelf<TExpressionStatementSyntax>(); 677var node = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
src\roslyn\src\Analyzers\Core\CodeFixes\SimplifyBooleanExpression\SimplifyConditionalCodeFixProvider.cs (2)
50diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start).ToImmutableArray(), 51d => d.Location.FindNode(getInnermostNodeForTie: true, cancellationToken),
src\roslyn\src\Analyzers\Core\CodeFixes\SimplifyLinqExpression\SimplifyLinqExpressionCodeFixProvider.cs (2)
41foreach (var diagnostic in diagnostics.OrderByDescending(diagnostics => diagnostics.Location.SourceSpan.Start)) 43var invocation = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
src\roslyn\src\Analyzers\Core\CodeFixes\UpdateLegacySuppressions\UpdateLegacySuppressionsCodeFixProvider.cs (2)
33root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true) != null) 44var node = editor.OriginalRoot.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
src\roslyn\src\Analyzers\Core\CodeFixes\UseExplicitTupleName\UseExplicitTupleNameCodeFixProvider.cs (1)
39var oldNameNode = diagnostic.Location.FindNode(
src\roslyn\src\Analyzers\Core\CodeFixes\UseInferredMemberName\AbstractUseInferredMemberNameCodeFixProvider.cs (1)
34var node = root.FindNode(diagnostic.Location.SourceSpan);
src\roslyn\src\Analyzers\Core\CodeFixes\UseIsNullCheck\AbstractUseIsNullForReferenceEqualsCodeFixProvider.cs (2)
40var title = GetTitle(negated, diagnostic.Location.SourceTree!.Options); 54foreach (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.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)
36var node = diagnostic.Location.SourceTree?.GetRoot(context.CancellationToken).FindNode(diagnostic.Location.SourceSpan);
Microsoft.CodeAnalysis.Scripting (2)
Hosting\CommandLine\CommandLineRunner.cs (2)
384return (delta != 0) ? delta : d1.Location.SourceSpan.Start - d2.Location.SourceSpan.Start;
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)
325newDiagnostics.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\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Helpers\RemoveUnnecessaryImports\VisualBasicUnnecessaryImportsProvider.vb (2)
37Dim node = TryCast(root.FindNode(diagnostic.Location.SourceSpan), ImportsClauseSyntax) 44Dim node = TryCast(root.FindNode(diagnostic.Location.SourceSpan), ImportsStatementSyntax)
Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes (3)
src\roslyn\src\Analyzers\VisualBasic\CodeFixes\GenerateParameterizedMember\GenerateParameterizedMemberCodeFixProvider.vb (1)
61Dim diagnosticSpan = diagnostic.Location.SourceSpan
src\roslyn\src\Analyzers\VisualBasic\CodeFixes\QualifyMemberAccess\VisualBasicQualifyMemberAccessCodeFixProvider.vb (1)
28Dim node = diagnostic.Location.FindNode(True, cancellationToken)
src\roslyn\src\Analyzers\VisualBasic\CodeFixes\SimplifyObjectCreation\VisualBasicSimplifyObjectCreationCodeFixProvider.vb (1)
37Dim 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) 59Dim node = diagnostic.Location.FindNode(cancellationToken)
src\roslyn\src\Analyzers\VisualBasic\CodeFixes\GenerateParameterizedMember\GenerateParameterizedMemberCodeFixProvider.vb (1)
61Dim diagnosticSpan = diagnostic.Location.SourceSpan
src\roslyn\src\Analyzers\VisualBasic\CodeFixes\QualifyMemberAccess\VisualBasicQualifyMemberAccessCodeFixProvider.vb (1)
28Dim node = diagnostic.Location.FindNode(True, cancellationToken)
src\roslyn\src\Analyzers\VisualBasic\CodeFixes\SimplifyObjectCreation\VisualBasicSimplifyObjectCreationCodeFixProvider.vb (1)
37Dim node = DirectCast(root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie:=True), VariableDeclaratorSyntax)
Microsoft.CodeAnalysis.VisualBasic.Workspaces (3)
Simplification\VisualBasicSimplificationService.vb (1)
170Dim node = root.FindNode(diagnostic.Location.SourceSpan)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Helpers\RemoveUnnecessaryImports\VisualBasicUnnecessaryImportsProvider.vb (2)
37Dim node = TryCast(root.FindNode(diagnostic.Location.SourceSpan), ImportsClauseSyntax) 44Dim 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, 250if (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) 147var document = solution.GetRequiredDocument(diagnostic.Location.SourceTree!); 155var 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)
69var diagnosticSpan = diagnosticsToFix.First().Value.FirstOrDefault()?.Location.SourceSpan;
Diagnostics\DiagnosticAnalysisResultBuilder.cs (7)
53switch (diagnostic.Location.Kind) 57var diagnosticDocumentId = Project.GetDocumentForExternalLocation(diagnostic.Location); 112=> AddDiagnostic(ref _lazySemanticLocals, diagnostic.Location.SourceTree, diagnostic); 130switch (diagnostic.Location.Kind) 133var diagnosticDocumentId = Project.GetDocumentForExternalLocation(diagnostic.Location); 150var diagnosticTree = diagnostic.Location.SourceTree; 175throw ExceptionUtilities.UnexpectedValue(diagnostic.Location.Kind);
Diagnostics\DiagnosticData.cs (4)
212var document = project.GetDocument(diagnostic.Location.SourceTree); 216if (diagnostic.Location.Kind == LocationKind.ExternalFile) 218document = project.Documents.FirstOrDefault(d => d.FilePath == diagnostic.Location.GetLineSpan().Path); 231var location = CreateLocation(document, diagnostic.Location);
Diagnostics\Extensions.cs (10)
223var diagnostics = additionalPragmaSuppressionDiagnostics.WhereAsArray(d => d.Location.SourceTree == treeToAnalyze); 230foreach (var group in additionalPragmaSuppressionDiagnostics.GroupBy(d => d.Location.SourceTree!)) 283Debug.Assert(diagnostics.All(d => d.Location.SourceTree == tree)); 295Debug.Assert(diagnostics.All(d => d.Location.SourceTree == tree)); 322filterSpan.HasValue && !filterSpan.Value.IntersectsWith(diagnostic.Location.SourceSpan)); 440if (span.HasValue && !span.Value.IntersectsWith(diagnostic.Location.SourceSpan)) 451if (diagnostic.Location.SourceTree != null) 453return targetTextDocument.Project.GetDocument(diagnostic.Location.SourceTree) == targetTextDocument; 455else if (diagnostic.Location.Kind == LocationKind.ExternalFile) 457var lineSpan = diagnostic.Location.GetLineSpan();
Diagnostics\GeneratorDiagnosticsPlaceholderAnalyzer.cs (1)
42else if (diagnostic.Location.Kind == LocationKind.None &&
Log\WorkspaceStructureLogger.cs (1)
193new XAttribute("path", SanitizePath(diagnostic.Location.GetLineSpan().Path)),
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeFixes\FixAllContextHelper.cs (1)
140foreach (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)
42var diagnosticFilePath = PathUtilities.GetDirectoryName(diagnostic?.Location.SourceTree?.FilePath ?? project.FilePath);
Microsoft.Extensions.Logging.Generators (2)
LoggerMessageGenerator.Roslyn4.0.cs (2)
121if ((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)
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.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.MetadataExtractor.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\runtime\src\libraries\System.Runtime.InteropServices\gen\Common\ConvertToSourceGeneratedInteropFixer.cs (3)
195DocumentId documentId = solutionEditor.OriginalSolution.GetDocumentId(diagnostic.Location.SourceTree)!; 196SyntaxNode root = await diagnostic.Location.SourceTree.GetRootAsync(ct).ConfigureAwait(false); 198SyntaxNode 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\runtime\src\libraries\System.Runtime.InteropServices\gen\Common\ConvertToSourceGeneratedInteropFixer.cs (3)
195DocumentId documentId = solutionEditor.OriginalSolution.GetDocumentId(diagnostic.Location.SourceTree)!; 196SyntaxNode root = await diagnostic.Location.SourceTree.GetRootAsync(ct).ConfigureAwait(false); 198SyntaxNode 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);
Roslyn.Diagnostics.Analyzers (19)
ExportedPartsShouldHaveImportingConstructorCodeFixProvider.cs (3)
50createChangedDocument = cancellationToken => AddExplicitImportingConstructorAsync(context.Document, diagnostic.Location.SourceSpan, cancellationToken); 55createChangedDocument = cancellationToken => MakeConstructorPublicAsync(context.Document, diagnostic.Location.SourceSpan, cancellationToken); 60createChangedDocument = cancellationToken => AddImportingConstructorAttributeAsync(context.Document, diagnostic.Location.SourceSpan, cancellationToken);
ImportingConstructorShouldBeObsoleteCodeFixProvider.cs (5)
47createChangedDocument = cancellationToken => AddObsoleteAttributeAsync(context.Document, diagnostic.Location.SourceSpan, cancellationToken); 52createChangedDocument = cancellationToken => AddDescriptionAndErrorAsync(context.Document, diagnostic.Location.SourceSpan, cancellationToken); 57createChangedDocument = cancellationToken => UpdateDescriptionAsync(context.Document, diagnostic.Location.SourceSpan, cancellationToken); 62createChangedDocument = cancellationToken => AddErrorAsync(context.Document, diagnostic.Location.SourceSpan, cancellationToken); 67createChangedDocument = cancellationToken => SetErrorToTrueAsync(context.Document, diagnostic.Location.SourceSpan, cancellationToken);
NamedTypeFullNameNotNullSuppressor.cs (2)
41if (diagnostic.Location.SourceTree is not { } tree) 47var node = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
PartsExportedWithMEFv2MustBeMarkedAsShared.Fixer.cs (1)
46if (TryGetDeclaration(root!.FindNode(diagnostic.Location.SourceSpan), out var declaration))
RelaxTestNamingSuppressor.cs (2)
44if (diagnostic.Location.SourceTree is not { } tree) 50var node = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeFixes\FixAllContextHelper.cs (1)
140foreach (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)
42var diagnosticFilePath = PathUtilities.GetDirectoryName(diagnostic?.Location.SourceTree?.FilePath ?? project.FilePath);
TestExportsShouldNotBeDiscoverableCodeFixProvider.cs (1)
42cancellationToken => AddPartNotDiscoverableAttributeAsync(context.Document, diagnostic.Location.SourceSpan, cancellationToken),
Roslyn.Diagnostics.CSharp.Analyzers (5)
CSharpAvoidOptSuffixForNullableEnableCodeCodeFixProvider.cs (2)
38var variable = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true); 54if (semanticModel.LookupSymbols(diagnostic.Location.SourceSpan.Start, variableSymbol.ContainingType, newName).IsEmpty)
CSharpDoNotUseDebugAssertForInterpolatedStringsFixer.cs (1)
50ct => ReplaceWithDebugAssertAsync(context.Document, diagnostic.Location, roslynDebugSymbol, ct),
PreferNullLiteralCodeFixProvider.cs (1)
40cancellationToken => ReplaceWithNullLiteralAsync(context.Document, diagnostic.Location, cancellationToken),
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Helpers\RemoveUnnecessaryImports\CSharpUnnecessaryImportsProvider.cs (1)
36root.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)
39TextSpan diagnosticSpan = diagnostic.Location.SourceSpan;