1 override of SourceTree
Microsoft.CodeAnalysis (1)
Diagnostic\SourceLocation.cs (1)
72public override SyntaxTree SourceTree
695 references to SourceTree
AnalyzerRunner (1)
DiagnosticAnalyzerRunner.cs (1)
205.ThenBy(tuple => tuple.Item2.Location.SourceTree?.FilePath, StringComparer.OrdinalIgnoreCase)
ConfigurationSchemaGenerator (1)
RuntimeSource\SourceGenerators\DiagnosticInfo.cs (1)
34=> Location.Create(location.SourceTree?.FilePath ?? "", location.SourceSpan, location.GetLineSpan().Span);
GenerateDocumentationAndConfigFiles (26)
src\RoslynAnalyzers\Utilities\Compiler\Options\AnalyzerOptionsExtensions.cs (4)
40tree = symbol.Locations[0].SourceTree; 319=> options.GetDisallowedSymbolNamesWithValueOption(rule, symbol.Locations[0].SourceTree, compilation); 333=> options.GetAdditionalRequiredSuffixesOption(rule, symbol.Locations[0].SourceTree, compilation); 382=> options.GetAdditionalRequiredGenericInterfaces(rule, symbol.Locations[0].SourceTree, compilation);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\AnalysisContextExtensions.cs (4)
54=> location.SourceTree != null && context.ShouldAnalyzeSpan(location.SourceSpan, location.SourceTree); 74=> location.SourceTree != null && context.ShouldAnalyzeSpan(location.SourceSpan, location.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\LocationExtensions.cs (5)
14Contract.ThrowIfNull(location.SourceTree); 15return location.SourceTree; 37var tree = loc.SourceTree; 44return loc1.SourceTree == loc2.SourceTree && loc1.SourceSpan.IntersectsWith(loc2.SourceSpan);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.AnonymousFunctionOrDelegateSymbolKey.cs (1)
46var syntaxTree = location.SourceTree;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.BodyLevelSymbolKey.cs (2)
77var syntaxTree = locations[0]!.SourceTree; 181var firstSourceTree = locations[0]?.SourceTree;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.cs (1)
160return compilation.SyntaxTrees.Contains(firstNonNull.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyReader.cs (2)
725if (location.SourceTree != null) 728var semanticModel = Compilation.GetSemanticModel(location.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyWriter.cs (1)
262WriteString(location.SourceTree.FilePath);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService.cs (1)
493if (location.SourceTree != destinationMember.SyntaxTree)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService_FindDeclaration.cs (1)
226TryAddToWorker(declarations, checkGeneratedCode, out declaration, out availableIndices, d => d.SyntaxTree == location?.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationHelpers.cs (2)
205if (info.Context.AfterThisLocation?.SourceTree is { } afterSourceTree && 219if (info.Context.BeforeThisLocation?.SourceTree is { } beforeSourceTree &&
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\ISolutionExtensions.cs (1)
159return solution.GetDocument(location.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\ProjectExtensions.cs (1)
42var diagnosticFilePath = PathUtilities.GetDirectoryName(diagnostic?.Location.SourceTree?.FilePath ?? project.FilePath);
ILLink.RoslynAnalyzer (1)
RequiresUnsafeAnalyzer.cs (1)
64var syntaxTree = context.Location.SourceTree!;
Metrics (21)
MetricsOutputWriter.cs (1)
86writer.WriteAttributeString("File", location.SourceTree?.FilePath ?? "UNKNOWN");
src\RoslynAnalyzers\Utilities\Compiler\Options\AnalyzerOptionsExtensions.cs (4)
40tree = symbol.Locations[0].SourceTree; 319=> options.GetDisallowedSymbolNamesWithValueOption(rule, symbol.Locations[0].SourceTree, compilation); 333=> options.GetAdditionalRequiredSuffixesOption(rule, symbol.Locations[0].SourceTree, compilation); 382=> options.GetAdditionalRequiredGenericInterfaces(rule, symbol.Locations[0].SourceTree, compilation);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\AnalysisContextExtensions.cs (4)
54=> location.SourceTree != null && context.ShouldAnalyzeSpan(location.SourceSpan, location.SourceTree); 74=> location.SourceTree != null && context.ShouldAnalyzeSpan(location.SourceSpan, location.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\LocationExtensions.cs (5)
14Contract.ThrowIfNull(location.SourceTree); 15return location.SourceTree; 37var tree = loc.SourceTree; 44return loc1.SourceTree == loc2.SourceTree && loc1.SourceSpan.IntersectsWith(loc2.SourceSpan);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.AnonymousFunctionOrDelegateSymbolKey.cs (1)
46var syntaxTree = location.SourceTree;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.BodyLevelSymbolKey.cs (2)
77var syntaxTree = locations[0]!.SourceTree; 181var firstSourceTree = locations[0]?.SourceTree;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.cs (1)
160return compilation.SyntaxTrees.Contains(firstNonNull.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyReader.cs (2)
725if (location.SourceTree != null) 728var semanticModel = Compilation.GetSemanticModel(location.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyWriter.cs (1)
262WriteString(location.SourceTree.FilePath);
Metrics.Legacy (21)
src\RoslynAnalyzers\Tools\Metrics\MetricsOutputWriter.cs (1)
86writer.WriteAttributeString("File", location.SourceTree?.FilePath ?? "UNKNOWN");
src\RoslynAnalyzers\Utilities\Compiler\Options\AnalyzerOptionsExtensions.cs (4)
40tree = symbol.Locations[0].SourceTree; 319=> options.GetDisallowedSymbolNamesWithValueOption(rule, symbol.Locations[0].SourceTree, compilation); 333=> options.GetAdditionalRequiredSuffixesOption(rule, symbol.Locations[0].SourceTree, compilation); 382=> options.GetAdditionalRequiredGenericInterfaces(rule, symbol.Locations[0].SourceTree, compilation);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\AnalysisContextExtensions.cs (4)
54=> location.SourceTree != null && context.ShouldAnalyzeSpan(location.SourceSpan, location.SourceTree); 74=> location.SourceTree != null && context.ShouldAnalyzeSpan(location.SourceSpan, location.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\LocationExtensions.cs (5)
14Contract.ThrowIfNull(location.SourceTree); 15return location.SourceTree; 37var tree = loc.SourceTree; 44return loc1.SourceTree == loc2.SourceTree && loc1.SourceSpan.IntersectsWith(loc2.SourceSpan);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.AnonymousFunctionOrDelegateSymbolKey.cs (1)
46var syntaxTree = location.SourceTree;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.BodyLevelSymbolKey.cs (2)
77var syntaxTree = locations[0]!.SourceTree; 181var firstSourceTree = locations[0]?.SourceTree;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.cs (1)
160return compilation.SyntaxTrees.Contains(firstNonNull.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyReader.cs (2)
725if (location.SourceTree != null) 728var semanticModel = Compilation.GetSemanticModel(location.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyWriter.cs (1)
262WriteString(location.SourceTree.FilePath);
Microsoft.Analyzers.Extra.Tests (2)
Resources\RoslynTestUtils.cs (2)
348var doc = proj.GetDocument(d.Location.SourceTree); 530return diagnostics.Where(d => d.Location.SourceTree!.FilePath.EndsWith(document.Name));
Microsoft.Analyzers.Local.Tests (2)
Resources\RoslynTestUtils.cs (2)
349var doc = proj.GetDocument(d.Location.SourceTree); 531return diagnostics.Where(d => d.Location.SourceTree!.FilePath.EndsWith(document.Name));
Microsoft.AspNetCore.Analyzer.Testing (2)
DiagnosticAnalyzerRunner.cs (1)
99if (tree == diag.Location.SourceTree)
DiagnosticVerifier.cs (1)
122if (tree == diag.Location.SourceTree)
Microsoft.AspNetCore.Components.Analyzers.Tests (2)
Helpers\DiagnosticVerifier.Helper.cs (1)
76if (tree == diag.Location.SourceTree)
Verifiers\DiagnosticVerifier.cs (1)
261string resultMethodName = diagnostics[i].Location.SourceTree.FilePath.EndsWith(".cs", StringComparison.Ordinal) ? "GetCSharpResultAt" : "GetBasicResultAt";
Microsoft.AspNetCore.Components.SdkAnalyzers.Tests (2)
Helpers\DiagnosticVerifier.Helper.cs (1)
76if (tree == diag.Location.SourceTree)
Verifiers\DiagnosticVerifier.cs (1)
261string resultMethodName = diagnostics[i].Location.SourceTree.FilePath.EndsWith(".cs", StringComparison.Ordinal) ? "GetCSharpResultAt" : "GetBasicResultAt";
Microsoft.AspNetCore.Http.RequestDelegateGenerator (1)
RequestDelegateGeneratorSuppressor.cs (1)
49if (location.SourceTree is not { } sourceTree)
Microsoft.AspNetCore.Razor.Test.Common (2)
Language\IntegrationTests\CompilationFailedException.cs (1)
42syntaxTreesWithErrors.Add(diagnostic.Location.SourceTree);
Language\IntegrationTests\RazorIntegrationTestBase.cs (1)
507syntaxTreesWithErrors.Add(diagnostic.Location.SourceTree);
Microsoft.AspNetCore.Razor.Test.Common.Tooling (1)
Language\IntegrationTests\RazorToolingIntegrationTestBase.cs (1)
379syntaxTreesWithErrors.Add(diagnostic.Location.SourceTree);
Microsoft.CodeAnalysis (29)
Diagnostic\Diagnostic.cs (1)
519if (location.SourceTree != tree)
Diagnostic\Location.cs (3)
31[MemberNotNullWhen(true, nameof(SourceTree))] 32public bool IsInSource { get { return SourceTree != null; } } 100result += "(" + this.SourceTree?.FilePath + this.SourceSpan + ")";
DiagnosticAnalyzer\AnalysisResultBuilder.cs (1)
304=> diagnostic.Location.SourceTree;
DiagnosticAnalyzer\AnalysisScope.cs (1)
301if (diagnostic.Location.SourceTree != filterFile.SourceTree)
DiagnosticAnalyzer\AnalyzerDriver.cs (6)
1262Debug.Assert(location.SourceTree != null); 1265if (IsGeneratedOrHiddenCodeLocation(location.SourceTree, location.SourceSpan, cancellationToken)) 1273var generatedCodeSymbolsInTree = getOrComputeGeneratedCodeSymbolsInTree(location.SourceTree, compilation, cancellationToken); 1276var model = compilation.GetSemanticModel(location.SourceTree); 1277for (var node = location.SourceTree.GetRoot(cancellationToken).FindNode(location.SourceSpan, getInnermostNodeForTie: true); 2027if (diagnostic?.Location.SourceTree is { } tree &&
DiagnosticAnalyzer\AnalyzerExecutor.AnalyzerDiagnosticReporter.cs (1)
133_contextFile.Value.SourceTree == diagnostic.Location.SourceTree;
DiagnosticAnalyzer\AnalyzerExecutor.cs (3)
1553if (syntaxRef.SyntaxTree == diagnostic.Location.SourceTree) 1679if (location.SourceTree != null && 1680!IsAnalyzerSuppressedForTree(analyzer, location.SourceTree, cancellationToken))
DiagnosticAnalyzer\CompilationWithAnalyzers.cs (2)
910if (location.SourceTree != null) 912partialTrees.Add(location.SourceTree);
DiagnosticAnalyzer\DiagnosticAnalysisContextHelpers.cs (5)
95Debug.Assert(location.SourceTree != null); 96if (!compilation.ContainsSyntaxTree(location.SourceTree)) 99throw new ArgumentException(string.Format(CodeAnalysisResources.InvalidDiagnosticLocationReported, id, location.SourceTree.FilePath), "diagnostic"); 102if (location.SourceSpan.End > location.SourceTree.Length) 105throw new ArgumentException(string.Format(CodeAnalysisResources.InvalidDiagnosticSpanReported, id, location.SourceSpan, location.SourceTree.FilePath), "diagnostic");
DiagnosticAnalyzer\SuppressMessageAttributeState.cs (2)
186var model = _compilation.GetSemanticModel(location.SourceTree); 189for (var node = location.SourceTree.GetRoot().FindNode(location.SourceSpan, getInnermostNodeForTie: true);
ReferenceManager\CommonReferenceManager.Resolution.cs (4)
814Debug.Assert(referenceDirective.Location.SourceTree is object); 815if (localBoundReferenceDirectives != null && localBoundReferenceDirectives.ContainsKey((referenceDirective.Location.SourceTree.FilePath, referenceDirective.File))) 835localBoundReferenceDirectives.Add((referenceDirective.Location.SourceTree.FilePath, referenceDirective.File), boundReference); 871var tree = location.SourceTree;
Microsoft.CodeAnalysis.Analyzers (26)
src\RoslynAnalyzers\Utilities\Compiler\Options\AnalyzerOptionsExtensions.cs (4)
40tree = symbol.Locations[0].SourceTree; 319=> options.GetDisallowedSymbolNamesWithValueOption(rule, symbol.Locations[0].SourceTree, compilation); 333=> options.GetAdditionalRequiredSuffixesOption(rule, symbol.Locations[0].SourceTree, compilation); 382=> options.GetAdditionalRequiredGenericInterfaces(rule, symbol.Locations[0].SourceTree, compilation);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\AnalysisContextExtensions.cs (4)
54=> location.SourceTree != null && context.ShouldAnalyzeSpan(location.SourceSpan, location.SourceTree); 74=> location.SourceTree != null && context.ShouldAnalyzeSpan(location.SourceSpan, location.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\LocationExtensions.cs (5)
14Contract.ThrowIfNull(location.SourceTree); 15return location.SourceTree; 37var tree = loc.SourceTree; 44return loc1.SourceTree == loc2.SourceTree && loc1.SourceSpan.IntersectsWith(loc2.SourceSpan);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.AnonymousFunctionOrDelegateSymbolKey.cs (1)
46var syntaxTree = location.SourceTree;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.BodyLevelSymbolKey.cs (2)
77var syntaxTree = locations[0]!.SourceTree; 181var firstSourceTree = locations[0]?.SourceTree;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.cs (1)
160return compilation.SyntaxTrees.Contains(firstNonNull.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyReader.cs (2)
725if (location.SourceTree != null) 728var semanticModel = Compilation.GetSemanticModel(location.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyWriter.cs (1)
262WriteString(location.SourceTree.FilePath);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService.cs (1)
493if (location.SourceTree != destinationMember.SyntaxTree)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService_FindDeclaration.cs (1)
226TryAddToWorker(declarations, checkGeneratedCode, out declaration, out availableIndices, d => d.SyntaxTree == location?.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationHelpers.cs (2)
205if (info.Context.AfterThisLocation?.SourceTree is { } afterSourceTree && 219if (info.Context.BeforeThisLocation?.SourceTree is { } beforeSourceTree &&
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\ISolutionExtensions.cs (1)
159return solution.GetDocument(location.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\ProjectExtensions.cs (1)
42var diagnosticFilePath = PathUtilities.GetDirectoryName(diagnostic?.Location.SourceTree?.FilePath ?? project.FilePath);
Microsoft.CodeAnalysis.AnalyzerUtilities (20)
src\RoslynAnalyzers\Utilities\Compiler\Options\AnalyzerOptionsExtensions.cs (4)
40tree = symbol.Locations[0].SourceTree; 319=> options.GetDisallowedSymbolNamesWithValueOption(rule, symbol.Locations[0].SourceTree, compilation); 333=> options.GetAdditionalRequiredSuffixesOption(rule, symbol.Locations[0].SourceTree, compilation); 382=> options.GetAdditionalRequiredGenericInterfaces(rule, symbol.Locations[0].SourceTree, compilation);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\AnalysisContextExtensions.cs (4)
54=> location.SourceTree != null && context.ShouldAnalyzeSpan(location.SourceSpan, location.SourceTree); 74=> location.SourceTree != null && context.ShouldAnalyzeSpan(location.SourceSpan, location.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\LocationExtensions.cs (5)
14Contract.ThrowIfNull(location.SourceTree); 15return location.SourceTree; 37var tree = loc.SourceTree; 44return loc1.SourceTree == loc2.SourceTree && loc1.SourceSpan.IntersectsWith(loc2.SourceSpan);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.AnonymousFunctionOrDelegateSymbolKey.cs (1)
46var syntaxTree = location.SourceTree;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.BodyLevelSymbolKey.cs (2)
77var syntaxTree = locations[0]!.SourceTree; 181var firstSourceTree = locations[0]?.SourceTree;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.cs (1)
160return compilation.SyntaxTrees.Contains(firstNonNull.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyReader.cs (2)
725if (location.SourceTree != null) 728var semanticModel = Compilation.GetSemanticModel(location.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyWriter.cs (1)
262WriteString(location.SourceTree.FilePath);
Microsoft.CodeAnalysis.BannedApiAnalyzers (26)
src\RoslynAnalyzers\Utilities\Compiler\Options\AnalyzerOptionsExtensions.cs (4)
40tree = symbol.Locations[0].SourceTree; 319=> options.GetDisallowedSymbolNamesWithValueOption(rule, symbol.Locations[0].SourceTree, compilation); 333=> options.GetAdditionalRequiredSuffixesOption(rule, symbol.Locations[0].SourceTree, compilation); 382=> options.GetAdditionalRequiredGenericInterfaces(rule, symbol.Locations[0].SourceTree, compilation);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\AnalysisContextExtensions.cs (4)
54=> location.SourceTree != null && context.ShouldAnalyzeSpan(location.SourceSpan, location.SourceTree); 74=> location.SourceTree != null && context.ShouldAnalyzeSpan(location.SourceSpan, location.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\LocationExtensions.cs (5)
14Contract.ThrowIfNull(location.SourceTree); 15return location.SourceTree; 37var tree = loc.SourceTree; 44return loc1.SourceTree == loc2.SourceTree && loc1.SourceSpan.IntersectsWith(loc2.SourceSpan);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.AnonymousFunctionOrDelegateSymbolKey.cs (1)
46var syntaxTree = location.SourceTree;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.BodyLevelSymbolKey.cs (2)
77var syntaxTree = locations[0]!.SourceTree; 181var firstSourceTree = locations[0]?.SourceTree;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.cs (1)
160return compilation.SyntaxTrees.Contains(firstNonNull.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyReader.cs (2)
725if (location.SourceTree != null) 728var semanticModel = Compilation.GetSemanticModel(location.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyWriter.cs (1)
262WriteString(location.SourceTree.FilePath);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService.cs (1)
493if (location.SourceTree != destinationMember.SyntaxTree)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService_FindDeclaration.cs (1)
226TryAddToWorker(declarations, checkGeneratedCode, out declaration, out availableIndices, d => d.SyntaxTree == location?.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationHelpers.cs (2)
205if (info.Context.AfterThisLocation?.SourceTree is { } afterSourceTree && 219if (info.Context.BeforeThisLocation?.SourceTree is { } beforeSourceTree &&
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\ISolutionExtensions.cs (1)
159return solution.GetDocument(location.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\ProjectExtensions.cs (1)
42var diagnosticFilePath = PathUtilities.GetDirectoryName(diagnostic?.Location.SourceTree?.FilePath ?? project.FilePath);
Microsoft.CodeAnalysis.CodeStyle (25)
src\Analyzers\Core\Analyzers\MakeFieldReadonly\AbstractMakeFieldReadonlyDiagnosticAnalyzer.cs (2)
224|| ShouldSkipAnalysis(location.SourceTree!, options, compilation.Options, option.Notification, cancellationToken)) 311return options.GetAnalyzerOptions(diagnosticLocation.SourceTree!).PreferReadonly;
src\Analyzers\Core\Analyzers\NamingStyle\NamingStyleDiagnosticAnalyzerBase.cs (2)
58var sourceTree = symbolContext.Symbol.Locations.FirstOrDefault()?.SourceTree; 86if (symbol?.Locations.FirstOrDefault()?.SourceTree is not { } sourceTree)
src\Analyzers\Core\Analyzers\RemoveUnnecessarySuppressions\AbstractRemoveUnnecessaryPragmaSuppressionsDiagnosticAnalyzer.cs (2)
497if (diagnostic.Location.SourceTree == tree) 555Debug.Assert(diagnostic.Location.SourceTree == tree);
src\Analyzers\Core\Analyzers\RemoveUnusedMembers\AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs (2)
701r => r.SyntaxTree == diagnosticLocation.SourceTree && r.Span.Contains(diagnosticLocation.SourceSpan)); 772foreach (var tree in namedTypeSymbol.Locations.Select(l => l.SourceTree).Distinct().WhereNotNull())
src\Analyzers\Core\Analyzers\RemoveUnusedParametersAndValues\AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.SymbolStartAnalyzer.cs (1)
133var option = analyzerOptions.GetAnalyzerOptions(location.SourceTree!).UnusedParameters;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\AnalysisContextExtensions.cs (4)
54=> location.SourceTree != null && context.ShouldAnalyzeSpan(location.SourceSpan, location.SourceTree); 74=> location.SourceTree != null && context.ShouldAnalyzeSpan(location.SourceSpan, location.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\LocationExtensions.cs (5)
14Contract.ThrowIfNull(location.SourceTree); 15return location.SourceTree; 37var tree = loc.SourceTree; 44return loc1.SourceTree == loc2.SourceTree && loc1.SourceSpan.IntersectsWith(loc2.SourceSpan);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.AnonymousFunctionOrDelegateSymbolKey.cs (1)
46var syntaxTree = location.SourceTree;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.BodyLevelSymbolKey.cs (2)
77var syntaxTree = locations[0]!.SourceTree; 181var firstSourceTree = locations[0]?.SourceTree;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.cs (1)
160return compilation.SyntaxTrees.Contains(firstNonNull.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyReader.cs (2)
725if (location.SourceTree != null) 728var semanticModel = Compilation.GetSemanticModel(location.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyWriter.cs (1)
262WriteString(location.SourceTree.FilePath);
Microsoft.CodeAnalysis.CodeStyle.Fixes (9)
src\Analyzers\Core\CodeFixes\AddParameter\AddParameterService.cs (1)
101declarationLocation => solution.GetRequiredDocument(declarationLocation.Locations[0].SourceTree!));
src\Analyzers\Core\CodeFixes\MatchFolderAndNamespace\AbstractChangeNamespaceToMatchFolderCodeFixProvider.CustomFixAllProvider.cs (1)
78.GroupBy(diagnostic => diagnostic.Location.SourceTree)
src\Analyzers\Core\CodeFixes\UseIsNullCheck\AbstractUseIsNullForReferenceEqualsCodeFixProvider.cs (1)
40var title = GetTitle(negated, diagnostic.Location.SourceTree!.Options);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService.cs (1)
493if (location.SourceTree != destinationMember.SyntaxTree)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService_FindDeclaration.cs (1)
226TryAddToWorker(declarations, checkGeneratedCode, out declaration, out availableIndices, d => d.SyntaxTree == location?.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationHelpers.cs (2)
205if (info.Context.AfterThisLocation?.SourceTree is { } afterSourceTree && 219if (info.Context.BeforeThisLocation?.SourceTree is { } beforeSourceTree &&
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\ISolutionExtensions.cs (1)
159return solution.GetDocument(location.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\ProjectExtensions.cs (1)
42var diagnosticFilePath = PathUtilities.GetDirectoryName(diagnostic?.Location.SourceTree?.FilePath ?? project.FilePath);
Microsoft.CodeAnalysis.CSharp (51)
Binder\Binder_Symbols.cs (4)
1981if (containerResult == 0 && la.SourceTree == lb.SourceTree) return lb.SourceSpan.Start - la.SourceSpan.Start; 2062arg0 = srcSymbol.GetFirstLocation().SourceTree.FilePath; 2216arg0 = first.GetFirstLocation().SourceTree.FilePath;
Binder\BinderFactory.BinderFactoryVisitor.cs (1)
634return (location.SourceTree == syntaxTree) && span.Contains(location.SourceSpan);
Binder\InMethodBinder.cs (1)
249Debug.Assert(oldLocation != newLocation || oldLocation == Location.None || newLocation.SourceTree?.GetRoot().ContainsDiagnostics == true,
CommandLine\CSharpCompiler.cs (1)
262string entryPointFileName = PathUtilities.GetFileName(entryPoint.GetFirstLocation().SourceTree!.FilePath);
Compilation\CSharpCompilation.cs (3)
3823var filePath = location.SourceTree?.FilePath; 4757var comparison = CompareSyntaxTreeOrdering(loc1.SourceTree!, loc2.SourceTree!);
Compilation\CSharpDiagnosticFilter.cs (3)
153Debug.Assert(location.SourceTree is null || location.SourceTree is CSharpSyntaxTree); 154var tree = location.SourceTree as CSharpSyntaxTree;
Compilation\CSharpSemanticModel.cs (1)
3247if (location.SourceTree == this.SyntaxTree && parameter.Span.Contains(location.SourceSpan))
Compilation\SyntaxTreeSemanticModel.cs (4)
1835if (loc.IsInSource && loc.SourceTree == this.SyntaxTree && declarationSpan.Contains(loc.SourceSpan)) 2050if (location.SourceTree == this.SyntaxTree && parameter.Span.Contains(location.SourceSpan)) 2234if (location.SourceTree == this.SyntaxTree && parameter.Span.Contains(location.SourceSpan)) 2461if (location.SourceTree != this.SyntaxTree)
Compiler\DocumentationCommentCompiler.cs (3)
588Debug.Assert(location.SourceTree!.ReportDocumentationCommentDiagnostics()); //Should be the same tree as for the symbol. 609Debug.Assert(location.SourceTree!.ReportDocumentationCommentDiagnostics()); //Should be the same tree as for the symbol. 741if (location.SourceTree.ReportDocumentationCommentDiagnostics())
Compiler\DocumentationCommentCompiler.IncludeElementExpander.cs (2)
636if (treelessSyntax.ContainsDiagnostics && sourceLocation.SourceTree.ReportDocumentationCommentDiagnostics()) 652if (sourceLocation.SourceTree.ReportDocumentationCommentDiagnostics())
Emitter\Model\PEModuleBuilder.cs (1)
464Cci.DebugSourceDocument doc = DebugDocumentsBuilder.TryGetDebugDocument(span.Path, basePath: location.SourceTree.FilePath);
SymbolDisplay\SymbolDisplayVisitor.Types.cs (1)
191: internalSymbol2.GetFirstLocationOrNone().SourceTree is { } tree ? $"<tree {internalSymbol2.DeclaringCompilation.GetSyntaxTreeOrdinal(tree)}>"
SymbolDisplay\SymbolDisplayVisitor_Minimal.cs (2)
246if (location.IsInSource && location.SourceTree == SemanticModelOpt.SyntaxTree) 248var token = location.SourceTree.GetRoot().FindToken(PositionOpt);
Symbols\ConstraintsHelper.cs (1)
102Binder.CheckFeatureAvailability(location.SourceTree, MessageID.IDS_FeatureAllowsRefStructConstraint, diagnostics, location);
Symbols\LexicalSortKey.cs (1)
75: this(location.SourceTree, location.SourceSpan.Start, compilation)
Symbols\RangeVariableSymbol.cs (2)
61Debug.Assert(_location.SourceTree != null); 62SyntaxToken token = _location.SourceTree.GetRoot().FindToken(_location.SourceSpan.Start);
Symbols\Source\ModifierUtils.cs (7)
117=> ((result & modifier) != 0) && !Binder.CheckFeatureAvailability(errorLocation.SourceTree, featureID, diagnostics, errorLocation); 155LanguageVersion availableVersion = ((CSharpParseOptions)errorLocation.SourceTree.Options).LanguageVersion; 182Binder.CheckFeatureAvailability(errorLocation.SourceTree, MessageID.IDS_DefaultInterfaceImplementation, diagnostics, errorLocation); 217Debug.Assert(location.SourceTree is not null); 219LanguageVersion availableVersion = ((CSharpParseOptions)location.SourceTree.Options).LanguageVersion; 231Debug.Assert(location.SourceTree is not null); 233LanguageVersion availableVersion = ((CSharpParseOptions)location.SourceTree.Options).LanguageVersion;
Symbols\Source\SourceMemberContainerSymbol.cs (1)
5194var languageVersion = ((CSharpParseOptions)this.GetFirstLocation().SourceTree!.Options).LanguageVersion;
Symbols\Source\SourceModuleSymbol.cs (1)
375ImmutableArray<ImmutableArray<string>> interceptorsNamespaces = ((CSharpParseOptions)location.SourceTree.Options).InterceptorsNamespaces;
Symbols\Source\SourceNamespaceSymbol.cs (1)
395return !namespaceNameLocations.Any(static (loc, leftTree) => (object)loc.SourceTree == leftTree, leftTree);
Symbols\Source\SourcePropertySymbol.cs (2)
460Debug.Assert(location.SourceTree is not null); 462LanguageVersion availableVersion = ((CSharpParseOptions)location.SourceTree.Options).LanguageVersion;
Symbols\Source\SourceUserDefinedOperatorSymbolBase.cs (3)
246LanguageVersion availableVersion = ((CSharpParseOptions)location.SourceTree.Options).LanguageVersion; 272Binder.CheckFeatureAvailability(location.SourceTree, MessageID.IDS_DefaultInterfaceImplementation, diagnostics, location); 956Binder.CheckFeatureAvailability(location.SourceTree, MessageID.IDS_FeatureRelaxedShiftOperator, diagnostics, location);
Symbols\Symbol.cs (3)
452if (loc.IsInSource && loc.SourceTree == tree && declarationSpan.Contains(loc.SourceSpan)) 511SyntaxToken token = location.SourceTree.GetRoot().FindToken(location.SourceSpan.Start); 527SyntaxNode parent = location.SourceTree.GetRoot();
Symbols\Symbol_Attributes.cs (2)
502if (location.SourceTree == argumentLocation.SourceTree &&
Microsoft.CodeAnalysis.CSharp.CodeStyle (2)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SemanticFacts\CSharpSemanticFacts.cs (2)
80if (symbol.Locations.Any(static (loc, location) => loc.SourceTree == location.SourceTree && loc.SourceSpan.Contains(location.SourceSpan), location))
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (4)
src\Analyzers\CSharp\CodeFixes\MakeMethodAsynchronous\CSharpMakeMethodAsynchronousCodeFixProvider.cs (2)
46if (diagnostic.Location.SourceTree is null) 49var root = diagnostic.Location.SourceTree.GetRoot(cancellationToken);
src\Analyzers\CSharp\CodeFixes\UseIsNullCheck\CSharpUseIsNullCheckForCastAndEqualityOperatorCodeFixProvider.cs (1)
42var title = GetTitle(negated, diagnostic.Location.SourceTree!.Options);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationHelpers.cs (1)
204? contextLocation.SourceTree
Microsoft.CodeAnalysis.CSharp.CodeStyle.UnitTests (2)
src\Analyzers\CSharp\Tests\GenerateConstructor\GenerateConstructorTests_Razor.cs (1)
69diagnostic => diagnostic.Severity == DiagnosticSeverity.Error && diagnostic.Location.SourceTree == requestTree));
src\Analyzers\CSharp\Tests\GenerateMethod\GenerateMethodTests_Razor.cs (1)
67diagnostic => diagnostic.Severity == DiagnosticSeverity.Error && diagnostic.Location.SourceTree == requestTree));
Microsoft.CodeAnalysis.CSharp.CSharp15.UnitTests (4)
UnionsTests.cs (4)
23700Assert.Equal(s1Decl, location.SourceTree.GetRoot().FindNode(location.SourceSpan)); 23702Assert.Equal(s1Decl, location.SourceTree.GetRoot().FindNode(location.SourceSpan)); 23704Assert.Equal("bool", location.SourceTree.GetRoot().FindNode(location.SourceSpan).ToString()); 23706Assert.Equal("int", location.SourceTree.GetRoot().FindNode(location.SourceSpan).ToString());
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (3)
Formatting\CodeCleanupTests.TestFixers.cs (3)
34var sourceTree = diagnostic.Location.SourceTree; 101var sourceTree = diagnostic.Location.SourceTree; 151var sourceTree = diagnostic.Location.SourceTree;
Microsoft.CodeAnalysis.CSharp.Emit2.UnitTests (2)
Emit\EditAndContinue\EditAndContinueTestBase.cs (2)
94var tree1 = method1.Locations[0].SourceTree; 95var tree0 = method0.Locations[0].SourceTree;
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (7)
Diagnostics\GetDiagnosticsTests.cs (5)
572Assert.True(diagnostics[0].Location.SourceTree.Equals(syntaxTree1)); 573Assert.True(diagnostics[1].Location.SourceTree.Equals(syntaxTree2)); 574Assert.True(diagnostics[2].Location.SourceTree.Equals(syntaxTree3)); 598Assert.True(diagnostics[0].Location.SourceTree.Equals(syntaxTree1)); 599Assert.True(diagnostics[1].Location.SourceTree.Equals(syntaxTree2));
Semantics\OutVarTests.cs (2)
35652Assert.Equal(tree, identifierBefore.Location.SourceTree); 35658Assert.Null(identifierAfter.Location.SourceTree);
Microsoft.CodeAnalysis.CSharp.Features (10)
Completion\CompletionProviders\AwaitCompletionProvider.cs (1)
126foreach (var group in references.SelectMany(r => r.Locations).GroupBy(l => l.Location.SourceTree))
ConvertPrimaryToRegularConstructor\ConvertPrimaryToRegularConstructorCodeRefactoringProvider.cs (2)
476foreach (var location in namedType.Locations.OrderBy(l => !ReferenceEquals(l.SourceTree, typeDeclaration.SyntaxTree))) 478foreach (var (fieldOrProperty, initializer) in initializedFieldsAndProperties.Where(i => ReferenceEquals(i.initializer.SyntaxTree, location.SourceTree)).OrderBy(i => i.initializer.SpanStart))
Copilot\CSharpImplementNotImplementedExceptionDiagnosticAnalyzer.cs (1)
74if (location.SourceTree == context.FilterTree)
Debugging\BreakpointResolver.cs (1)
36var tree = location.SourceTree;
ImplementInterface\AbstractChangeImplementationCodeRefactoringProvider.cs (2)
236if (location.SourceTree is null) 239var doc = solution.GetRequiredDocument(location.SourceTree);
src\Analyzers\CSharp\CodeFixes\MakeMethodAsynchronous\CSharpMakeMethodAsynchronousCodeFixProvider.cs (2)
46if (diagnostic.Location.SourceTree is null) 49var root = diagnostic.Location.SourceTree.GetRoot(cancellationToken);
src\Analyzers\CSharp\CodeFixes\UseIsNullCheck\CSharpUseIsNullCheckForCastAndEqualityOperatorCodeFixProvider.cs (1)
42var title = GetTitle(negated, diagnostic.Location.SourceTree!.Options);
Microsoft.CodeAnalysis.CSharp.Features.UnitTests (4)
GenerateVariable\GenerateTypeTests_Razor.cs (1)
48diagnostic => diagnostic.Severity == DiagnosticSeverity.Error && diagnostic.Location.SourceTree == requestTree));
GenerateVariable\GenerateVariableTests_Razor.cs (1)
69diagnostic => diagnostic.Severity == DiagnosticSeverity.Error && diagnostic.Location.SourceTree == requestTree));
src\Analyzers\CSharp\Tests\GenerateConstructor\GenerateConstructorTests_Razor.cs (1)
69diagnostic => diagnostic.Severity == DiagnosticSeverity.Error && diagnostic.Location.SourceTree == requestTree));
src\Analyzers\CSharp\Tests\GenerateMethod\GenerateMethodTests_Razor.cs (1)
67diagnostic => diagnostic.Severity == DiagnosticSeverity.Error && diagnostic.Location.SourceTree == requestTree));
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (1)
Semantics\InterceptorsTests.cs (1)
7589comp1.GetDiagnostics().Where(d => d.Location.SourceTree == interceptors).Verify(
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (10)
Symbols\Source\DeclaringSyntaxNodeTests.cs (4)
742Assert.Equal(new[] { source0, source1, source3 }, locations.Select(l => l.SourceTree)); 748Assert.Equal(new[] { source0, source1, source3, source4 }, locations.Select(l => l.SourceTree)); 753Assert.Equal(new[] { source0, source4, source3 }, locations.Select(l => l.SourceTree)); 763Assert.Equal(new[] { source4, source3 }, locations.Select(l => l.SourceTree));
Symbols\Source\FileModifierTests.cs (4)
891Assert.Equal(source1, classC.Locations[0].SourceTree); 938Assert.Equal(source1, member.Locations[0].SourceTree); 973Assert.Equal(source1, classC.Locations[0].SourceTree); 1003Assert.Equal(source1, classC.Locations[0].SourceTree);
Symbols\Source\MethodTests.cs (2)
2625Assert.Equal("source1", method.Locations[0].SourceTree.FilePath); 2626Assert.Equal("source2", implementationPart.Locations[0].SourceTree.FilePath);
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (6)
Diagnostics\DiagnosticTest.cs (2)
86Assert.Same(syntaxTree, d1.Location.SourceTree); 100Assert.Same(syntaxTree, d3.Location.SourceTree);
Syntax\SyntaxNodeTests.cs (4)
2153Assert.Equal(tree, nodeLocation.SourceTree); 2158Assert.Equal(tree, tokenLocation.SourceTree); 2163Assert.Equal(tree, triviaLocation.SourceTree); 2169Assert.Equal(tree, spanLocation.SourceTree);
Microsoft.CodeAnalysis.CSharp.Workspaces (7)
Rename\CSharpRenameRewriterLanguageService.cs (4)
144_renamableDeclarationLocation = _renamedSymbol.Locations.FirstOrDefault(loc => loc.IsInSource && loc.SourceTree == _semanticModel.SyntaxTree); 863var tree = location.SourceTree; 894var token = await location.SourceTree!.GetTouchingTokenAsync(location.SourceSpan.Start, cancellationToken, findInsideTrivia: true).ConfigureAwait(false); 970var token = await implicitReferenceLocation.Location.SourceTree!.GetTouchingTokenAsync(
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SemanticFacts\CSharpSemanticFacts.cs (2)
80if (symbol.Locations.Any(static (loc, location) => loc.SourceTree == location.SourceTree && loc.SourceSpan.Contains(location.SourceSpan), location))
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationHelpers.cs (1)
204? contextLocation.SourceTree
Microsoft.CodeAnalysis.EditorFeatures (4)
InlineRename\AbstractEditorInlineRenameService.SymbolRenameInfo.cs (1)
165var symbolSourceDocument = this.Document.Project.Solution.GetDocument(RenameSymbol.Locations.Single().SourceTree);
Navigation\AbstractDefinitionLocationService.cs (1)
266if (otherPart.Locations is not [{ SourceTree: { } sourceTree, SourceSpan: var span }])
Peek\PeekHelpers.cs (2)
50var root = identifierLocation.SourceTree.GetRoot(cancellationToken); 70return identifierLocation.SourceTree.GetLocation(node.Span).GetMappedLineSpan().Span;
Microsoft.CodeAnalysis.EditorFeatures.UnitTests (2)
SymbolFinder\SymbolFinderTests.cs (2)
835var document = solution.GetDocument(sourceDefinition.Locations.First(loc => loc.IsInSource).SourceTree); 883var document = solution.GetDocument(sourceDefinition.Locations.First(loc => loc.IsInSource).SourceTree);
Microsoft.CodeAnalysis.ExternalAccess.Copilot (1)
SemanticSearch\CopilotSemanticSearchUtilities.cs (1)
43=> location.SourceTree!.GetRoot(cancellationToken).FindNode(location.SourceSpan, findInsideTrivia, getInnermostNodeForTie);
Microsoft.CodeAnalysis.Features (62)
ChangeSignature\AbstractChangeSignatureService.cs (2)
162var declarationDocument = solution.GetRequiredDocument(declarationLocation.SourceTree!); 458var tree = location.SourceTree;
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;
CodeLens\CodeLensReferencesService.cs (3)
104var document = solution.GetDocument(location.SourceTree); 358var document = solution.GetDocument(commonLocation.SourceTree); 389var document = solution.GetDocument(syntaxNode.GetLocation().SourceTree);
CodeLens\LocationComparer.cs (3)
22x.SourceTree.FilePath.Equals(y.SourceTree.FilePath, StringComparison.OrdinalIgnoreCase); 33StringComparer.OrdinalIgnoreCase.GetHashCode(obj.SourceTree.FilePath));
Debugging\AbstractBreakpointResolver.cs (1)
82var document = _solution.GetDocument(location.SourceTree);
Diagnostics\Service\DocumentAnalysisExecutor_Helpers.cs (5)
150RoslynDebug.Assert(location.SourceTree != null); 151if (project.GetDocument(location.SourceTree) == null) 154throw new ArgumentException(string.Format(FeaturesResources.Reported_diagnostic_0_has_a_source_location_in_file_1_which_is_not_part_of_the_compilation_being_analyzed, id, location.SourceTree.FilePath), "diagnostic"); 157if (location.SourceSpan.End > location.SourceTree.Length) 160throw 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");
DocumentHighlighting\AbstractDocumentHighlightsService.cs (2)
246var document = solution.GetDocument(location.SourceTree); 316var tree = location.SourceTree;
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);
ExternalAccess\UnitTesting\SolutionCrawler\UnitTestingWorkCoordinator.UnitTestingSemanticChangeProcessor.cs (1)
183var documentId = solution.GetDocumentId(location.SourceTree, projectId);
ExtractMethod\MethodExtractor.VariableSymbol.cs (2)
111Contract.ThrowIfFalse(locationLeft.SourceTree == locationRight.SourceTree);
FindUsages\AbstractFindUsagesService_FindImplementations.cs (1)
133if (location.IsInSource && !seenLocations.Add((location.SourceTree.FilePath, location.SourceSpan)))
FindUsages\DefinitionItemFactory.cs (1)
247solution.GetDocument(location.SourceTree) is { } document &&
FindUsages\FindUsagesHelpers.cs (1)
110Locations: [{ SourceTree: { } syntaxTree, SourceSpan: var sourceSpan }, ..],
GenerateType\AbstractGenerateTypeService.State.cs (1)
316.Select(static loc => loc.SourceTree)
GoToDefinition\GoToDefinitionFeatureHelpers.cs (1)
42if (sourceLocations.All(l => solution.GetDocument(l.SourceTree) == null))
InheritanceMargin\AbstractInheritanceMarginService_Helpers.cs (1)
721if (location.IsInSource && location.IsVisibleSourceLocation() && solution.GetDocument(location.SourceTree) is { } document)
Navigation\NavigableItemFactory.cs (1)
44let doc = solution.GetDocument(c.SourceTree)
Navigation\NavigableItemFactory.SymbolLocationNavigableItem.cs (1)
50return (self._location.IsInSource && self._solution.GetDocument(self._location.SourceTree) is { } document)
NavigationBar\AbstractNavigationBarItemService.cs (4)
67var navigationLocationSpan = symbol.Locations.FirstOrDefault(loc => loc.SourceTree == tree)?.SourceSpan ?? 79var navigationLocation = symbol.Locations.FirstOrDefault(loc => loc.SourceTree != null && loc.SourceTree != tree) ?? 82var documentId = solution.GetDocumentId(navigationLocation.SourceTree);
PdbSourceDocument\PdbSourceDocumentMetadataAsSourceFileProvider.cs (1)
284var navigateDocument = navigateProject.GetDocument(navigateLocation.SourceTree);
PullMemberUp\MemberAndDestinationValidator.cs (1)
25destination.Locations.Any(static (location, arg) => location.IsInSource && !arg.solution.GetRequiredDocument(location.SourceTree).IsGeneratedCode(arg.cancellationToken), (solution, cancellationToken));
Rename\SymbolicRenameInfo.cs (1)
220var sourceDocument = solution.GetRequiredDocument(location.SourceTree);
SemanticSearch\SemanticSearchDefinitionItemFactory.cs (1)
55if (solution.GetDocument(location.SourceTree) is { } document)
Shared\Utilities\AnnotatedSymbolMapping.cs (1)
70var tree = location.SourceTree!;
src\Analyzers\Core\Analyzers\MakeFieldReadonly\AbstractMakeFieldReadonlyDiagnosticAnalyzer.cs (2)
224|| ShouldSkipAnalysis(location.SourceTree!, options, compilation.Options, option.Notification, cancellationToken)) 311return options.GetAnalyzerOptions(diagnosticLocation.SourceTree!).PreferReadonly;
src\Analyzers\Core\Analyzers\NamingStyle\NamingStyleDiagnosticAnalyzerBase.cs (2)
58var sourceTree = symbolContext.Symbol.Locations.FirstOrDefault()?.SourceTree; 86if (symbol?.Locations.FirstOrDefault()?.SourceTree is not { } sourceTree)
src\Analyzers\Core\Analyzers\RemoveUnnecessarySuppressions\AbstractRemoveUnnecessaryPragmaSuppressionsDiagnosticAnalyzer.cs (2)
497if (diagnostic.Location.SourceTree == tree) 555Debug.Assert(diagnostic.Location.SourceTree == tree);
src\Analyzers\Core\Analyzers\RemoveUnusedMembers\AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs (2)
701r => r.SyntaxTree == diagnosticLocation.SourceTree && r.Span.Contains(diagnosticLocation.SourceSpan)); 772foreach (var tree in namedTypeSymbol.Locations.Select(l => l.SourceTree).Distinct().WhereNotNull())
src\Analyzers\Core\Analyzers\RemoveUnusedParametersAndValues\AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.SymbolStartAnalyzer.cs (1)
133var option = analyzerOptions.GetAnalyzerOptions(location.SourceTree!).UnusedParameters;
src\Analyzers\Core\CodeFixes\AddParameter\AddParameterService.cs (1)
101declarationLocation => solution.GetRequiredDocument(declarationLocation.Locations[0].SourceTree!));
src\Analyzers\Core\CodeFixes\MatchFolderAndNamespace\AbstractChangeNamespaceToMatchFolderCodeFixProvider.CustomFixAllProvider.cs (1)
78.GroupBy(diagnostic => diagnostic.Location.SourceTree)
src\Analyzers\Core\CodeFixes\UseIsNullCheck\AbstractUseIsNullForReferenceEqualsCodeFixProvider.cs (1)
40var title = GetTitle(negated, diagnostic.Location.SourceTree!.Options);
SyncNamespaces\AbstractSyncNamespacesService.cs (3)
107RoslynDebug.AssertNotNull(firstDiagnostic?.Location?.SourceTree); 109var document = solution.GetRequiredDocument(firstDiagnostic.Location.SourceTree); 172.WhereAsArray(diagnostic => diagnostic.Location.SourceTree?.FilePath == document.FilePath);
ValueTracking\ValueTrackedItem.cs (2)
46Contract.ThrowIfNull(location.SourceTree); 48var document = solution.GetRequiredDocument(location.SourceTree);
ValueTracking\ValueTracker.cs (3)
202if (location.SourceTree is null) 208var sourceDoc = collector.Solution.GetRequiredDocument(location.SourceTree); 290if (definitionLocation is not { SourceTree: not null })
Microsoft.CodeAnalysis.LanguageServer.Protocol (3)
Handler\CallHierarchy\CallHierarchyHelpers.cs (1)
121location.SourceTree == syntax.SyntaxTree &&
Handler\CallHierarchy\CallHierarchyIncomingCallsHandler.cs (1)
50.GroupBy(location => solution.GetDocument(location.SourceTree)?.Id);
Handler\TypeHierarchy\TypeHierarchyHelpers.cs (1)
100location.SourceTree == syntax.SyntaxTree &&
Microsoft.CodeAnalysis.PerformanceSensitiveAnalyzers (26)
src\RoslynAnalyzers\Utilities\Compiler\Options\AnalyzerOptionsExtensions.cs (4)
40tree = symbol.Locations[0].SourceTree; 319=> options.GetDisallowedSymbolNamesWithValueOption(rule, symbol.Locations[0].SourceTree, compilation); 333=> options.GetAdditionalRequiredSuffixesOption(rule, symbol.Locations[0].SourceTree, compilation); 382=> options.GetAdditionalRequiredGenericInterfaces(rule, symbol.Locations[0].SourceTree, compilation);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\AnalysisContextExtensions.cs (4)
54=> location.SourceTree != null && context.ShouldAnalyzeSpan(location.SourceSpan, location.SourceTree); 74=> location.SourceTree != null && context.ShouldAnalyzeSpan(location.SourceSpan, location.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\LocationExtensions.cs (5)
14Contract.ThrowIfNull(location.SourceTree); 15return location.SourceTree; 37var tree = loc.SourceTree; 44return loc1.SourceTree == loc2.SourceTree && loc1.SourceSpan.IntersectsWith(loc2.SourceSpan);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.AnonymousFunctionOrDelegateSymbolKey.cs (1)
46var syntaxTree = location.SourceTree;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.BodyLevelSymbolKey.cs (2)
77var syntaxTree = locations[0]!.SourceTree; 181var firstSourceTree = locations[0]?.SourceTree;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.cs (1)
160return compilation.SyntaxTrees.Contains(firstNonNull.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyReader.cs (2)
725if (location.SourceTree != null) 728var semanticModel = Compilation.GetSemanticModel(location.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyWriter.cs (1)
262WriteString(location.SourceTree.FilePath);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService.cs (1)
493if (location.SourceTree != destinationMember.SyntaxTree)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService_FindDeclaration.cs (1)
226TryAddToWorker(declarations, checkGeneratedCode, out declaration, out availableIndices, d => d.SyntaxTree == location?.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationHelpers.cs (2)
205if (info.Context.AfterThisLocation?.SourceTree is { } afterSourceTree && 219if (info.Context.BeforeThisLocation?.SourceTree is { } beforeSourceTree &&
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\ISolutionExtensions.cs (1)
159return solution.GetDocument(location.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\ProjectExtensions.cs (1)
42var diagnosticFilePath = PathUtilities.GetDirectoryName(diagnostic?.Location.SourceTree?.FilePath ?? project.FilePath);
Microsoft.CodeAnalysis.PublicApiAnalyzers (21)
DeclarePublicApiAnalyzer.Impl.cs (1)
863var syntaxTree = location.SourceTree;
src\RoslynAnalyzers\Utilities\Compiler\Options\AnalyzerOptionsExtensions.cs (4)
40tree = symbol.Locations[0].SourceTree; 319=> options.GetDisallowedSymbolNamesWithValueOption(rule, symbol.Locations[0].SourceTree, compilation); 333=> options.GetAdditionalRequiredSuffixesOption(rule, symbol.Locations[0].SourceTree, compilation); 382=> options.GetAdditionalRequiredGenericInterfaces(rule, symbol.Locations[0].SourceTree, compilation);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\AnalysisContextExtensions.cs (4)
54=> location.SourceTree != null && context.ShouldAnalyzeSpan(location.SourceSpan, location.SourceTree); 74=> location.SourceTree != null && context.ShouldAnalyzeSpan(location.SourceSpan, location.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\LocationExtensions.cs (5)
14Contract.ThrowIfNull(location.SourceTree); 15return location.SourceTree; 37var tree = loc.SourceTree; 44return loc1.SourceTree == loc2.SourceTree && loc1.SourceSpan.IntersectsWith(loc2.SourceSpan);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.AnonymousFunctionOrDelegateSymbolKey.cs (1)
46var syntaxTree = location.SourceTree;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.BodyLevelSymbolKey.cs (2)
77var syntaxTree = locations[0]!.SourceTree; 181var firstSourceTree = locations[0]?.SourceTree;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.cs (1)
160return compilation.SyntaxTrees.Contains(firstNonNull.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyReader.cs (2)
725if (location.SourceTree != null) 728var semanticModel = Compilation.GetSemanticModel(location.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyWriter.cs (1)
262WriteString(location.SourceTree.FilePath);
Microsoft.CodeAnalysis.PublicApiAnalyzers.CodeFixes (2)
AnnotatePublicApiFix.cs (1)
126.GroupBy(d => d.Location.SourceTree);
DeclarePublicApiFix.cs (1)
257.GroupBy(d => d.Location.SourceTree);
Microsoft.CodeAnalysis.Razor.Compiler (1)
Analyzers\ComponentParameterNullableWarningSuppressor.cs (1)
36var node = diagnostic.Location.SourceTree?.GetRoot(context.CancellationToken).FindNode(diagnostic.Location.SourceSpan);
Microsoft.CodeAnalysis.Remote.Razor (1)
RemoteTagHelperSearchEngine.cs (1)
73solution.GetDocument(location.SourceTree) is { } document)
Microsoft.CodeAnalysis.Remote.ServiceHub (1)
Services\DiagnosticAnalyzer\RemoteDiagnosticAnalyzerService.cs (1)
111var document = solution.GetDocument(diagnostic.Location.SourceTree);
Microsoft.CodeAnalysis.ResxSourceGenerator (20)
src\RoslynAnalyzers\Utilities\Compiler\Options\AnalyzerOptionsExtensions.cs (4)
40tree = symbol.Locations[0].SourceTree; 319=> options.GetDisallowedSymbolNamesWithValueOption(rule, symbol.Locations[0].SourceTree, compilation); 333=> options.GetAdditionalRequiredSuffixesOption(rule, symbol.Locations[0].SourceTree, compilation); 382=> options.GetAdditionalRequiredGenericInterfaces(rule, symbol.Locations[0].SourceTree, compilation);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\AnalysisContextExtensions.cs (4)
54=> location.SourceTree != null && context.ShouldAnalyzeSpan(location.SourceSpan, location.SourceTree); 74=> location.SourceTree != null && context.ShouldAnalyzeSpan(location.SourceSpan, location.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\LocationExtensions.cs (5)
14Contract.ThrowIfNull(location.SourceTree); 15return location.SourceTree; 37var tree = loc.SourceTree; 44return loc1.SourceTree == loc2.SourceTree && loc1.SourceSpan.IntersectsWith(loc2.SourceSpan);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.AnonymousFunctionOrDelegateSymbolKey.cs (1)
46var syntaxTree = location.SourceTree;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.BodyLevelSymbolKey.cs (2)
77var syntaxTree = locations[0]!.SourceTree; 181var firstSourceTree = locations[0]?.SourceTree;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.cs (1)
160return compilation.SyntaxTrees.Contains(firstNonNull.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyReader.cs (2)
725if (location.SourceTree != null) 728var semanticModel = Compilation.GetSemanticModel(location.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyWriter.cs (1)
262WriteString(location.SourceTree.FilePath);
Microsoft.CodeAnalysis.Test.Utilities (5)
Diagnostics\CommonDiagnosticAnalyzers.cs (1)
1806context.TryGetValue(location.SourceTree, _treeValueProvider, out var isGeneratedCode);
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)) 579assertText.AppendLine(l.SourceTree.GetText().Lines.GetLineFromPosition(l.SourceSpan.Start).ToString());
Microsoft.CodeAnalysis.VisualBasic (22)
Binding\Binder_Expressions.vb (2)
3025declarationLocation.SourceTree Is referenceLocation.SourceTree Then
CommandLine\CommandLineDiagnosticFormatter.vb (1)
132text = diagnostic.Location.SourceTree.GetText()
Compilation\VisualBasicDiagnosticFilter.vb (3)
138Dim tree = location?.SourceTree 204If location IsNot Nothing AndAlso location.SourceTree IsNot Nothing AndAlso 205location.SourceTree.GetWarningState(id, location.SourceSpan.Start) = ReportDiagnostic.Suppress Then
Emit\PEModuleBuilder.vb (1)
282Dim doc As Cci.DebugSourceDocument = DebugDocumentsBuilder.TryGetDebugDocument(span.Path, basePath:=location.SourceTree.FilePath)
Locations\LocationExtensions.vb (1)
38Return DirectCast(location.SourceTree, VisualBasicSyntaxTree)
Locations\VBLocation.vb (1)
32Return DirectCast(Me.SourceTree, VisualBasicSyntaxTree)
Symbols\LexicalSortKey.vb (3)
187If first.SourceTree IsNot Nothing AndAlso first.SourceTree Is second.SourceTree Then
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 62methodLoc.SourceTree Is tree AndAlso
Symbols\Source\SourceAssemblySymbol.vb (1)
494Dim compilationUnitSyntax = DirectCast(rootNs.Location.SourceTree.GetRoot(), CompilationUnitSyntax)
Symbols\Source\SourceMemberContainerTypeSymbol.vb (1)
1363Return containingSourceNamespace.GetDeclarationSpelling(firstLocation.SourceTree, firstLocation.SourceSpan.Start)
Symbols\Source\SourceModuleSymbol.vb (1)
1025Dim tree = DirectCast(loc.SourceTree, VisualBasicSyntaxTree)
Symbols\Source\SourceNamedTypeSymbol.vb (1)
547If location.IsInSource AndAlso Not DirectCast(location.SourceTree, VisualBasicSyntaxTree).IsEmbeddedSyntaxTree Then
Symbols\Symbol.vb (2)
385If location.IsInSource AndAlso location.SourceTree IsNot Nothing Then 386Dim token = CType(location.SourceTree.GetRoot().FindToken(location.SourceSpan.Start), SyntaxToken)
Microsoft.CodeAnalysis.Workspaces (65)
CodeFixes\FixAllOccurrences\BatchFixAllProvider.cs (2)
118.OrderBy(d => d.Location.SourceTree!.FilePath) 147var document = solution.GetRequiredDocument(diagnostic.Location.SourceTree!);
Diagnostics\DiagnosticAnalysisResultBuilder.cs (2)
112=> AddDiagnostic(ref _lazySemanticLocals, diagnostic.Location.SourceTree, diagnostic); 150var diagnosticTree = diagnostic.Location.SourceTree;
Diagnostics\DiagnosticData.cs (2)
212var document = project.GetDocument(diagnostic.Location.SourceTree); 300builder.Add(CreateLocation(document.Project.Solution.GetDocument(location.SourceTree), location));
Diagnostics\Extensions.cs (6)
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)); 451if (diagnostic.Location.SourceTree != null) 453return targetTextDocument.Project.GetDocument(diagnostic.Location.SourceTree) == targetTextDocument;
Editing\SymbolEditor.cs (1)
324var sourceTree = location.SourceTree;
FindSymbols\FindReferences\Finders\AbstractMemberScopedReferenceFinder.cs (1)
41var document = project.GetDocument(location.SourceTree);
FindSymbols\FindReferences\Finders\ImplicitConstructorInitializerSymbolReferenceFinder.cs (1)
75constructor.Locations.First(loc => loc.SourceTree == constructorNode.SyntaxTree && constructorNode.Span.IntersectsWith(loc.SourceSpan)),
FindSymbols\ReferenceLocation.cs (2)
136var thisPath = this.Location.SourceTree?.FilePath; 137var otherPath = other.Location.SourceTree?.FilePath;
ReassignedVariable\AbstractReassignedVariableService.cs (1)
248if (parameterLocation.SourceTree == semanticModel.SyntaxTree)
Recommendations\AbstractRecommendationServiceRunner.cs (1)
352static (candidateLocation, declarationSyntax) => !(declarationSyntax.SyntaxTree == candidateLocation.SourceTree &&
Rename\ConflictEngine\ConflictResolver.cs (10)
184Contract.ThrowIfNull(implicitUsageConflict.SourceTree); 186implicitUsageConflict.SourceSpan, conflictResolution.OldSolution.GetRequiredDocument(implicitUsageConflict.SourceTree).Id, RelatedLocationType.UnresolvableConflict)); 208Contract.ThrowIfNull(implicitConflict.SourceTree); 210implicitConflict.SourceSpan, conflictResolution.OldSolution.GetRequiredDocument(implicitConflict.SourceTree).Id, RelatedLocationType.UnresolvableConflict)); 304Contract.ThrowIfNull(languageConflict.SourceTree); 306languageConflict.SourceSpan, conflictResolution.OldSolution.GetRequiredDocument(languageConflict.SourceTree).Id, RelatedLocationType.UnresolvableConflict)); 331Contract.ThrowIfNull(oldLocation.SourceTree); 333oldLocation.SourceSpan, conflictResolution.OldSolution.GetRequiredDocument(oldLocation.SourceTree).Id, RelatedLocationType.UnresolvableConflict)); 373renameDeclarationLocations[symbolIndex] = new RenameDeclarationLocationReference(solution.GetDocumentId(location.SourceTree), location.SourceSpan, overriddenFromMetadata, locations.Length); 412.OrderBy(l => l.IsInSource ? solution.GetDocumentId(l.SourceTree)!.Id : Guid.Empty)
Rename\ConflictEngine\ConflictResolver.Session.cs (4)
63_documentIdOfRenameSymbolDeclaration = renameLocationSet.Solution.GetRequiredDocument(renameSymbolDeclarationLocation.SourceTree!).Id; 243.Select(l => conflictResolution.OldSolution.GetRequiredDocument(l.SourceTree!)) 582var overridingSymbol = await SymbolFinder.FindSymbolAtPositionAsync(solution.GetRequiredDocument(newLocation.SourceTree), newLocation.SourceSpan.Start, cancellationToken: _cancellationToken).ConfigureAwait(false); 691var allRenamedDocuments = _renameLocationSet.Locations.Select(loc => loc.Location.SourceTree!).Distinct().Select(solution.GetRequiredDocument);
Rename\RenameUtilities.cs (2)
125return renameLocations.Select(l => solution.GetRequiredDocument(l.Location.SourceTree!)); 129var documentsOfRenameSymbolDeclaration = symbol.Locations.SelectAsArray(l => l.IsInSource, l => solution.GetRequiredDocument(l.SourceTree!));
Rename\SymbolicRenameLocations.ReferenceProcessing.cs (6)
202var syntaxFacts = solution.GetRequiredDocument(firstLocation.SourceTree!) 235var document = solution.GetRequiredDocument(location.SourceTree); 285Contract.ThrowIfNull(aliasLocation.SourceTree); 286results.Add(new RenameLocation(aliasLocation, solution.GetRequiredDocument(aliasLocation.SourceTree).Id)); 308Contract.ThrowIfNull(aliasLocation.SourceTree); 309results.Add(new RenameLocation(aliasLocation, solution.GetRequiredDocument(aliasLocation.SourceTree).Id));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\AnalysisContextExtensions.cs (4)
54=> location.SourceTree != null && context.ShouldAnalyzeSpan(location.SourceSpan, location.SourceTree); 74=> location.SourceTree != null && context.ShouldAnalyzeSpan(location.SourceSpan, location.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\LocationExtensions.cs (5)
14Contract.ThrowIfNull(location.SourceTree); 15return location.SourceTree; 37var tree = loc.SourceTree; 44return loc1.SourceTree == loc2.SourceTree && loc1.SourceSpan.IntersectsWith(loc2.SourceSpan);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.AnonymousFunctionOrDelegateSymbolKey.cs (1)
46var syntaxTree = location.SourceTree;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.BodyLevelSymbolKey.cs (2)
77var syntaxTree = locations[0]!.SourceTree; 181var firstSourceTree = locations[0]?.SourceTree;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.cs (1)
160return compilation.SyntaxTrees.Contains(firstNonNull.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyReader.cs (2)
725if (location.SourceTree != null) 728var semanticModel = Compilation.GetSemanticModel(location.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyWriter.cs (1)
262WriteString(location.SourceTree.FilePath);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService.cs (1)
493if (location.SourceTree != destinationMember.SyntaxTree)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService_FindDeclaration.cs (1)
226TryAddToWorker(declarations, checkGeneratedCode, out declaration, out availableIndices, d => d.SyntaxTree == location?.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationHelpers.cs (2)
205if (info.Context.AfterThisLocation?.SourceTree is { } afterSourceTree && 219if (info.Context.BeforeThisLocation?.SourceTree is { } beforeSourceTree &&
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\ISolutionExtensions.cs (1)
159return solution.GetDocument(location.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\ProjectExtensions.cs (1)
42var diagnosticFilePath = PathUtilities.GetDirectoryName(diagnostic?.Location.SourceTree?.FilePath ?? project.FilePath);
Workspace\Solution\SolutionCompilationState.SymbolToProjectId.cs (2)
82var syntaxTree = symbol.Locations[0].SourceTree; 177Locations: [{ SourceTree: var typeParameterSourceTree }, ..],
Microsoft.Extensions.Logging.Generators (1)
LoggerMessageGenerator.Roslyn4.0.cs (1)
121if ((seen ??= new()).Add((diagnostic.Id, diagnostic.Location?.SourceSpan, diagnostic.Location?.SourceTree?.FilePath, diagnostic.GetMessage())))
Microsoft.Extensions.Options.SourceGeneration (4)
Parser.cs (4)
101Location lowerLocationInCompilation = modelTypeLocation is not null && modelTypeLocation.SourceTree is not null && _compilation.ContainsSyntaxTree(modelTypeLocation.SourceTree) 296Location location = memberLocation is not null && memberLocation.SourceTree is not null && _compilation.ContainsSyntaxTree(memberLocation.SourceTree)
Microsoft.Gen.BuildMetadata.Unit.Tests (1)
test\Generators\Shared\RoslynTestUtils.cs (1)
484var doc = proj.GetDocument(d.Location.SourceTree);
Microsoft.Gen.ComplianceReports.Unit.Tests (1)
test\Generators\Shared\RoslynTestUtils.cs (1)
484var doc = proj.GetDocument(d.Location.SourceTree);
Microsoft.Gen.ContextualOptions.Unit.Tests (1)
test\Generators\Shared\RoslynTestUtils.cs (1)
484var doc = proj.GetDocument(d.Location.SourceTree);
Microsoft.Gen.Logging.Unit.Tests (1)
test\Generators\Shared\RoslynTestUtils.cs (1)
484var doc = proj.GetDocument(d.Location.SourceTree);
Microsoft.Gen.MetadataExtractor.Unit.Tests (1)
test\Generators\Shared\RoslynTestUtils.cs (1)
484var doc = proj.GetDocument(d.Location.SourceTree);
Microsoft.Gen.Metrics.Unit.Tests (1)
test\Generators\Shared\RoslynTestUtils.cs (1)
484var doc = proj.GetDocument(d.Location.SourceTree);
Microsoft.Gen.MetricsReports.Unit.Tests (1)
test\Generators\Shared\RoslynTestUtils.cs (1)
484var doc = proj.GetDocument(d.Location.SourceTree);
Microsoft.Interop.ComInterfaceGenerator (5)
Analyzers\ComClassGeneratorDiagnosticsAnalyzer.cs (1)
74var declarationNode = (TypeDeclarationSyntax)location.SourceTree.GetRoot().FindNode(location.SourceSpan);
ComMethodInfo.cs (2)
109if (methodLocation.SourceTree == interfaceLocation.SourceTree
src\libraries\System.Runtime.InteropServices\gen\Common\ConvertToSourceGeneratedInteropFixer.cs (2)
195DocumentId documentId = solutionEditor.OriginalSolution.GetDocumentId(diagnostic.Location.SourceTree)!; 196SyntaxNode root = await diagnostic.Location.SourceTree.GetRootAsync(ct).ConfigureAwait(false);
Microsoft.Interop.LibraryImportGenerator (8)
Analyzers\CustomMarshallerAttributeFixer.cs (3)
36Document doc = fixAllContext.Solution.GetDocument(diagnostic.Location.SourceTree); 42SyntaxNode root = await diagnostic.Location.SourceTree.GetRootAsync(fixAllContext.CancellationToken).ConfigureAwait(false); 183attr.ApplicationSyntaxReference.SyntaxTree == locationInAttribute.SourceTree
Analyzers\LibraryImportDiagnosticsAnalyzer.cs (1)
189|| diagnostic.Location.SourceTree == userSyntaxTree)
Analyzers\ShapeBreakingDiagnosticSuppressor.cs (2)
35SemanticModel model = context.GetSemanticModel(diagnostic.Location.SourceTree); 36ISymbol diagnosedSymbol = model.GetDeclaredSymbol(diagnostic.Location.SourceTree.GetRoot(context.CancellationToken).FindNode(diagnostic.Location.SourceSpan), context.CancellationToken);
src\libraries\System.Runtime.InteropServices\gen\Common\ConvertToSourceGeneratedInteropFixer.cs (2)
195DocumentId documentId = solutionEditor.OriginalSolution.GetDocumentId(diagnostic.Location.SourceTree)!; 196SyntaxNode root = await diagnostic.Location.SourceTree.GetRootAsync(ct).ConfigureAwait(false);
Microsoft.Interop.LibraryImportGenerator.Downlevel (1)
DownlevelLibraryImportDiagnosticsAnalyzer.cs (1)
188|| diagnostic.Location.SourceTree == userSyntaxTree)
Microsoft.Maui.Controls.BindingSourceGen (2)
BindingInvocationDescription.cs (2)
22 => location.SourceTree is null 24 : new SourceCodeLocation(location.SourceTree.FilePath, location.SourceSpan, location.GetLineSpan().Span);
Microsoft.ML.InternalCodeAnalyzer (1)
RelaxTestNamingSuppressor.cs (1)
36if (!(diagnostic.Location.SourceTree is { } tree))
Microsoft.VisualStudio.LanguageServices (11)
CallHierarchy\CallHierarchyDetail.cs (5)
31_documentId = workspace.CurrentSolution.GetDocumentId(location.SourceTree); 35File = location.SourceTree.FilePath; 44var start = location.SourceTree.GetText().Lines[lineSpan.StartLinePosition.Line].Start; 45var end = location.SourceTree.GetText().Lines[lineSpan.EndLinePosition.Line].End; 46return location.SourceTree.GetText().GetSubText(TextSpan.FromBounds(start, end)).ToString();
Diagnostics\VisualStudioVenusSpanMappingService.cs (2)
73if (location.SourceTree != null) 75return location.SourceTree.GetText().Lines;
MoveStaticMembers\VisualStudioMoveStaticMembersOptionsService.cs (1)
154private static string GetFile(Location loc) => loc.SourceTree!.FilePath;
Venus\ContainedLanguageCodeSupport.cs (2)
209var position = type.Locations.First(loc => loc.SourceTree == targetSyntaxTree).SourceSpan.Start; 490var typeLocation = type.Locations.FirstOrDefault(d => d.SourceTree == containingTree);
Workspace\VisualStudioSymbolNavigationService.cs (1)
63var targetDocument = solution.GetDocument(sourceLocation.SourceTree);
Microsoft.VisualStudio.LanguageServices.Implementation (4)
CodeModel\AbstractCodeModelService.cs (1)
594var document = project.GetDocument(location.SourceTree);
CodeModel\Collections\OverloadsCollection.cs (1)
74var document = solution.GetDocument(location.SourceTree);
CodeModel\Collections\PartialTypeCollection.cs (1)
57var document = solution.GetDocument(location.SourceTree);
RoslynVisualStudioWorkspace.cs (1)
158var tree = sourceLocation.SourceTree;
Roslyn.Diagnostics.Analyzers (31)
AbstractCreateTestAccessor`1.cs (1)
44var location = typeSymbol.Locations.FirstOrDefault(location => location.IsInSource && Equals(location.SourceTree, semanticModel.SyntaxTree));
AbstractExposeMemberForTesting`1.cs (1)
50var location = testAccessorType.Locations.FirstOrDefault(location => location.IsInSource && Equals(location.SourceTree, semanticModel.SyntaxTree));
DefaultableTypeShouldHaveDefaultableFieldsAnalyzer.cs (1)
98var semanticModel = originalContext.Compilation.GetSemanticModel(field.Locations[0].SourceTree);
NamedTypeFullNameNotNullSuppressor.cs (1)
41if (diagnostic.Location.SourceTree is not { } tree)
RelaxTestNamingSuppressor.cs (1)
44if (diagnostic.Location.SourceTree is not { } tree)
src\RoslynAnalyzers\Utilities\Compiler\Options\AnalyzerOptionsExtensions.cs (4)
40tree = symbol.Locations[0].SourceTree; 319=> options.GetDisallowedSymbolNamesWithValueOption(rule, symbol.Locations[0].SourceTree, compilation); 333=> options.GetAdditionalRequiredSuffixesOption(rule, symbol.Locations[0].SourceTree, compilation); 382=> options.GetAdditionalRequiredGenericInterfaces(rule, symbol.Locations[0].SourceTree, compilation);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\AnalysisContextExtensions.cs (4)
54=> location.SourceTree != null && context.ShouldAnalyzeSpan(location.SourceSpan, location.SourceTree); 74=> location.SourceTree != null && context.ShouldAnalyzeSpan(location.SourceSpan, location.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\LocationExtensions.cs (5)
14Contract.ThrowIfNull(location.SourceTree); 15return location.SourceTree; 37var tree = loc.SourceTree; 44return loc1.SourceTree == loc2.SourceTree && loc1.SourceSpan.IntersectsWith(loc2.SourceSpan);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.AnonymousFunctionOrDelegateSymbolKey.cs (1)
46var syntaxTree = location.SourceTree;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.BodyLevelSymbolKey.cs (2)
77var syntaxTree = locations[0]!.SourceTree; 181var firstSourceTree = locations[0]?.SourceTree;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.cs (1)
160return compilation.SyntaxTrees.Contains(firstNonNull.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyReader.cs (2)
725if (location.SourceTree != null) 728var semanticModel = Compilation.GetSemanticModel(location.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyWriter.cs (1)
262WriteString(location.SourceTree.FilePath);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService.cs (1)
493if (location.SourceTree != destinationMember.SyntaxTree)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService_FindDeclaration.cs (1)
226TryAddToWorker(declarations, checkGeneratedCode, out declaration, out availableIndices, d => d.SyntaxTree == location?.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationHelpers.cs (2)
205if (info.Context.AfterThisLocation?.SourceTree is { } afterSourceTree && 219if (info.Context.BeforeThisLocation?.SourceTree is { } beforeSourceTree &&
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\ISolutionExtensions.cs (1)
159return solution.GetDocument(location.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\ProjectExtensions.cs (1)
42var diagnosticFilePath = PathUtilities.GetDirectoryName(diagnostic?.Location.SourceTree?.FilePath ?? project.FilePath);
Roslyn.Diagnostics.CSharp.Analyzers (3)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SemanticFacts\CSharpSemanticFacts.cs (2)
80if (symbol.Locations.Any(static (loc, location) => loc.SourceTree == location.SourceTree && loc.SourceSpan.Contains(location.SourceSpan), location))
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationHelpers.cs (1)
204? contextLocation.SourceTree
System.Text.Json.SourceGeneration (2)
Helpers\RoslynExtensions.cs (2)
41=> location.SourceTree != null && compilation.ContainsSyntaxTree(location.SourceTree);
Test.Utilities (20)
src\RoslynAnalyzers\Utilities\Compiler\Options\AnalyzerOptionsExtensions.cs (4)
40tree = symbol.Locations[0].SourceTree; 319=> options.GetDisallowedSymbolNamesWithValueOption(rule, symbol.Locations[0].SourceTree, compilation); 333=> options.GetAdditionalRequiredSuffixesOption(rule, symbol.Locations[0].SourceTree, compilation); 382=> options.GetAdditionalRequiredGenericInterfaces(rule, symbol.Locations[0].SourceTree, compilation);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\AnalysisContextExtensions.cs (4)
54=> location.SourceTree != null && context.ShouldAnalyzeSpan(location.SourceSpan, location.SourceTree); 74=> location.SourceTree != null && context.ShouldAnalyzeSpan(location.SourceSpan, location.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\LocationExtensions.cs (5)
14Contract.ThrowIfNull(location.SourceTree); 15return location.SourceTree; 37var tree = loc.SourceTree; 44return loc1.SourceTree == loc2.SourceTree && loc1.SourceSpan.IntersectsWith(loc2.SourceSpan);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.AnonymousFunctionOrDelegateSymbolKey.cs (1)
46var syntaxTree = location.SourceTree;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.BodyLevelSymbolKey.cs (2)
77var syntaxTree = locations[0]!.SourceTree; 181var firstSourceTree = locations[0]?.SourceTree;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.cs (1)
160return compilation.SyntaxTrees.Contains(firstNonNull.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyReader.cs (2)
725if (location.SourceTree != null) 728var semanticModel = Compilation.GetSemanticModel(location.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyWriter.cs (1)
262WriteString(location.SourceTree.FilePath);
Text.Analyzers (26)
src\RoslynAnalyzers\Utilities\Compiler\Options\AnalyzerOptionsExtensions.cs (4)
40tree = symbol.Locations[0].SourceTree; 319=> options.GetDisallowedSymbolNamesWithValueOption(rule, symbol.Locations[0].SourceTree, compilation); 333=> options.GetAdditionalRequiredSuffixesOption(rule, symbol.Locations[0].SourceTree, compilation); 382=> options.GetAdditionalRequiredGenericInterfaces(rule, symbol.Locations[0].SourceTree, compilation);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\AnalysisContextExtensions.cs (4)
54=> location.SourceTree != null && context.ShouldAnalyzeSpan(location.SourceSpan, location.SourceTree); 74=> location.SourceTree != null && context.ShouldAnalyzeSpan(location.SourceSpan, location.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\LocationExtensions.cs (5)
14Contract.ThrowIfNull(location.SourceTree); 15return location.SourceTree; 37var tree = loc.SourceTree; 44return loc1.SourceTree == loc2.SourceTree && loc1.SourceSpan.IntersectsWith(loc2.SourceSpan);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.AnonymousFunctionOrDelegateSymbolKey.cs (1)
46var syntaxTree = location.SourceTree;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.BodyLevelSymbolKey.cs (2)
77var syntaxTree = locations[0]!.SourceTree; 181var firstSourceTree = locations[0]?.SourceTree;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.cs (1)
160return compilation.SyntaxTrees.Contains(firstNonNull.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyReader.cs (2)
725if (location.SourceTree != null) 728var semanticModel = Compilation.GetSemanticModel(location.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyWriter.cs (1)
262WriteString(location.SourceTree.FilePath);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService.cs (1)
493if (location.SourceTree != destinationMember.SyntaxTree)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService_FindDeclaration.cs (1)
226TryAddToWorker(declarations, checkGeneratedCode, out declaration, out availableIndices, d => d.SyntaxTree == location?.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationHelpers.cs (2)
205if (info.Context.AfterThisLocation?.SourceTree is { } afterSourceTree && 219if (info.Context.BeforeThisLocation?.SourceTree is { } beforeSourceTree &&
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\ISolutionExtensions.cs (1)
159return solution.GetDocument(location.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\ProjectExtensions.cs (1)
42var diagnosticFilePath = PathUtilities.GetDirectoryName(diagnostic?.Location.SourceTree?.FilePath ?? project.FilePath);