2 overrides of SourceSpan
Microsoft.CodeAnalysis (2)
Diagnostic\ExternalFileLocation.cs (1)
33public override TextSpan SourceSpan
Diagnostic\SourceLocation.cs (1)
64public override TextSpan SourceSpan
626 references to SourceSpan
AnalyzerRunner (2)
DiagnosticAnalyzerRunner.cs (2)
206.ThenBy(tuple => tuple.Item2.Location.SourceSpan.Start) 207.ThenBy(tuple => tuple.Item2.Location.SourceSpan.End);
ConfigurationSchemaGenerator (1)
RuntimeSource\SourceGenerators\DiagnosticInfo.cs (1)
34=> Location.Create(location.SourceTree?.FilePath ?? "", location.SourceSpan, location.GetLineSpan().Span);
ILLink.CodeFixProvider (2)
BaseAttributeCodeFixProvider.cs (1)
42 SyntaxNode targetNode = root.FindNode (diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
DynamicallyAccessedMembersCodeFixProvider.cs (1)
103 if (root.FindNode (diagnostic.AdditionalLocations[0].SourceSpan, getInnermostNodeForTie: true) is not SyntaxNode targetNode)
Microsoft.Analyzers.Extra.Tests (6)
Resources\RoslynTestUtils.cs (6)
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)
Microsoft.Analyzers.Local.Tests (8)
InternalReferencedInPublicDocAnalyzerTests.cs (2)
471var text = source.Substring(location.SourceSpan.Start, location.SourceSpan.Length);
Resources\RoslynTestUtils.cs (6)
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)
Microsoft.AspNetCore.Analyzer.Testing (2)
DiagnosticAnalyzerRunner.cs (1)
113return diagnostics.OrderBy(d => d.Location.SourceSpan.Start).ToArray();
DiagnosticVerifier.cs (1)
131return diagnostics.OrderBy(d => d.Location.SourceSpan.Start).ToArray();
Microsoft.AspNetCore.App.Analyzers (6)
RouteEmbeddedLanguage\FrameworkParametersCompletionProvider.cs (2)
515? parentOpt.Value.GetLocation().SourceSpan.Start 518? parentOpt.Value.GetLocation().SourceSpan.End
WebApplicationBuilder\WebApplicationBuilderAnalyzer.cs (4)
294var fullSyntaxLength = location.SourceSpan.Length; 295var chainAndTriviaLength = methodLocation.SourceSpan.Start - location.SourceSpan.Start; 298methodLocation.SourceSpan.Start,
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.Analyzers.Tests (3)
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 (1)
97return diagnostics.OrderBy(d => d.Location.SourceSpan.Start).ToArray();
Microsoft.AspNetCore.Components.SdkAnalyzers (1)
ComponentParametersShouldBePublicCodeFixProvider.cs (1)
35var diagnosticSpan = diagnostic.Location.SourceSpan;
Microsoft.AspNetCore.Components.SdkAnalyzers.Tests (3)
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 (1)
97return diagnostics.OrderBy(d => d.Location.SourceSpan.Start).ToArray();
Microsoft.AspNetCore.Http.RequestDelegateGenerator (1)
RequestDelegateGeneratorSuppressor.cs (1)
50|| sourceTree.GetRoot().FindNode(location.SourceSpan) is not InvocationExpressionSyntax node
Microsoft.AspNetCore.Mvc.Api.Analyzers (1)
AddResponseTypeAttributeCodeFixAction.cs (1)
131var diagnosticNode = root.FindNode(_diagnostic.Location.SourceSpan);
Microsoft.CodeAnalysis (10)
Diagnostic\Diagnostic.cs (1)
523return !filterSpan.HasValue || filterSpan.GetValueOrDefault().IntersectsWith(location.SourceSpan);
Diagnostic\Location.cs (1)
100result += "(" + this.SourceTree?.FilePath + this.SourceSpan + ")";
DiagnosticAnalyzer\AnalysisScope.cs (1)
316return ShouldInclude(diagnostic.Location.SourceSpan);
DiagnosticAnalyzer\AnalyzerDriver.cs (2)
1255if (IsGeneratedOrHiddenCodeLocation(location.SourceTree, location.SourceSpan, cancellationToken)) 1267for (var node = location.SourceTree.GetRoot(cancellationToken).FindNode(location.SourceSpan, getInnermostNodeForTie: true);
DiagnosticAnalyzer\AnalyzerExecutor.AnalyzerDiagnosticReporter.cs (1)
113(!FilterSpanForLocalDiagnostics.HasValue || FilterSpanForLocalDiagnostics.Value.IntersectsWith(diagnostic.Location.SourceSpan)))
DiagnosticAnalyzer\AnalyzerExecutor.cs (1)
1411if (diagnostic.Location.SourceSpan.IntersectsWith(syntax.FullSpan))
DiagnosticAnalyzer\DiagnosticAnalysisContextHelpers.cs (2)
102if (location.SourceSpan.End > location.SourceTree.Length) 105throw new ArgumentException(string.Format(CodeAnalysisResources.InvalidDiagnosticSpanReported, id, location.SourceSpan, location.SourceTree.FilePath), "diagnostic");
DiagnosticAnalyzer\SuppressMessageAttributeState.cs (1)
166for (var node = location.SourceTree.GetRoot().FindNode(location.SourceSpan, getInnermostNodeForTie: true);
Microsoft.CodeAnalysis.CodeStyle (17)
src\Analyzers\Core\Analyzers\RemoveUnnecessaryParentheses\AbstractRemoveUnnecessaryParenthesesDiagnosticAnalyzer.cs (3)
132var expressionFirstLine = lines.GetLineFromPosition(parenthesizedExpressionLocation.SourceSpan.Start); 134var textSpanEndPosition = Math.Min(parenthesizedExpressionLocation.SourceSpan.End, expressionFirstLine.Span.End); 135return Location.Create(parenthesizedExpression.SyntaxTree, TextSpan.FromBounds(parenthesizedExpressionLocation.SourceSpan.Start, textSpanEndPosition));
src\Analyzers\Core\Analyzers\RemoveUnnecessarySuppressions\AbstractRemoveUnnecessaryPragmaSuppressionsDiagnosticAnalyzer.cs (1)
565if (pragma.Span.End <= diagnostic.Location.SourceSpan.Start)
src\Analyzers\Core\Analyzers\RemoveUnusedMembers\AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs (1)
564r => r.SyntaxTree == diagnosticLocation.SourceTree && r.Span.Contains(diagnosticLocation.SourceSpan));
src\Analyzers\Core\Analyzers\UseSystemHashCode\UseSystemHashCodeDiagnosticAnalyzer.cs (1)
47if (!context.ShouldAnalyzeSpan(diagnosticLocation.SourceSpan))
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\AnalysisContextExtensions.cs (2)
55=> location.SourceTree != null && context.ShouldAnalyzeSpan(location.SourceSpan, location.SourceTree); 75=> location.SourceTree != null && context.ShouldAnalyzeSpan(location.SourceSpan, location.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\LocationExtensions.cs (7)
20=> location.GetSourceTreeOrThrow().GetRoot(cancellationToken).FindToken(location.SourceSpan.Start); 23=> location.GetSourceTreeOrThrow().GetRoot(cancellationToken).FindNode(location.SourceSpan); 26=> location.GetSourceTreeOrThrow().GetRoot(cancellationToken).FindNode(location.SourceSpan, getInnermostNodeForTie: getInnermostNodeForTie); 29=> location.GetSourceTreeOrThrow().GetRoot(cancellationToken).FindNode(location.SourceSpan, findInsideTrivia, getInnermostNodeForTie); 39return !(tree == null || tree.IsHiddenPosition(loc.SourceSpan.Start)); 45return loc1.SourceTree == loc2.SourceTree && loc1.SourceSpan.IntersectsWith(loc2.SourceSpan);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyWriter.cs (2)
264WriteInteger(location.SourceSpan.Start); 265WriteInteger(location.SourceSpan.Length);
Microsoft.CodeAnalysis.CodeStyle.Fixes (48)
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\AddParameter\AbstractAddParameterCodeFixProvider.cs (1)
69var 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\MakeTypePartial\AbstractMakeTypePartialCodeFixProvider.cs (1)
37var declaration = syntaxRoot.FindNode(diagnostic.Location.SourceSpan);
src\Analyzers\Core\CodeFixes\NewLines\MultipleBlankLines\AbstractMultipleBlankLinesCodeFixProvider.cs (1)
53var token = root.FindToken(diagnostic.AdditionalLocations[0].SourceSpan.Start);
src\Analyzers\Core\CodeFixes\RemoveAsyncModifier\AbstractRemoveAsyncModifierCodeFixProvider.cs (1)
75foreach (var diagnostic in diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start))
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 (4)
39if (root.FindNode(diagnostic.Location.SourceSpan) is { } node && syntaxFacts.IsAttribute(node) || 40root.FindTrivia(diagnostic.Location.SourceSpan.Start).HasStructure) 76if (editor.OriginalRoot.FindNode(location.SourceSpan) is { } attribute && 85node = editor.OriginalRoot.FindTrivia(location.SourceSpan.Start).GetStructure()!;
src\Analyzers\Core\CodeFixes\RemoveUnusedParametersAndValues\AbstractRemoveUnusedValuesCodeFixProvider.cs (5)
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\Analyzers\Core\CodeFixes\SimplifyBooleanExpression\SimplifyConditionalCodeFixProvider.cs (1)
51diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start).ToImmutableArray(),
src\Analyzers\Core\CodeFixes\SimplifyLinqExpression\SimplifyLinqExpressionCodeFixProvider.cs (2)
42foreach (var diagnostic in diagnostics.OrderByDescending(diagnostics => diagnostics.Location.SourceSpan.Start)) 44var invocation = 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\UseCoalesceExpression\UseCoalesceExpressionForNullableTernaryConditionalCheckCodeFixProvider.cs (3)
51var conditionalExpression = root.FindNode(diagnostic.AdditionalLocations[0].SourceSpan, getInnermostNodeForTie: true); 52var conditionExpression = root.FindNode(diagnostic.AdditionalLocations[1].SourceSpan); 53var whenPart = root.FindNode(diagnostic.AdditionalLocations[2].SourceSpan);
src\Analyzers\Core\CodeFixes\UseCoalesceExpression\UseCoalesceExpressionForTernaryConditionalCheckCodeFixProvider.cs (3)
63var conditionalExpression = root.FindNode(diagnostic.AdditionalLocations[0].SourceSpan, getInnermostNodeForTie: true); 64var conditionalPartHigh = root.FindNode(diagnostic.AdditionalLocations[1].SourceSpan); 65var whenPart = root.FindNode(diagnostic.AdditionalLocations[2].SourceSpan);
src\Analyzers\Core\CodeFixes\UseInferredMemberName\AbstractUseInferredMemberNameCodeFixProvider.cs (1)
39var node = root.FindNode(diagnostic.Location.SourceSpan);
src\Analyzers\Core\CodeFixes\UseIsNullCheck\AbstractUseIsNullForReferenceEqualsCodeFixProvider.cs (1)
59foreach (var diagnostic in diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start))
src\Analyzers\Core\CodeFixes\UseNullPropagation\AbstractUseNullPropagationCodeFixProvider.cs (5)
88var conditionalExpressionOrIfStatement = root.FindNode(diagnostic.AdditionalLocations[0].SourceSpan, getInnermostNodeForTie: true); 113var conditionalPart = root.FindNode(diagnostic.AdditionalLocations[1].SourceSpan, getInnermostNodeForTie: true); 114var whenPart = root.FindNode(diagnostic.AdditionalLocations[2].SourceSpan, getInnermostNodeForTie: true); 170var whenTrueStatement = (TStatementSyntax)root.FindNode(diagnostic.AdditionalLocations[1].SourceSpan); 171var match = (TExpressionSyntax)root.FindNode(diagnostic.AdditionalLocations[2].SourceSpan, getInnermostNodeForTie: true);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeFixes\ForkingSyntaxEditorBasedCodeFixProvider.cs (1)
69diagnostic.AdditionalLocations[0].SourceSpan, getInnermostNodeForTie: true);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationHelpers.cs (2)
205var afterMember = declarationList.LastOrDefault(m => m.SpanStart <= info.Context.AfterThisLocation.SourceSpan.Start); 221var beforeMember = declarationList.FirstOrDefault(m => m.Span.End >= info.Context.BeforeThisLocation.SourceSpan.End);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\FindSymbols\LinkedFileReferenceLocationEqualityComparer.cs (3)
26return x.Location.SourceSpan == y.Location.SourceSpan; 30=> obj.Location.SourceSpan.GetHashCode();
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\MoveDeclarationNearReference\AbstractMoveDeclarationNearReferenceService.State.cs (1)
107let token = syntaxRoot.FindToken(r.Location.SourceSpan.Start)
Microsoft.CodeAnalysis.CSharp (36)
Binder\Binder_Invocation.cs (2)
1627int line = callerSourceLocation.SourceTree.GetDisplayLineNumber(callerSourceLocation.SourceSpan); 1632string path = callerSourceLocation.SourceTree.GetDisplayPath(callerSourceLocation.SourceSpan, Compilation.Options.SourceReferenceResolver);
Binder\Binder_Symbols.cs (2)
1896if (containerResult == 0 && la.SourceTree == lb.SourceTree) return lb.SourceSpan.Start - la.SourceSpan.Start;
Binder\BinderFactory.BinderFactoryVisitor.cs (1)
643return (location.SourceTree == syntaxTree) && span.Contains(location.SourceSpan);
Binder\LocalScopeBinder.cs (2)
513if (declaredInThisScope && newLocation.SourceSpan.Start >= local.GetFirstLocation().SourceSpan.Start)
Compilation\CSharpCompilation.cs (2)
4552return loc1.SourceSpan.Start - loc2.SourceSpan.Start;
Compilation\CSharpDiagnosticFilter.cs (1)
155var position = location.SourceSpan.Start;
Compilation\CSharpSemanticModel.cs (1)
3236if (location.SourceTree == this.SyntaxTree && parameter.Span.Contains(location.SourceSpan))
Compilation\SyntaxTreeSemanticModel.cs (5)
1813if (loc.IsInSource && loc.SourceTree == this.SyntaxTree && declarationSpan.Contains(loc.SourceSpan)) 1936if (alias.Alias.GetFirstLocation().SourceSpan == declarationSyntax.Alias.Name.Span) 1969if (alias.Alias.GetFirstLocation().SourceSpan == declarationSyntax.Identifier.Span) 2180if (location.SourceTree == this.SyntaxTree && parameter.Span.Contains(location.SourceSpan)) 2400var position = CheckAndAdjustPosition(location.SourceSpan.Start);
FlowAnalysis\ControlFlowPass.cs (2)
342var sourceStart = sourceLocation.SourceSpan.Start; 343var targetStart = node.Label.GetFirstLocation().SourceSpan.Start;
FlowAnalysis\DataFlowsInWalker.cs (1)
95if (IsInside && !RegionContains(node.RangeVariableSymbol.GetFirstLocation().SourceSpan))
FlowAnalysis\DataFlowsOutWalker.cs (1)
233((param.RefKind != RefKind.None && !param.IsImplicitlyDeclared && !RegionContains(param.GetFirstLocation().SourceSpan)) ||
FlowAnalysis\DefiniteAssignment.cs (1)
1217(symbol.TryGetFirstLocation() is var location && (location is null || node.Span.End < location.SourceSpan.Start)))
Symbols\LexicalSortKey.cs (1)
75: this(location.SourceTree, location.SourceSpan.Start, compilation)
Symbols\NamespaceOrTypeSymbol.cs (1)
227if (loc.IsInSource && loc.SourceTree == syntax.SyntaxTree && syntax.Span.Contains(loc.SourceSpan))
Symbols\RangeVariableSymbol.cs (1)
62SyntaxToken token = _location.SourceTree.GetRoot().FindToken(_location.SourceSpan.Start);
Symbols\Source\SourceMemberContainerSymbol.cs (1)
1119if (declaration.Declarations.Length >= 1 && position == declaration.Declarations[0].Location.SourceSpan.Start)
Symbols\Source\SourceMemberContainerSymbol_ImplementationChecks.cs (2)
1764if (GetImplementsLocationOrFallback(interface1).SourceSpan.Start > GetImplementsLocationOrFallback(interface2).SourceSpan.Start)
Symbols\Symbol.cs (7)
454if (loc.IsInSource && loc.SourceTree == tree && declarationSpan.Contains(loc.SourceSpan)) 456wasZeroWidthMatch = loc.SourceSpan.IsEmpty && loc.SourceSpan.End == declarationSpan.Start; 511if (location.SourceSpan.Length != 0) 513SyntaxToken token = location.SourceTree.GetRoot().FindToken(location.SourceSpan.Start); 531foreach (var descendant in parent.DescendantNodesAndSelf(c => c.Location.SourceSpan.Contains(location.SourceSpan))) 533if (descendant is TNode && descendant.Location.SourceSpan.Contains(location.SourceSpan))
Symbols\Symbol_Attributes.cs (2)
498argumentLocation.SourceSpan.Contains(location.SourceSpan))
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 (33)
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)
45var node = root.FindNode(diagnostic.Location.SourceSpan); 75var node = editor.OriginalRoot.FindNode(diagnostic.Location.SourceSpan);
src\Analyzers\CSharp\CodeFixes\ConditionalExpressionInStringInterpolation\CSharpAddParenthesesAroundConditionalExpressionInInterpolatedStringCodeFixProvider.cs (1)
39var diagnosticSpan = diagnostic.Location.SourceSpan;
src\Analyzers\CSharp\CodeFixes\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionCodeFixProvider.cs (2)
61if (spans.Any((s, nodeSpan) => s.Contains(nodeSpan), switchLocation.SourceSpan)) 67spans.Add(switchLocation.SourceSpan);
src\Analyzers\CSharp\CodeFixes\DisambiguateSameVariable\CSharpDisambiguateSameVariableCodeFixProvider.cs (1)
60var span = diagnostic.Location.SourceSpan;
src\Analyzers\CSharp\CodeFixes\HideBase\HideBaseCodeFixProvider.cs (1)
33var diagnosticSpan = diagnostic.Location.SourceSpan;
src\Analyzers\CSharp\CodeFixes\MakeLocalFunctionStatic\MakeLocalFunctionStaticCodeFixHelper.cs (1)
132var referenceSpan = location.Location.SourceSpan;
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 (1)
49var token = root.FindToken(diagnostic.Location.SourceSpan.Start);
src\Analyzers\CSharp\CodeFixes\MakeStatementAsynchronous\CSharpMakeStatementAsynchronousCodeFixProvider.cs (1)
36var node = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
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\NewLines\EmbeddedStatementPlacement\EmbeddedStatementPlacementCodeFixProvider.cs (1)
70var node = root.FindNode(diagnostic.AdditionalLocations[0].SourceSpan);
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\UseExplicitArrayInExpressionTree\CSharpUseExplicitArrayInExpressionTreeCodeFixProvider.cs (1)
122foreach (var diagnostic in diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start))
src\Analyzers\CSharp\CodeFixes\UseImplicitObjectCreation\CSharpUseImplicitObjectCreationCodeFixProvider.cs (1)
50.OrderBy(d => d.Location.SourceSpan.End)
src\Analyzers\CSharp\CodeFixes\UseImplicitOrExplicitType\UseExplicitTypeCodeFixProvider.cs (1)
49var 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 (1)
40foreach (var diagnostic in diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start))
src\Analyzers\CSharp\CodeFixes\UsePatternCombinators\CSharpUsePatternCombinatorsCodeFixProvider.cs (1)
80var expression = editor.OriginalRoot.FindNode(location.SourceSpan, getInnermostNodeForTie: true);
src\Analyzers\CSharp\CodeFixes\UsePatternMatching\CSharpAsAndMemberAccessCodeFixProvider.cs (1)
43foreach (var diagnostic in diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start))
src\Analyzers\CSharp\CodeFixes\UseThrowExpression\UseThrowExpressionCodeFixProvider.cs (4)
48var ifStatement = root.FindNode(diagnostic.AdditionalLocations[0].SourceSpan); 49var throwStatementExpression = root.FindNode(diagnostic.AdditionalLocations[1].SourceSpan); 50var assignmentValue = root.FindNode(diagnostic.AdditionalLocations[2].SourceSpan); 51var assignmentExpressionStatement = root.FindNode(diagnostic.AdditionalLocations[3].SourceSpan);
src\Analyzers\CSharp\CodeFixes\UseUtf8StringLiteral\UseUtf8StringLiteralCodeFixProvider.cs (2)
120.Where(a => a.Initializer?.ElementValues.FirstOrDefault()?.Syntax.SpanStart == diagnostic.Location.SourceSpan.Start) 168if (argument.Span.Start == location.SourceSpan.Start)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationHelpers.cs (1)
206return contextTree?.GetRoot(cancellationToken).FindToken(contextLocation!.SourceSpan.Start).Parent;
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (1)
Formatting\CodeCleanupTests.TestFixers.cs (1)
36var node = (await sourceTree.GetRootAsync(cancellationToken)).FindNode(diagnostic.Location.SourceSpan);
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (2)
Diagnostics\DiagnosticAnalyzerTests.cs (2)
3907Assert.Equal(diagnosticSpan, location.SourceSpan); 3982Assert.Equal(diagnosticSpan, location.SourceSpan);
Microsoft.CodeAnalysis.CSharp.Features (41)
Completion\CompletionProviders\ExplicitInterfaceMemberCompletionProvider.cs (1)
102return CompletionUtilities.GetTargetCaretNodeForInsertedMember(caretTarget).GetLocation().SourceSpan.End;
Completion\CompletionProviders\OverrideCompletionProvider.cs (1)
209return CompletionUtilities.GetTargetCaretNodeForInsertedMember(caretTarget).GetLocation().SourceSpan.End;
Completion\CompletionProviders\PartialMethodCompletionProvider.cs (1)
67return CompletionUtilities.GetTargetCaretPositionForMethod(methodDeclaration).GetLocation().SourceSpan.End;
ConvertProgram\ConvertToProgramMainCodeRefactoringProvider.cs (1)
47if (!acceptableLocation.SourceSpan.IntersectsWith(position))
Copilot\CSharpCopilotCodeFixProvider.cs (1)
81var containingMethod = CSharpSyntaxFacts.Instance.GetContainingMethodDeclaration(root, diagnostic.Location.SourceSpan.Start, useFullSpan: false);
Debugging\BreakpointResolver.cs (1)
37var token = tree.GetRoot(cancellationToken).FindToken(location.SourceSpan.Start);
GoToDefinition\CSharpGoToDefinitionSymbolService.cs (1)
69return symbol.Locations.FirstOrDefault()?.SourceSpan.Start ?? 0;
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)
45var node = root.FindNode(diagnostic.Location.SourceSpan); 75var node = editor.OriginalRoot.FindNode(diagnostic.Location.SourceSpan);
src\Analyzers\CSharp\CodeFixes\ConditionalExpressionInStringInterpolation\CSharpAddParenthesesAroundConditionalExpressionInInterpolatedStringCodeFixProvider.cs (1)
39var diagnosticSpan = diagnostic.Location.SourceSpan;
src\Analyzers\CSharp\CodeFixes\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionCodeFixProvider.cs (2)
61if (spans.Any((s, nodeSpan) => s.Contains(nodeSpan), switchLocation.SourceSpan)) 67spans.Add(switchLocation.SourceSpan);
src\Analyzers\CSharp\CodeFixes\DisambiguateSameVariable\CSharpDisambiguateSameVariableCodeFixProvider.cs (1)
60var span = diagnostic.Location.SourceSpan;
src\Analyzers\CSharp\CodeFixes\HideBase\HideBaseCodeFixProvider.cs (1)
33var diagnosticSpan = diagnostic.Location.SourceSpan;
src\Analyzers\CSharp\CodeFixes\MakeLocalFunctionStatic\MakeLocalFunctionStaticCodeFixHelper.cs (1)
132var referenceSpan = location.Location.SourceSpan;
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 (1)
49var token = root.FindToken(diagnostic.Location.SourceSpan.Start);
src\Analyzers\CSharp\CodeFixes\MakeStatementAsynchronous\CSharpMakeStatementAsynchronousCodeFixProvider.cs (1)
36var node = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
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\NewLines\EmbeddedStatementPlacement\EmbeddedStatementPlacementCodeFixProvider.cs (1)
70var node = root.FindNode(diagnostic.AdditionalLocations[0].SourceSpan);
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\UseExplicitArrayInExpressionTree\CSharpUseExplicitArrayInExpressionTreeCodeFixProvider.cs (1)
122foreach (var diagnostic in diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start))
src\Analyzers\CSharp\CodeFixes\UseImplicitObjectCreation\CSharpUseImplicitObjectCreationCodeFixProvider.cs (1)
50.OrderBy(d => d.Location.SourceSpan.End)
src\Analyzers\CSharp\CodeFixes\UseImplicitOrExplicitType\UseExplicitTypeCodeFixProvider.cs (1)
49var 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 (1)
40foreach (var diagnostic in diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start))
src\Analyzers\CSharp\CodeFixes\UsePatternCombinators\CSharpUsePatternCombinatorsCodeFixProvider.cs (1)
80var expression = editor.OriginalRoot.FindNode(location.SourceSpan, getInnermostNodeForTie: true);
src\Analyzers\CSharp\CodeFixes\UsePatternMatching\CSharpAsAndMemberAccessCodeFixProvider.cs (1)
43foreach (var diagnostic in diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start))
src\Analyzers\CSharp\CodeFixes\UseThrowExpression\UseThrowExpressionCodeFixProvider.cs (4)
48var ifStatement = root.FindNode(diagnostic.AdditionalLocations[0].SourceSpan); 49var throwStatementExpression = root.FindNode(diagnostic.AdditionalLocations[1].SourceSpan); 50var assignmentValue = root.FindNode(diagnostic.AdditionalLocations[2].SourceSpan); 51var assignmentExpressionStatement = root.FindNode(diagnostic.AdditionalLocations[3].SourceSpan);
src\Analyzers\CSharp\CodeFixes\UseUtf8StringLiteral\UseUtf8StringLiteralCodeFixProvider.cs (2)
120.Where(a => a.Initializer?.ElementValues.FirstOrDefault()?.Syntax.SpanStart == diagnostic.Location.SourceSpan.Start) 168if (argument.Span.Start == location.SourceSpan.Start)
StringIndentation\CSharpStringIndentationService.cs (1)
102if (!IsInHole(interpolatedString, error.Location.SourceSpan))
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (4)
Compilation\SemanticModelGetDeclaredSymbolAPITests.cs (1)
3903Assert.Equal(param.Identifier.Span, symbol.Locations[0].SourceSpan);
Symbols\AnonymousTypesSemanticsTests.cs (1)
1995Assert.Equal(typeSpan, type.Locations[0].SourceSpan);
Symbols\AnonymousTypesSymbolTests.cs (2)
1702Assert.True(statement1.Span.Contains(typeA3.Locations[0].SourceSpan)); 1703Assert.True(statement2.Span.Contains(typeA4.Locations[0].SourceSpan));
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (18)
Diagnostics\DiagnosticTest.cs (3)
87Assert.Equal(new TextSpan(5, 8), d1.Location.SourceSpan); 101Assert.Equal(new TextSpan(1, 1), d3.Location.SourceSpan); 103Assert.Equal(new TextSpan(14, 8), d3.AdditionalLocations.First().SourceSpan);
Diagnostics\LocationsTests.cs (10)
400Assert.InRange(diag.Location.SourceSpan.End, diag.Location.SourceSpan.Start, syntaxTree.GetText().Length); 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)); 595Assert.Equal(0, diagnostics[0].Location.SourceSpan.Start); 596Assert.Equal(0, diagnostics[0].Location.SourceSpan.Length); 598Assert.True(treeSpan.Contains(diagnostics[0].Location.SourceSpan));
LexicalAndXml\RawStringLiteralLexingTests.cs (1)
224var actualDiagnosticsSpans = diagnostics.Select(d => d.Location.SourceSpan).OrderBy(d => d.Start);
Syntax\SyntaxNodeTests.cs (4)
2080Assert.Equal(method.Span, nodeLocation.SourceSpan); 2085Assert.Equal(method.Identifier.Span, tokenLocation.SourceSpan); 2090Assert.Equal(method.ReturnType.GetLastToken().TrailingTrivia[0].Span, triviaLocation.SourceSpan); 2096Assert.Equal(textSpan, spanLocation.SourceSpan);
Microsoft.CodeAnalysis.CSharp.Workspaces (6)
Rename\CSharpRenameRewriterLanguageService.cs (3)
869var token = await tree.GetTouchingTokenAsync(location.SourceSpan.Start, cancellationToken, findInsideTrivia: true).ConfigureAwait(false); 897var token = await location.SourceTree!.GetTouchingTokenAsync(location.SourceSpan.Start, cancellationToken, findInsideTrivia: true).ConfigureAwait(false); 1002implicitReferenceLocation.Location.SourceSpan.Start, cancellationToken, findInsideTrivia: false).ConfigureAwait(false);
Simplification\CSharpSimplificationService.cs (1)
195if (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))
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationHelpers.cs (1)
206return contextTree?.GetRoot(cancellationToken).FindToken(contextLocation!.SourceSpan.Start).Parent;
Microsoft.CodeAnalysis.EditorFeatures (1)
Navigation\AbstractDefinitionLocationService.cs (1)
264if (otherPart.Locations is not [{ SourceTree: { } sourceTree, SourceSpan: var span }])
Microsoft.CodeAnalysis.EditorFeatures.Wpf (1)
Peek\PeekHelpers.cs (1)
51var node = root.FindToken(identifierLocation.SourceSpan.Start).Parent;
Microsoft.CodeAnalysis.EditorFeatures2.UnitTests (3)
FindReferences\FindReferencesTests.vb (1)
467Return loc.IsInSource AndAlso Not loc.SourceTree.IsHiddenPosition(loc.SourceSpan.Start)
Rename\RenameEngineResult.vb (2)
227Dim newLocation = ConflictResolution.GetResolutionTextSpan(location.SourceSpan, documentId) 251Function(r) r.ConflictCheckSpan = location.SourceSpan AndAlso r.DocumentId = documentId)
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 (99)
ChangeSignature\AbstractChangeSignatureService.cs (1)
463var node = root.FindNode(location.SourceSpan, findInsideTrivia: true, getInnermostNodeForTie: true);
CodeFixes\Suppression\AbstractSuppressionBatchFixAllProvider.cs (1)
281tuple => tuple.action, tuple => tuple.diagnostic?.Location.SourceSpan.Start ?? 0);
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.PragmaBatchFixHelpers.cs (1)
53currentDiagnosticSpans.Add(diagnostic, diagnostic.Location.SourceSpan);
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.PragmaWarningBatchFixAllProvider.cs (1)
36var span = diagnostic.Location.SourceSpan;
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.PragmaWarningCodeAction.cs (1)
66_diagnostic.Location.SourceSpan,
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.RemoveSuppressionCodeAction.BatchFixer.cs (1)
45var span = diagnostic.Location.SourceSpan;
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.RemoveSuppressionCodeAction_Pragma.cs (2)
97_diagnostic.Location.SourceSpan, 124var diagnosticSpan = diagnostic.Location.SourceSpan;
CodeLens\CodeLensReferencesService.cs (2)
118var position = location.SourceSpan.Start; 219var enclosingSymbol = semanticModel.GetEnclosingSymbol(location.SourceSpan.Start, cancellationToken);
CodeLens\LocationComparer.cs (3)
21return x.SourceSpan.Equals(y.SourceSpan) && 32return Hash.Combine(obj.SourceSpan.GetHashCode(),
Completion\Providers\AbstractObjectInitializerCompletionProvider.cs (1)
78contextPosition: initializerLocation.SourceSpan.Start,
Debugging\AbstractBreakpointResolver.cs (1)
83var textSpan = new TextSpan(location.SourceSpan.Start, 0);
DocumentHighlighting\AbstractDocumentHighlightsService.cs (2)
315var token = root.FindToken(location.SourceSpan.Start, findInsideTrivia: true); 319: new DocumentSpan(document, location.SourceSpan);
ExtractMethod\MethodExtractor.VariableSymbol.cs (11)
174return leftLocation.SourceSpan.Start - rightLocation.SourceSpan.Start; 226Contract.ThrowIfFalse(_localSymbol.Locations[0].SourceSpan.Start != other._localSymbol.Locations[0].SourceSpan.Start); 228return _localSymbol.Locations[0].SourceSpan.Start - other._localSymbol.Locations[0].SourceSpan.Start; 248var span = _localSymbol.Locations[0].SourceSpan; 338Contract.ThrowIfFalse(locationLeft.SourceSpan.Start != locationRight.SourceSpan.Start); 340return locationLeft.SourceSpan.Start - locationRight.SourceSpan.Start;
FindUsages\AbstractFindUsagesService_FindImplementations.cs (1)
133if (location.IsInSource && !seenLocations.Add((location.SourceTree.FilePath, location.SourceSpan)))
FindUsages\DefinitionItemFactory.cs (2)
240source.Add(new DocumentSpan(document, location.SourceSpan)); 300var sourceSpan = location.SourceSpan;
InheritanceMargin\AbstractInheritanceMarginService_Helpers.cs (1)
739sourceSpans: [new DocumentSpan(document, location.SourceSpan)],
IntroduceParameter\AbstractIntroduceParameterCodeRefactoringProvider.cs (1)
285.OrderByDescending(reference => reference.Location.SourceSpan.Start);
Navigation\NavigableItemFactory.SymbolLocationNavigableItem.cs (1)
58public TextSpan SourceSpan => _location.SourceSpan;
NavigationBar\AbstractNavigationBarItemService.cs (2)
67var navigationLocationSpan = symbol.Locations.FirstOrDefault(loc => loc.SourceTree == tree)?.SourceSpan ?? 86return new SymbolItemLocation(inDocumentInfo: null, (documentId, navigationLocation.SourceSpan));
RemoveUnusedVariable\AbstractRemoveUnusedVariableCodeFixProvider.cs (3)
45var node = root.FindNode(diagnostic.Location.SourceSpan); 74var node = root.FindNode(diagnostic.Location.SourceSpan); 97var referencedSymbolNode = root.FindNode(location.Location.SourceSpan);
ReplaceMethodWithProperty\ReplaceMethodWithPropertyCodeRefactoringProvider.cs (2)
250var nameToken = root.FindToken(location.SourceSpan.Start); 290var nameToken = root.FindToken(location.SourceSpan.Start);
ReplacePropertyWithMethods\ReplacePropertyWithMethodsCodeRefactoringProvider.cs (3)
431return x.location.Location.SourceSpan == y.location.Location.SourceSpan; 435=> obj.location.Location.SourceSpan.GetHashCode();
Shared\Utilities\AnnotatedSymbolMapping.cs (1)
80var token = root.FindToken(location.SourceSpan.Start);
SimplifyTypeNames\AbstractSimplifyTypeNamesCodeFixProvider.cs (1)
112root, model, diagnostic.Location.SourceSpan,
src\Analyzers\Core\Analyzers\RemoveUnnecessaryParentheses\AbstractRemoveUnnecessaryParenthesesDiagnosticAnalyzer.cs (3)
132var expressionFirstLine = lines.GetLineFromPosition(parenthesizedExpressionLocation.SourceSpan.Start); 134var textSpanEndPosition = Math.Min(parenthesizedExpressionLocation.SourceSpan.End, expressionFirstLine.Span.End); 135return Location.Create(parenthesizedExpression.SyntaxTree, TextSpan.FromBounds(parenthesizedExpressionLocation.SourceSpan.Start, textSpanEndPosition));
src\Analyzers\Core\Analyzers\RemoveUnnecessarySuppressions\AbstractRemoveUnnecessaryPragmaSuppressionsDiagnosticAnalyzer.cs (1)
565if (pragma.Span.End <= diagnostic.Location.SourceSpan.Start)
src\Analyzers\Core\Analyzers\RemoveUnusedMembers\AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs (1)
564r => r.SyntaxTree == diagnosticLocation.SourceTree && r.Span.Contains(diagnosticLocation.SourceSpan));
src\Analyzers\Core\Analyzers\UseSystemHashCode\UseSystemHashCodeDiagnosticAnalyzer.cs (1)
47if (!context.ShouldAnalyzeSpan(diagnosticLocation.SourceSpan))
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\AddParameter\AbstractAddParameterCodeFixProvider.cs (1)
69var 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\MakeTypePartial\AbstractMakeTypePartialCodeFixProvider.cs (1)
37var declaration = syntaxRoot.FindNode(diagnostic.Location.SourceSpan);
src\Analyzers\Core\CodeFixes\NewLines\MultipleBlankLines\AbstractMultipleBlankLinesCodeFixProvider.cs (1)
53var token = root.FindToken(diagnostic.AdditionalLocations[0].SourceSpan.Start);
src\Analyzers\Core\CodeFixes\RemoveAsyncModifier\AbstractRemoveAsyncModifierCodeFixProvider.cs (1)
75foreach (var diagnostic in diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start))
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 (4)
39if (root.FindNode(diagnostic.Location.SourceSpan) is { } node && syntaxFacts.IsAttribute(node) || 40root.FindTrivia(diagnostic.Location.SourceSpan.Start).HasStructure) 76if (editor.OriginalRoot.FindNode(location.SourceSpan) is { } attribute && 85node = editor.OriginalRoot.FindTrivia(location.SourceSpan.Start).GetStructure()!;
src\Analyzers\Core\CodeFixes\RemoveUnusedParametersAndValues\AbstractRemoveUnusedValuesCodeFixProvider.cs (5)
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\Analyzers\Core\CodeFixes\SimplifyBooleanExpression\SimplifyConditionalCodeFixProvider.cs (1)
51diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start).ToImmutableArray(),
src\Analyzers\Core\CodeFixes\SimplifyLinqExpression\SimplifyLinqExpressionCodeFixProvider.cs (2)
42foreach (var diagnostic in diagnostics.OrderByDescending(diagnostics => diagnostics.Location.SourceSpan.Start)) 44var invocation = 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\UseCoalesceExpression\UseCoalesceExpressionForNullableTernaryConditionalCheckCodeFixProvider.cs (3)
51var conditionalExpression = root.FindNode(diagnostic.AdditionalLocations[0].SourceSpan, getInnermostNodeForTie: true); 52var conditionExpression = root.FindNode(diagnostic.AdditionalLocations[1].SourceSpan); 53var whenPart = root.FindNode(diagnostic.AdditionalLocations[2].SourceSpan);
src\Analyzers\Core\CodeFixes\UseCoalesceExpression\UseCoalesceExpressionForTernaryConditionalCheckCodeFixProvider.cs (3)
63var conditionalExpression = root.FindNode(diagnostic.AdditionalLocations[0].SourceSpan, getInnermostNodeForTie: true); 64var conditionalPartHigh = root.FindNode(diagnostic.AdditionalLocations[1].SourceSpan); 65var whenPart = root.FindNode(diagnostic.AdditionalLocations[2].SourceSpan);
src\Analyzers\Core\CodeFixes\UseInferredMemberName\AbstractUseInferredMemberNameCodeFixProvider.cs (1)
39var node = root.FindNode(diagnostic.Location.SourceSpan);
src\Analyzers\Core\CodeFixes\UseIsNullCheck\AbstractUseIsNullForReferenceEqualsCodeFixProvider.cs (1)
59foreach (var diagnostic in diagnostics.OrderByDescending(d => d.Location.SourceSpan.Start))
src\Analyzers\Core\CodeFixes\UseNullPropagation\AbstractUseNullPropagationCodeFixProvider.cs (5)
88var conditionalExpressionOrIfStatement = root.FindNode(diagnostic.AdditionalLocations[0].SourceSpan, getInnermostNodeForTie: true); 113var conditionalPart = root.FindNode(diagnostic.AdditionalLocations[1].SourceSpan, getInnermostNodeForTie: true); 114var whenPart = root.FindNode(diagnostic.AdditionalLocations[2].SourceSpan, getInnermostNodeForTie: true); 170var whenTrueStatement = (TStatementSyntax)root.FindNode(diagnostic.AdditionalLocations[1].SourceSpan); 171var match = (TExpressionSyntax)root.FindNode(diagnostic.AdditionalLocations[2].SourceSpan, getInnermostNodeForTie: true);
SyncNamespaces\AbstractSyncNamespacesService.cs (2)
115firstDiagnostic.Location.SourceSpan, 124diagnosticSpan: firstDiagnostic.Location.SourceSpan,
ValueTracking\ValueTrackedItem.cs (1)
56location.SourceSpan,
ValueTracking\ValueTracker.FindReferencesProgress.cs (2)
146var span = referenceLocation.Location.SourceSpan; 169var span = referenceLocation.Location.SourceSpan;
Wrapping\AbstractWrapper.cs (1)
66=> declaration.GetDiagnostics().Any(d => d.Severity == DiagnosticSeverity.Error && d.Location.SourceSpan.OverlapsWith(headerSpan));
Microsoft.CodeAnalysis.Features.Test.Utilities (1)
EditAndContinue\EditAndContinueTestVerifier.cs (1)
514.OrderBy(partners => partners.Key.GetLocation().SourceSpan.Start)
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 (7)
Features\Diagnostics\DocumentAnalysisExecutor.cs (1)
385bool shouldInclude(Diagnostic d) => span.Value.IntersectsWith(d.Location.SourceSpan) && !IsUnusedImportDiagnostic(d);
Features\Diagnostics\DocumentAnalysisExecutor_Helpers.cs (5)
352if (location.SourceSpan.End > location.SourceTree.Length) 355throw new ArgumentException(string.Format(FeaturesResources.Reported_diagnostic_0_has_a_source_location_1_in_file_2_which_is_outside_of_the_given_file, id, location.SourceSpan, location.SourceTree.FilePath), "diagnostic"); 375if (location.SourceSpan.End > text.Length) 378throw new ArgumentException(string.Format(FeaturesResources.Reported_diagnostic_0_has_a_source_location_1_in_file_2_which_is_outside_of_the_given_file, id, location.SourceSpan, filePath), "diagnostic"); 412if (span.HasValue && !span.Value.IntersectsWith(diagnostic.Location.SourceSpan))
Features\UnifiedSuggestions\UnifiedSuggestedActionsSource.cs (1)
246document, firstDiagnostic.Location.SourceSpan, scope, cancellationToken).ConfigureAwait(false);
Microsoft.CodeAnalysis.Test.Utilities (4)
Diagnostics\DiagnosticDescription.cs (4)
161_squiggledText = _location.SourceTree.GetText().ToString(_location.SourceSpan); 285if (!_syntaxPredicate(d._location.SourceTree.GetRoot().FindToken(_location.SourceSpan.Start, true).Parent)) 298if (!d._syntaxPredicate(_location.SourceTree.GetRoot().FindToken(_location.SourceSpan.Start, true).Parent)) 543assertText.AppendLine(l.SourceTree.GetText().Lines.GetLineFromPosition(l.SourceSpan.Start).ToString());
Microsoft.CodeAnalysis.VisualBasic (27)
Analysis\FlowAnalysis\DataFlowPass.vb (1)
1194If isImplicitlyDeclared OrElse firstLocation Is Nothing OrElse firstLocation.SourceSpan.Start < node.SpanStart Then
CommandLine\CommandLineDiagnosticFormatter.vb (2)
133Return diagnostic.Location.SourceSpan 147Return diagnostic.Location.SourceSpan
Compilation\DocumentationComments\DocumentationCommentCompiler.Includes.vb (1)
549(Not Me._filterSpanWithinTree.HasValue OrElse Me._filterSpanWithinTree.Value.Contains(loc.SourceSpan))
Compilation\VisualBasicDiagnosticFilter.vb (1)
205location.SourceTree.GetWarningState(id, location.SourceSpan.Start) = ReportDiagnostic.Suppress Then
GlobalImport.vb (1)
117Dim unmappedSpan = unmappedDiag.Location.SourceSpan
Locations\LocationExtensions.vb (1)
28Return location.SourceSpan
Locations\VBLocation.vb (1)
25Return Me.SourceSpan
Symbols\MethodSymbolExtensions.vb (1)
51If location.IsInSource AndAlso location.SourceTree Is syntaxTree AndAlso parameter.Span.Contains(location.SourceSpan) Then
Symbols\NamedTypeSymbolExtensions.vb (3)
30If methodLoc.IsInSource AndAlso methodLoc.SourceTree Is tree AndAlso methodLoc.SourceSpan = nameSpan Then 40If methodLoc.IsInSource AndAlso methodLoc.SourceTree Is tree AndAlso methodLoc.SourceSpan = nameSpan Then 63methodLoc.SourceSpan = nameSpan Then
Symbols\Source\SourceMemberContainerTypeSymbol.vb (10)
1361Return containingSourceNamespace.GetDeclarationSpelling(firstLocation.SourceTree, firstLocation.SourceSpan.Start) 2264((fileCompResult = 0) AndAlso typeToTestLocation.SourceSpan.Start >= structBeingAnalyzedLocation.SourceSpan.Start) 3263If Me._declaration.Declarations.Length >= 1 AndAlso position = Me._declaration.Declarations(0).Location.SourceSpan.Start Then 3895If GetImplementsLocation(interface1).SourceSpan.Start > GetImplementsLocation(interface2).SourceSpan.Start Then 3945If GetImplementsLocation(interface1).SourceSpan.Start > GetImplementsLocation(interface2).SourceSpan.Start Then 3977If GetImplementsLocation(interface1).SourceSpan.Start > GetImplementsLocation(interface2).SourceSpan.Start Then
Symbols\Source\SourcePropertySymbol.vb (2)
167Dim accessor = If(getMethod.Locations(0).SourceSpan.Start < setMethod.Locations(0).SourceSpan.Start, setMethod, getMethod)
Symbols\Symbol.vb (1)
373Dim token = CType(location.SourceTree.GetRoot().FindToken(location.SourceSpan.Start), SyntaxToken)
Syntax\SyntaxFacts.vb (1)
1116If p.GetLocation.SourceSpan.Start < token.SpanStart Then
Syntax\VisualBasicWarningStateMap.vb (1)
91entries(index) = New WarningStateMapEntry(currentDirective.GetLocation().SourceSpan.End, accumulatedGeneralWarningState, accumulatedSpecificWarningState)
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\RemoveUnnecessaryByVal\VisualBasicRemoveUnnecessaryByValCodeFixProvider.vb (1)
40Dim node = DirectCast(root.FindNode(diagnostic.AdditionalLocations(0).SourceSpan), ParameterSyntax)
src\Analyzers\VisualBasic\CodeFixes\SimplifyObjectCreation\VisualBasicSimplifyObjectCreationCodeFixProvider.vb (1)
38Dim node = DirectCast(root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie:=True), VariableDeclaratorSyntax)
Microsoft.CodeAnalysis.VisualBasic.Features (6)
Completion\CompletionProviders\OverrideCompletionProvider.vb (3)
206Return methodStatement.GetLocation().SourceSpan.End 213Return lastStatement.GetLocation().SourceSpan.End 223Return lastAccessorStatement.GetLocation().SourceSpan.End
src\Analyzers\VisualBasic\CodeFixes\GenerateParameterizedMember\GenerateParameterizedMemberCodeFixProvider.vb (1)
62Dim diagnosticSpan = diagnostic.Location.SourceSpan
src\Analyzers\VisualBasic\CodeFixes\RemoveUnnecessaryByVal\VisualBasicRemoveUnnecessaryByValCodeFixProvider.vb (1)
40Dim node = DirectCast(root.FindNode(diagnostic.AdditionalLocations(0).SourceSpan), ParameterSyntax)
src\Analyzers\VisualBasic\CodeFixes\SimplifyObjectCreation\VisualBasicSimplifyObjectCreationCodeFixProvider.vb (1)
38Dim node = DirectCast(root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie:=True), VariableDeclaratorSyntax)
Microsoft.CodeAnalysis.VisualBasic.Semantic.UnitTests (34)
Compilation\SemanticModelGetDeclaredSymbolAPITests.vb (34)
1258paramSymbol1.Locations.Single().SourceSpan.Start) 1266paramSymbol2.Locations.Single().SourceSpan.Start - "Optional ".Length) 1274paramSymbol3.Locations.Single().SourceSpan.Start) 1282paramSymbol4.Locations.Single().SourceSpan.Start) 1290paramSymbol5.Locations.Single().SourceSpan.Start) 1369Assert.Equal(syntax.SpanStart + 6, paramSymbol1.Locations.Single().SourceSpan.Start) 1374Assert.Equal(syntax.SpanStart + 6, paramSymbol2.Locations.Single().SourceSpan.Start) 1379Assert.Equal(syntax.SpanStart, paramSymbol3.Locations.Single().SourceSpan.Start) 1384Assert.Equal(syntax.SpanStart + 6, paramSymbol4.Locations.Single().SourceSpan.Start) 1849Assert.True(syntax.SpanStart = tpSymbol1.Locations.Item(0).SourceSpan.Start OrElse 1850syntax.SpanStart = tpSymbol1.Locations.Item(1).SourceSpan.Start, 1858Assert.True(syntax.SpanStart = tpSymbol2.Locations.Item(0).SourceSpan.Start OrElse 1859syntax.SpanStart = tpSymbol2.Locations.Item(1).SourceSpan.Start, 1867Assert.True(syntax.SpanStart = tpSymbol3.Locations.Item(0).SourceSpan.Start OrElse 1868syntax.SpanStart = tpSymbol3.Locations.Item(1).SourceSpan.Start, 1876Assert.True(syntax.SpanStart = tpSymbol4.Locations.Item(0).SourceSpan.Start OrElse 1877syntax.SpanStart = tpSymbol4.Locations.Item(1).SourceSpan.Start, 1885Assert.Equal(syntax.SpanStart, tpSymbol5.Locations.Single().SourceSpan.Start) 2022Assert.True(syntax.SpanStart = varSymbol1.Locations.Item(0).SourceSpan.Start OrElse 2023syntax.SpanStart = varSymbol1.Locations.Item(1).SourceSpan.Start, 2032Assert.True(syntax.SpanStart = varSymbol2.Locations.Item(0).SourceSpan.Start OrElse 2033syntax.SpanStart = varSymbol2.Locations.Item(1).SourceSpan.Start, 2042Assert.True(syntax.SpanStart = varSymbol3.Locations.Item(0).SourceSpan.Start OrElse 2043syntax.SpanStart = varSymbol3.Locations.Item(1).SourceSpan.Start, 2052Assert.True(syntax.SpanStart = varSymbol4.Locations.Item(0).SourceSpan.Start OrElse 2053syntax.SpanStart = varSymbol4.Locations.Item(1).SourceSpan.Start, 2062Assert.True(syntax.SpanStart = varSymbol5.Locations.Item(0).SourceSpan.Start OrElse 2063syntax.SpanStart = varSymbol5.Locations.Item(1).SourceSpan.Start, 2072Assert.True(syntax.SpanStart = varSymbol6.Locations.Item(0).SourceSpan.Start OrElse 2073syntax.SpanStart = varSymbol6.Locations.Item(1).SourceSpan.Start, 2083Assert.True(syntax.SpanStart = varSymbol7.Locations.Item(0).SourceSpan.Start OrElse 2084syntax.SpanStart = varSymbol7.Locations.Item(1).SourceSpan.Start, 2093Assert.True(syntax.SpanStart = varSymbol8.Locations.Item(0).SourceSpan.Start OrElse 2094syntax.SpanStart = varSymbol8.Locations.Item(1).SourceSpan.Start,
Microsoft.CodeAnalysis.VisualBasic.Symbol.UnitTests (17)
SymbolsTests\AnonymousTypes\AnonymousTypesSemanticsTests.vb (2)
425Assert.Equal(location.SourceSpan, localType.Locations(0).SourceSpan) 459Assert.Equal(locations(propIndex).SourceSpan, member.Locations(0).SourceSpan)
SymbolsTests\Source\SourceSymbolTests.vb (15)
341Assert.Equal("C", locs(0).SourceTree.GetText().ToString(locs(0).SourceSpan)) 343Assert.Equal("C", locs(1).SourceTree.GetText().ToString(locs(1).SourceSpan)) 350Assert.Equal("D", locs(0).SourceTree.GetText().ToString(locs(0).SourceSpan)) 352Assert.Equal("D", locs(1).SourceTree.GetText().ToString(locs(1).SourceSpan)) 359Assert.Equal("T", locs(0).SourceTree.GetText().ToString(locs(0).SourceSpan)) 361Assert.Equal("T", locs(1).SourceTree.GetText().ToString(locs(1).SourceSpan)) 367Assert.Equal("m1", locs(0).SourceTree.GetText().ToString(locs(0).SourceSpan)) 373Assert.Equal("x", locs(0).SourceTree.GetText().ToString(locs(0).SourceSpan)) 379Assert.Equal("v1$", locs(0).SourceTree.GetText().ToString(locs(0).SourceSpan)) 386Assert.Equal("N1", locs(0).SourceTree.GetText().ToString(locs(0).SourceSpan)) 388Assert.Equal("N1", locs(1).SourceTree.GetText().ToString(locs(1).SourceSpan)) 395Assert.Equal("N2", locs(0).SourceTree.GetText().ToString(locs(0).SourceSpan)) 397Assert.Equal("N2", locs(1).SourceTree.GetText().ToString(locs(1).SourceSpan)) 404Assert.Equal("N3", locs(0).SourceTree.GetText().ToString(locs(0).SourceSpan)) 406Assert.Equal("N3", locs(1).SourceTree.GetText().ToString(locs(1).SourceSpan))
Microsoft.CodeAnalysis.VisualBasic.Syntax.UnitTests (2)
TestSyntaxNodes.vb (2)
932Dim span1 = err1.Location.SourceSpan 933Dim span2 = err2.Location.SourceSpan
Microsoft.CodeAnalysis.VisualBasic.Test.Utilities (13)
CompilationTestUtils.vb (10)
1009Dim lineText As String = GetLineText(sourceLocation.SourceTree.GetText(), sourceLocation.SourceSpan.Start, offsetInLine) 1013New String("~"c, Math.Max(Math.Min(sourceLocation.SourceSpan.Length, lineText.Length - offsetInLine + 1), 1)) + Environment.NewLine 1056If loc1.SourceSpan.Start < loc2.SourceSpan.Start Then Return -1 1057If loc1.SourceSpan.Start > loc2.SourceSpan.Start Then Return 1 1058If loc1.SourceSpan.Length < loc2.SourceSpan.Length Then Return -1 1059If loc1.SourceSpan.Length > loc2.SourceSpan.Length Then Return 1
ParserTestUtilities.vb (1)
614Dim syntaxErrorSpan = syntaxError.Location.SourceSpan
SemanticModelTestBase.vb (2)
90" Location1.SourceSpan.Start : " & tpSymbol.Locations.Item(0).SourceSpan.Start & 91" Location2.SourceSpan.Start : " & tpSymbol.Locations.Item(0).SourceSpan.Start
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 (45)
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 (2)
120.ThenBy(d => d.Location.SourceSpan.Start) 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\FixAllState.cs (1)
70var diagnosticSpan = diagnosticsToFix.First().Value.FirstOrDefault()?.Location.SourceSpan;
Diagnostics\Extensions.cs (1)
319filterSpan.HasValue && !filterSpan.Value.IntersectsWith(diagnostic.Location.SourceSpan));
Editing\SymbolEditor.cs (1)
332return EditOneDeclarationAsync(symbol, doc.Id, location.SourceSpan.Start, editAction, cancellationToken);
FindSymbols\ReferenceLocation.cs (2)
140(compare = this.Location.SourceSpan.CompareTo(other.Location.SourceSpan)) != 0)
FindSymbols\ReferenceLocationExtensions.cs (1)
73var enclosingSymbol = semanticModel.GetEnclosingSymbol(reference.Location.SourceSpan.Start);
ReassignedVariable\AbstractReassignedVariableService.cs (1)
250location = parameterLocation.SourceSpan;
Recommendations\AbstractRecommendationServiceRunner.cs (1)
354declarationSyntax.Span.IntersectsWith(candidateLocation.SourceSpan)), declarationSyntax);
Remote\RemoteArguments.cs (1)
165referenceLocation.Location.SourceSpan,
Rename\ConflictEngine\ConflictResolver.cs (5)
193implicitUsageConflict.SourceSpan, conflictResolution.OldSolution.GetRequiredDocument(implicitUsageConflict.SourceTree).Id, RelatedLocationType.UnresolvableConflict)); 217implicitConflict.SourceSpan, conflictResolution.OldSolution.GetRequiredDocument(implicitConflict.SourceTree).Id, RelatedLocationType.UnresolvableConflict)); 337oldLocation.SourceSpan, conflictResolution.OldSolution.GetRequiredDocument(oldLocation.SourceTree).Id, RelatedLocationType.UnresolvableConflict)); 371renameDeclarationLocations[symbolIndex] = new RenameDeclarationLocationReference(solution.GetDocumentId(location.SourceTree), location.SourceSpan, overriddenFromMetadata, locations.Length); 411.ThenBy(l => l.IsInSource ? l.SourceSpan.Start : int.MaxValue);
Rename\ConflictEngine\ConflictResolver.Session.cs (6)
224renamedSpansTracker.GetAdjustedPosition(_renameSymbolDeclarationLocation.SourceSpan.Start, _documentIdOfRenameSymbolDeclaration), 550if (newLocations.Any(loc => loc.SourceSpan.Start == adjustedStartPosition)) 599if (newAdjustedStartPosition != newLocation.SourceSpan.Start) 607var overridingSymbol = await SymbolFinder.FindSymbolAtPositionAsync(solution.GetRequiredDocument(newLocation.SourceTree), newLocation.SourceSpan.Start, cancellationToken: _cancellationToken).ConfigureAwait(false); 685? conflictResolution.GetAdjustedTokenStartingPosition(_renameSymbolDeclarationLocation.SourceSpan.Start, _documentIdOfRenameSymbolDeclaration) 686: _renameSymbolDeclarationLocation.SourceSpan.Start;
Rename\SymbolicRenameLocations.ReferenceProcessing.cs (1)
302containingLocationForStringOrComment: location.ContainingStringLocation.SourceSpan));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\AnalysisContextExtensions.cs (2)
55=> location.SourceTree != null && context.ShouldAnalyzeSpan(location.SourceSpan, location.SourceTree); 75=> location.SourceTree != null && context.ShouldAnalyzeSpan(location.SourceSpan, location.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\LocationExtensions.cs (7)
20=> location.GetSourceTreeOrThrow().GetRoot(cancellationToken).FindToken(location.SourceSpan.Start); 23=> location.GetSourceTreeOrThrow().GetRoot(cancellationToken).FindNode(location.SourceSpan); 26=> location.GetSourceTreeOrThrow().GetRoot(cancellationToken).FindNode(location.SourceSpan, getInnermostNodeForTie: getInnermostNodeForTie); 29=> location.GetSourceTreeOrThrow().GetRoot(cancellationToken).FindNode(location.SourceSpan, findInsideTrivia, getInnermostNodeForTie); 39return !(tree == null || tree.IsHiddenPosition(loc.SourceSpan.Start)); 45return loc1.SourceTree == loc2.SourceTree && loc1.SourceSpan.IntersectsWith(loc2.SourceSpan);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyWriter.cs (2)
264WriteInteger(location.SourceSpan.Start); 265WriteInteger(location.SourceSpan.Length);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeFixes\ForkingSyntaxEditorBasedCodeFixProvider.cs (1)
69diagnostic.AdditionalLocations[0].SourceSpan, getInnermostNodeForTie: true);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationHelpers.cs (2)
205var afterMember = declarationList.LastOrDefault(m => m.SpanStart <= info.Context.AfterThisLocation.SourceSpan.Start); 221var beforeMember = declarationList.FirstOrDefault(m => m.Span.End >= info.Context.BeforeThisLocation.SourceSpan.End);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\FindSymbols\LinkedFileReferenceLocationEqualityComparer.cs (3)
26return x.Location.SourceSpan == y.Location.SourceSpan; 30=> obj.Location.SourceSpan.GetHashCode();
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\MoveDeclarationNearReference\AbstractMoveDeclarationNearReferenceService.State.cs (1)
107let token = syntaxRoot.FindToken(r.Location.SourceSpan.Start)
Microsoft.CodeAnalysis.Workspaces.UnitTests (7)
BatchFixAllProviderTests.cs (1)
104cancellationToken => CreateChangedDocument(context.Document, diagnostic.Location.SourceSpan, replacement, cancellationToken),
FindReferencesTests.cs (6)
555Assert.NotEqual(typeResult.Locations.Single().Location.SourceSpan, constructorResult.Locations.Single().Location.SourceSpan); 588Assert.NotEqual(typeResult.Locations.Single().Location.SourceSpan, constructorResult.Locations.Single().Location.SourceSpan); 630Assert.True(typeResult.Locations.All(loc => loc.Location.SourceSpan != constructorResult.Locations.Single().Location.SourceSpan));
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}"); 156TextSpan? expectedSpan = Location.None.SourceSpan; 169Assert.True(expectedSpan.Equals(d.Location.SourceSpan), 170$"Span {spanNum} doesn't match: expected {expectedSpan} but got {d.Location.SourceSpan}"); 172if (expectedSpan != Location.None.SourceSpan) 418if (x.Location.SourceSpan.Start < y.Location.SourceSpan.Start) 422else if (x.Location.SourceSpan.Start > y.Location.SourceSpan.Start)
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}"); 156TextSpan? expectedSpan = Location.None.SourceSpan; 169Assert.True(expectedSpan.Equals(d.Location.SourceSpan), 170$"Span {spanNum} doesn't match: expected {expectedSpan} but got {d.Location.SourceSpan}"); 172if (expectedSpan != Location.None.SourceSpan) 418if (x.Location.SourceSpan.Start < y.Location.SourceSpan.Start) 422else if (x.Location.SourceSpan.Start > y.Location.SourceSpan.Start)
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}"); 156TextSpan? expectedSpan = Location.None.SourceSpan; 169Assert.True(expectedSpan.Equals(d.Location.SourceSpan), 170$"Span {spanNum} doesn't match: expected {expectedSpan} but got {d.Location.SourceSpan}"); 172if (expectedSpan != Location.None.SourceSpan) 418if (x.Location.SourceSpan.Start < y.Location.SourceSpan.Start) 422else if (x.Location.SourceSpan.Start > y.Location.SourceSpan.Start)
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}"); 156TextSpan? expectedSpan = Location.None.SourceSpan; 169Assert.True(expectedSpan.Equals(d.Location.SourceSpan), 170$"Span {spanNum} doesn't match: expected {expectedSpan} but got {d.Location.SourceSpan}"); 172if (expectedSpan != Location.None.SourceSpan) 418if (x.Location.SourceSpan.Start < y.Location.SourceSpan.Start) 422else if (x.Location.SourceSpan.Start > y.Location.SourceSpan.Start)
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}"); 156TextSpan? expectedSpan = Location.None.SourceSpan; 169Assert.True(expectedSpan.Equals(d.Location.SourceSpan), 170$"Span {spanNum} doesn't match: expected {expectedSpan} but got {d.Location.SourceSpan}"); 172if (expectedSpan != Location.None.SourceSpan) 418if (x.Location.SourceSpan.Start < y.Location.SourceSpan.Start) 422else if (x.Location.SourceSpan.Start > y.Location.SourceSpan.Start)
Microsoft.Interop.ComInterfaceGenerator (5)
ComMethodInfo.cs (4)
110&& interfaceLocation.SourceSpan.Contains(methodLocation.SourceSpan)) 127if (declaringSyntax.GetLocation().SourceSpan.Contains(methodLocationInAttributedInterfaceDeclaration.SourceSpan))
src\libraries\System.Runtime.InteropServices\gen\Common\ConvertToSourceGeneratedInteropFixer.cs (1)
202SyntaxNode node = root.FindNode(diagnostic.Location.SourceSpan);
Microsoft.Interop.LibraryImportGenerator (6)
Analyzers\ConvertToLibraryImportFixer.cs (1)
293SyntaxNode? referenceNode = root.FindNode(location.Location.SourceSpan);
Analyzers\CustomMarshallerAttributeFixer.cs (3)
39var entryPointTypeSymbol = (INamedTypeSymbol)model.GetEnclosingSymbol(diagnostic.Location.SourceSpan.Start, fixAllContext.CancellationToken); 44SyntaxNode node = root.FindNode(diagnostic.Location.SourceSpan); 184&& attr.ApplicationSyntaxReference.Span.Contains(locationInAttribute.SourceSpan)).ConstructorArguments[0].Value!;
Analyzers\ShapeBreakingDiagnosticSuppressor.cs (1)
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 (1)
202SyntaxNode node = root.FindNode(diagnostic.Location.SourceSpan);
Microsoft.Maui.Controls.BindingSourceGen (1)
BindingInvocationDescription.cs (1)
20 : new SourceCodeLocation(location.SourceTree.FilePath, location.SourceSpan, location.GetLineSpan().Span);
Microsoft.ML.InternalCodeAnalyzer (3)
ContractsCheckNameofFixProvider.cs (1)
41var diagnosticSpan = diagnostic.Location.SourceSpan;
NameFixProvider.cs (1)
60var token = root.FindToken(diagnostic.Location.SourceSpan.Start);
RelaxTestNamingSuppressor.cs (1)
42var node = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
Microsoft.VisualStudio.LanguageServices (5)
CallHierarchy\CallHierarchyDetail.cs (1)
30_span = location.SourceSpan;
Diagnostics\VisualStudioVenusSpanMappingService.cs (1)
33sourceSpan = location.SourceSpan;
Venus\ContainedLanguageCodeSupport.cs (3)
210var position = type.Locations.First(loc => loc.SourceTree == targetSyntaxTree).SourceSpan.Start; 300? semanticModel.LookupSymbols(position: type.Locations[0].SourceSpan.Start, container: type, name: null) 497return semanticModel.LookupSymbols(typeLocation.SourceSpan.Start, objectType, nameOfEvent).SingleOrDefault(m => m.Kind == SymbolKind.Event);
Mvc.Api.Analyzers.Test (4)
ActualApiResponseMetadataFactoryTest.cs (4)
77var methodSyntax = syntaxTree.GetRoot().FindNode(method.Locations[0].SourceSpan); 374var methodSyntax = (MethodDeclarationSyntax)syntaxTree.GetRoot().FindNode(method.Locations[0].SourceSpan); 394var methodSyntax = syntaxTree.GetRoot().FindNode(method.Locations[0].SourceSpan); 413var methodSyntax = syntaxTree.GetRoot().FindNode(method.Locations[0].SourceSpan);
System.Text.Json.SourceGeneration (1)
src\libraries\Common\src\SourceGenerators\DiagnosticInfo.cs (1)
34=> Location.Create(location.SourceTree?.FilePath ?? "", location.SourceSpan, location.GetLineSpan().Span);
System.Text.RegularExpressions.Generator (1)
RegexGenerator.Parser.cs (1)
255return Location.Create(location.SourceTree?.FilePath ?? string.Empty, location.SourceSpan, location.GetLineSpan().Span);
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