1 override of SourceTree
Microsoft.CodeAnalysis (1)
Diagnostic\SourceLocation.cs (1)
72public override SyntaxTree SourceTree
692 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 (25)
src\RoslynAnalyzers\Utilities\Compiler\Options\AnalyzerOptionsExtensions.cs (4)
42tree = symbol.Locations[0].SourceTree; 321=> options.GetDisallowedSymbolNamesWithValueOption(rule, symbol.Locations[0].SourceTree, compilation); 335=> options.GetAdditionalRequiredSuffixesOption(rule, symbol.Locations[0].SourceTree, compilation); 384=> 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)
213TryAddToWorker(declarations, checkGeneratedCode, out declaration, out availableIndices, d => d.SyntaxTree == location?.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationHelpers.cs (2)
202if (info.Context.AfterThisLocation?.SourceTree is { } afterSourceTree && 218if (info.Context.BeforeThisLocation?.SourceTree is { } beforeSourceTree &&
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\ProjectExtensions.cs (1)
57var diagnosticFilePath = PathUtilities.GetDirectoryName(diagnostic?.Location.SourceTree?.FilePath ?? project.FilePath);
Metrics (21)
MetricsOutputWriter.cs (1)
86writer.WriteAttributeString("File", location.SourceTree?.FilePath ?? "UNKNOWN");
src\RoslynAnalyzers\Utilities\Compiler\Options\AnalyzerOptionsExtensions.cs (4)
42tree = symbol.Locations[0].SourceTree; 321=> options.GetDisallowedSymbolNamesWithValueOption(rule, symbol.Locations[0].SourceTree, compilation); 335=> options.GetAdditionalRequiredSuffixesOption(rule, symbol.Locations[0].SourceTree, compilation); 384=> 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)
42tree = symbol.Locations[0].SourceTree; 321=> options.GetDisallowedSymbolNamesWithValueOption(rule, symbol.Locations[0].SourceTree, compilation); 335=> options.GetAdditionalRequiredSuffixesOption(rule, symbol.Locations[0].SourceTree, compilation); 384=> 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.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)
302if (diagnostic.Location.SourceTree != filterFile.SourceTree)
DiagnosticAnalyzer\AnalyzerDriver.cs (6)
1250Debug.Assert(location.SourceTree != null); 1253if (IsGeneratedOrHiddenCodeLocation(location.SourceTree, location.SourceSpan, cancellationToken)) 1261var generatedCodeSymbolsInTree = getOrComputeGeneratedCodeSymbolsInTree(location.SourceTree, compilation, cancellationToken); 1264var model = compilation.GetSemanticModel(location.SourceTree); 1265for (var node = location.SourceTree.GetRoot(cancellationToken).FindNode(location.SourceSpan, getInnermostNodeForTie: true); 2005if (diagnostic?.Location.SourceTree is { } tree &&
DiagnosticAnalyzer\AnalyzerExecutor.AnalyzerDiagnosticReporter.cs (1)
129_contextFile.Value.SourceTree == diagnostic.Location.SourceTree;
DiagnosticAnalyzer\AnalyzerExecutor.cs (3)
1454if (syntaxRef.SyntaxTree == diagnostic.Location.SourceTree) 1562if (location.SourceTree != null && 1563!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)
163var model = _compilation.GetSemanticModel(location.SourceTree); 166for (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 (25)
src\RoslynAnalyzers\Utilities\Compiler\Options\AnalyzerOptionsExtensions.cs (4)
42tree = symbol.Locations[0].SourceTree; 321=> options.GetDisallowedSymbolNamesWithValueOption(rule, symbol.Locations[0].SourceTree, compilation); 335=> options.GetAdditionalRequiredSuffixesOption(rule, symbol.Locations[0].SourceTree, compilation); 384=> 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)
213TryAddToWorker(declarations, checkGeneratedCode, out declaration, out availableIndices, d => d.SyntaxTree == location?.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationHelpers.cs (2)
202if (info.Context.AfterThisLocation?.SourceTree is { } afterSourceTree && 218if (info.Context.BeforeThisLocation?.SourceTree is { } beforeSourceTree &&
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\ProjectExtensions.cs (1)
57var diagnosticFilePath = PathUtilities.GetDirectoryName(diagnostic?.Location.SourceTree?.FilePath ?? project.FilePath);
Microsoft.CodeAnalysis.AnalyzerUtilities (20)
src\RoslynAnalyzers\Utilities\Compiler\Options\AnalyzerOptionsExtensions.cs (4)
42tree = symbol.Locations[0].SourceTree; 321=> options.GetDisallowedSymbolNamesWithValueOption(rule, symbol.Locations[0].SourceTree, compilation); 335=> options.GetAdditionalRequiredSuffixesOption(rule, symbol.Locations[0].SourceTree, compilation); 384=> 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 (25)
src\RoslynAnalyzers\Utilities\Compiler\Options\AnalyzerOptionsExtensions.cs (4)
42tree = symbol.Locations[0].SourceTree; 321=> options.GetDisallowedSymbolNamesWithValueOption(rule, symbol.Locations[0].SourceTree, compilation); 335=> options.GetAdditionalRequiredSuffixesOption(rule, symbol.Locations[0].SourceTree, compilation); 384=> 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)
213TryAddToWorker(declarations, checkGeneratedCode, out declaration, out availableIndices, d => d.SyntaxTree == location?.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationHelpers.cs (2)
202if (info.Context.AfterThisLocation?.SourceTree is { } afterSourceTree && 218if (info.Context.BeforeThisLocation?.SourceTree is { } beforeSourceTree &&
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\ProjectExtensions.cs (1)
57var 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)
607r => r.SyntaxTree == diagnosticLocation.SourceTree && r.Span.Contains(diagnosticLocation.SourceSpan)); 661foreach (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 (8)
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)
213TryAddToWorker(declarations, checkGeneratedCode, out declaration, out availableIndices, d => d.SyntaxTree == location?.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationHelpers.cs (2)
202if (info.Context.AfterThisLocation?.SourceTree is { } afterSourceTree && 218if (info.Context.BeforeThisLocation?.SourceTree is { } beforeSourceTree &&
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\ProjectExtensions.cs (1)
57var diagnosticFilePath = PathUtilities.GetDirectoryName(diagnostic?.Location.SourceTree?.FilePath ?? project.FilePath);
Microsoft.CodeAnalysis.CSharp (51)
Binder\Binder_Symbols.cs (4)
1944if (containerResult == 0 && la.SourceTree == lb.SourceTree) return lb.SourceSpan.Start - la.SourceSpan.Start; 2025arg0 = srcSymbol.GetFirstLocation().SourceTree.FilePath; 2179arg0 = 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)
3660var filePath = location.SourceTree?.FilePath; 4594var 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)
1837if (loc.IsInSource && loc.SourceTree == this.SyntaxTree && declarationSpan.Contains(loc.SourceSpan)) 2052if (location.SourceTree == this.SyntaxTree && parameter.Span.Contains(location.SourceSpan)) 2236if (location.SourceTree == this.SyntaxTree && parameter.Span.Contains(location.SourceSpan)) 2451if (location.SourceTree != this.SyntaxTree)
Compiler\DocumentationCommentCompiler.cs (3)
421Debug.Assert(location.SourceTree!.ReportDocumentationCommentDiagnostics()); //Should be the same tree as for the symbol. 436Debug.Assert(location.SourceTree!.ReportDocumentationCommentDiagnostics()); //Should be the same tree as for the symbol. 638if (location.SourceTree.ReportDocumentationCommentDiagnostics())
Compiler\DocumentationCommentCompiler.IncludeElementExpander.cs (2)
636if (treelessSyntax.ContainsDiagnostics && sourceLocation.SourceTree.ReportDocumentationCommentDiagnostics()) 652if (sourceLocation.SourceTree.ReportDocumentationCommentDiagnostics())
Emitter\Model\PEModuleBuilder.cs (1)
454Cci.DebugSourceDocument doc = DebugDocumentsBuilder.TryGetDebugDocument(span.Path, basePath: location.SourceTree.FilePath);
SymbolDisplay\SymbolDisplayVisitor.Types.cs (1)
192: 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)
5080var languageVersion = ((CSharpParseOptions)this.GetFirstLocation().SourceTree!.Options).LanguageVersion;
Symbols\Source\SourceModuleSymbol.cs (1)
355ImmutableArray<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)
461Debug.Assert(location.SourceTree is not null); 463LanguageVersion 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)
453if (loc.IsInSource && loc.SourceTree == tree && declarationSpan.Contains(loc.SourceSpan)) 512SyntaxToken token = location.SourceTree.GetRoot().FindToken(location.SourceSpan.Start); 528SyntaxNode parent = location.SourceTree.GetRoot();
Symbols\Symbol_Attributes.cs (2)
497if (location.SourceTree == argumentLocation.SourceTree &&
Microsoft.CodeAnalysis.CSharp.CodeStyle (2)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SemanticFacts\CSharpSemanticFacts.cs (2)
72if (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)
45if (diagnostic.Location.SourceTree is null) 48var 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)
203? contextLocation.SourceTree
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (3)
Formatting\CodeCleanupTests.TestFixers.cs (3)
34var sourceTree = diagnostic.Location.SourceTree; 103var sourceTree = diagnostic.Location.SourceTree; 159var sourceTree = diagnostic.Location.SourceTree;
Microsoft.CodeAnalysis.CSharp.Emit2.UnitTests (2)
Emit\EditAndContinue\EditAndContinueTestBase.cs (2)
86var tree1 = method1.Locations[0].SourceTree; 87var 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)
35663Assert.Equal(tree, identifierBefore.Location.SourceTree); 35669Assert.Null(identifierAfter.Location.SourceTree);
Microsoft.CodeAnalysis.CSharp.Features (9)
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)
45if (diagnostic.Location.SourceTree is null) 48var 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.Semantic.UnitTests (1)
Semantics\InterceptorsTests.cs (1)
7598comp1.GetDiagnostics().Where(d => d.Location.SourceTree == interceptors).Verify(
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (8)
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);
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)
2079Assert.Equal(tree, nodeLocation.SourceTree); 2084Assert.Equal(tree, tokenLocation.SourceTree); 2089Assert.Equal(tree, triviaLocation.SourceTree); 2095Assert.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); 865var tree = location.SourceTree; 896var token = await location.SourceTree!.GetTouchingTokenAsync(location.SourceSpan.Start, cancellationToken, findInsideTrivia: true).ConfigureAwait(false); 972var token = await implicitReferenceLocation.Location.SourceTree!.GetTouchingTokenAsync(
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SemanticFacts\CSharpSemanticFacts.cs (2)
72if (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)
203? contextLocation.SourceTree
Microsoft.CodeAnalysis.EditorFeatures (4)
InlineRename\AbstractEditorInlineRenameService.SymbolRenameInfo.cs (1)
166var symbolSourceDocument = this.Document.Project.Solution.GetDocument(RenameSymbol.Locations.Single().SourceTree);
Navigation\AbstractDefinitionLocationService.cs (1)
265if (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.EditorFeatures2.UnitTests (3)
FindReferences\FindReferencesTests.vb (1)
466Return loc.IsInSource AndAlso Not loc.SourceTree.IsHiddenPosition(loc.SourceSpan.Start)
Rename\RenameEngineResult.vb (2)
225Dim documentId = ConflictResolution.OldSolution.GetDocumentId(location.SourceTree) 248Dim documentId = ConflictResolution.OldSolution.GetDocumentId(location.SourceTree)
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 (4)
103var document = solution.GetDocument(location.SourceTree); 148var documentId = solution.GetDocument(location.SourceTree)?.Id; 247var document = solution.GetDocument(commonLocation.SourceTree); 278var 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)
151RoslynDebug.Assert(location.SourceTree != null); 152if (project.GetDocument(location.SourceTree) == null) 155throw 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"); 158if (location.SourceSpan.End > location.SourceTree.Length) 161throw 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)
236var document = solution.GetDocument(location.SourceTree); 306var tree = location.SourceTree;
EditAndContinue\EmitSolutionUpdateResults.cs (2)
166Debug.Assert(SyntaxError.Location.SourceTree != null); 167return 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)
239solution.GetDocument(location.SourceTree) is { } document)
GenerateType\AbstractGenerateTypeService.State.cs (1)
304var sourceTreeToBeGeneratedIn = symbol.Locations.First(loc => loc.IsInSource).SourceTree;
GoToDefinition\GoToDefinitionFeatureHelpers.cs (1)
42if (sourceLocations.All(l => solution.GetDocument(l.SourceTree) == null))
InheritanceMargin\AbstractInheritanceMarginService_Helpers.cs (1)
742if (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)
293var 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)
223var sourceDocument = solution.GetRequiredDocument(location.SourceTree);
SemanticSearch\AbstractSemanticSearchService.cs (1)
134d => new QueryCompilationError(d.Id, d.GetMessage(), (d.Location.SourceTree == queryTree) ? d.Location.SourceSpan : default));
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)
607r => r.SyntaxTree == diagnosticLocation.SourceTree && r.Span.Contains(diagnosticLocation.SourceSpan)); 661foreach (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.Where(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.PerformanceSensitiveAnalyzers (25)
src\RoslynAnalyzers\Utilities\Compiler\Options\AnalyzerOptionsExtensions.cs (4)
42tree = symbol.Locations[0].SourceTree; 321=> options.GetDisallowedSymbolNamesWithValueOption(rule, symbol.Locations[0].SourceTree, compilation); 335=> options.GetAdditionalRequiredSuffixesOption(rule, symbol.Locations[0].SourceTree, compilation); 384=> 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)
213TryAddToWorker(declarations, checkGeneratedCode, out declaration, out availableIndices, d => d.SyntaxTree == location?.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationHelpers.cs (2)
202if (info.Context.AfterThisLocation?.SourceTree is { } afterSourceTree && 218if (info.Context.BeforeThisLocation?.SourceTree is { } beforeSourceTree &&
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\ProjectExtensions.cs (1)
57var diagnosticFilePath = PathUtilities.GetDirectoryName(diagnostic?.Location.SourceTree?.FilePath ?? project.FilePath);
Microsoft.CodeAnalysis.PublicApiAnalyzers (21)
DeclarePublicApiAnalyzer.Impl.cs (1)
832var syntaxTree = location.SourceTree;
src\RoslynAnalyzers\Utilities\Compiler\Options\AnalyzerOptionsExtensions.cs (4)
42tree = symbol.Locations[0].SourceTree; 321=> options.GetDisallowedSymbolNamesWithValueOption(rule, symbol.Locations[0].SourceTree, compilation); 335=> options.GetAdditionalRequiredSuffixesOption(rule, symbol.Locations[0].SourceTree, compilation); 384=> 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.Remote.ServiceHub (1)
Services\DiagnosticAnalyzer\RemoteDiagnosticAnalyzerService.cs (1)
93var document = solution.GetDocument(diagnostic.Location.SourceTree);
Microsoft.CodeAnalysis.ResxSourceGenerator (20)
src\RoslynAnalyzers\Utilities\Compiler\Options\AnalyzerOptionsExtensions.cs (4)
42tree = symbol.Locations[0].SourceTree; 321=> options.GetDisallowedSymbolNamesWithValueOption(rule, symbol.Locations[0].SourceTree, compilation); 335=> options.GetAdditionalRequiredSuffixesOption(rule, symbol.Locations[0].SourceTree, compilation); 384=> 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)
1362Return containingSourceNamespace.GetDeclarationSpelling(firstLocation.SourceTree, firstLocation.SourceSpan.Start)
Symbols\Source\SourceModuleSymbol.vb (1)
1025Dim tree = DirectCast(loc.SourceTree, VisualBasicSyntaxTree)
Symbols\Source\SourceNamedTypeSymbol.vb (1)
544If location.IsInSource AndAlso Not DirectCast(location.SourceTree, VisualBasicSyntaxTree).IsEmbeddedSyntaxTree Then
Symbols\Symbol.vb (2)
372If location.IsInSource AndAlso location.SourceTree IsNot Nothing Then 373Dim token = CType(location.SourceTree.GetRoot().FindToken(location.SourceSpan.Start), SyntaxToken)
Microsoft.CodeAnalysis.VisualBasic.Symbol.UnitTests (30)
SymbolsTests\Source\SourceSymbolTests.vb (30)
335Assert.Equal("a.vb", locs(0).SourceTree.FilePath) 336Assert.Equal("C", locs(0).SourceTree.GetText().ToString(locs(0).SourceSpan)) 337Assert.Equal("b.vb", locs(1).SourceTree.FilePath) 338Assert.Equal("C", locs(1).SourceTree.GetText().ToString(locs(1).SourceSpan)) 344Assert.Equal("a.vb", locs(0).SourceTree.FilePath) 345Assert.Equal("D", locs(0).SourceTree.GetText().ToString(locs(0).SourceSpan)) 346Assert.Equal("b.vb", locs(1).SourceTree.FilePath) 347Assert.Equal("D", locs(1).SourceTree.GetText().ToString(locs(1).SourceSpan)) 353Assert.Equal("a.vb", locs(0).SourceTree.FilePath) 354Assert.Equal("T", locs(0).SourceTree.GetText().ToString(locs(0).SourceSpan)) 355Assert.Equal("b.vb", locs(1).SourceTree.FilePath) 356Assert.Equal("T", locs(1).SourceTree.GetText().ToString(locs(1).SourceSpan)) 361Assert.Equal("a.vb", locs(0).SourceTree.FilePath) 362Assert.Equal("m1", locs(0).SourceTree.GetText().ToString(locs(0).SourceSpan)) 367Assert.Equal("a.vb", locs(0).SourceTree.FilePath) 368Assert.Equal("x", locs(0).SourceTree.GetText().ToString(locs(0).SourceSpan)) 373Assert.Equal("a.vb", locs(0).SourceTree.FilePath) 374Assert.Equal("v1$", locs(0).SourceTree.GetText().ToString(locs(0).SourceSpan)) 380Assert.Equal("a.vb", locs(0).SourceTree.FilePath) 381Assert.Equal("N1", locs(0).SourceTree.GetText().ToString(locs(0).SourceSpan)) 382Assert.Equal("b.vb", locs(1).SourceTree.FilePath) 383Assert.Equal("N1", locs(1).SourceTree.GetText().ToString(locs(1).SourceSpan)) 389Assert.Equal("a.vb", locs(0).SourceTree.FilePath) 390Assert.Equal("N2", locs(0).SourceTree.GetText().ToString(locs(0).SourceSpan)) 391Assert.Equal("b.vb", locs(1).SourceTree.FilePath) 392Assert.Equal("N2", locs(1).SourceTree.GetText().ToString(locs(1).SourceSpan)) 398Assert.Equal("a.vb", locs(0).SourceTree.FilePath) 399Assert.Equal("N3", locs(0).SourceTree.GetText().ToString(locs(0).SourceSpan)) 400Assert.Equal("b.vb", locs(1).SourceTree.FilePath) 401Assert.Equal("N3", locs(1).SourceTree.GetText().ToString(locs(1).SourceSpan))
Microsoft.CodeAnalysis.VisualBasic.Test.Utilities (3)
CompilationTestUtils.vb (3)
1008Dim lineText As String = GetLineText(sourceLocation.SourceTree.GetText(), sourceLocation.SourceSpan.Start, offsetInLine) 1051Dim sourceTree1 = loc1.SourceTree 1052Dim sourceTree2 = loc2.SourceTree
Microsoft.CodeAnalysis.Workspaces (63)
CodeFixes\CodeFix.cs (1)
64var document = Project.GetDocument(diagnostic.Location.SourceTree);
CodeFixes\FixAllOccurrences\BatchFixAllProvider.cs (2)
118.OrderBy(d => d.Location.SourceTree!.FilePath) 147var document = solution.GetRequiredDocument(diagnostic.Location.SourceTree!);
Diagnostics\DiagnosticAnalysisResultBuilder.cs (2)
115=> AddDiagnostic(ref _lazySemanticLocals, diagnostic.Location.SourceTree, diagnostic); 153var diagnosticTree = diagnostic.Location.SourceTree;
Diagnostics\DiagnosticData.cs (1)
277builder.Add(CreateLocation(document.Project.Solution.GetDocument(location.SourceTree), location));
Diagnostics\Extensions.cs (6)
218var diagnostics = additionalPragmaSuppressionDiagnostics.WhereAsArray(d => d.Location.SourceTree == treeToAnalyze); 225foreach (var group in additionalPragmaSuppressionDiagnostics.GroupBy(d => d.Location.SourceTree!)) 278Debug.Assert(diagnostics.All(d => d.Location.SourceTree == tree)); 290Debug.Assert(diagnostics.All(d => d.Location.SourceTree == tree)); 550if (diagnostic.Location.SourceTree != null) 552return targetTextDocument.Project.GetDocument(diagnostic.Location.SourceTree) == targetTextDocument;
Editing\SymbolEditor.cs (1)
325var sourceTree = location.SourceTree;
FindSymbols\FindReferences\Finders\AbstractMemberScopedReferenceFinder.cs (1)
41var document = project.GetDocument(location.SourceTree);
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)
190Contract.ThrowIfNull(implicitUsageConflict.SourceTree); 192implicitUsageConflict.SourceSpan, conflictResolution.OldSolution.GetRequiredDocument(implicitUsageConflict.SourceTree).Id, RelatedLocationType.UnresolvableConflict)); 214Contract.ThrowIfNull(implicitConflict.SourceTree); 216implicitConflict.SourceSpan, conflictResolution.OldSolution.GetRequiredDocument(implicitConflict.SourceTree).Id, RelatedLocationType.UnresolvableConflict)); 308Contract.ThrowIfNull(languageConflict.SourceTree); 310languageConflict.SourceSpan, conflictResolution.OldSolution.GetRequiredDocument(languageConflict.SourceTree).Id, RelatedLocationType.UnresolvableConflict)); 335Contract.ThrowIfNull(oldLocation.SourceTree); 337oldLocation.SourceSpan, conflictResolution.OldSolution.GetRequiredDocument(oldLocation.SourceTree).Id, RelatedLocationType.UnresolvableConflict)); 377renameDeclarationLocations[symbolIndex] = new RenameDeclarationLocationReference(solution.GetDocumentId(location.SourceTree), location.SourceSpan, overriddenFromMetadata, locations.Length); 416.OrderBy(l => l.IsInSource ? solution.GetDocumentId(l.SourceTree)!.Id : Guid.Empty)
Rename\ConflictEngine\ConflictResolver.Session.cs (4)
66_documentIdOfRenameSymbolDeclaration = renameLocationSet.Solution.GetRequiredDocument(renameSymbolDeclarationLocation.SourceTree!).Id; 246.Select(l => conflictResolution.OldSolution.GetRequiredDocument(l.SourceTree!)) 613var overridingSymbol = await SymbolFinder.FindSymbolAtPositionAsync(solution.GetRequiredDocument(newLocation.SourceTree), newLocation.SourceSpan.Start, cancellationToken: _cancellationToken).ConfigureAwait(false); 720var allRenamedDocuments = _renameLocationSet.Locations.Select(loc => loc.Location.SourceTree!).Distinct().Select(solution.GetRequiredDocument);
Rename\RenameUtilities.cs (1)
91var documentsOfRenameSymbolDeclaration = symbol.Locations.Where(l => l.IsInSource).Select(l => solution.GetRequiredDocument(l.SourceTree!));
Rename\SymbolicRenameLocations.ReferenceProcessing.cs (6)
201var syntaxFacts = solution.GetRequiredDocument(firstLocation.SourceTree!) 234var document = solution.GetRequiredDocument(location.SourceTree); 274Contract.ThrowIfNull(aliasLocation.SourceTree); 275results.Add(new RenameLocation(aliasLocation, solution.GetRequiredDocument(aliasLocation.SourceTree).Id)); 297Contract.ThrowIfNull(aliasLocation.SourceTree); 298results.Add(new RenameLocation(aliasLocation, solution.GetRequiredDocument(aliasLocation.SourceTree).Id));
Shared\Extensions\ISolutionExtensions.cs (1)
47return solution.GetDocument(location.SourceTree);
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)
213TryAddToWorker(declarations, checkGeneratedCode, out declaration, out availableIndices, d => d.SyntaxTree == location?.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationHelpers.cs (2)
202if (info.Context.AfterThisLocation?.SourceTree is { } afterSourceTree && 218if (info.Context.BeforeThisLocation?.SourceTree is { } beforeSourceTree &&
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\ProjectExtensions.cs (1)
57var diagnosticFilePath = PathUtilities.GetDirectoryName(diagnostic?.Location.SourceTree?.FilePath ?? project.FilePath);
Workspace\Solution\SolutionCompilationState.SymbolToProjectId.cs (2)
82var syntaxTree = symbol.Locations[0].SourceTree; 179Locations: [{ SourceTree: var typeParameterSourceTree }, ..],
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.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 (4)
ComMethodInfo.cs (2)
109if (methodLocation.SourceTree == interfaceLocation.SourceTree
src\libraries\System.Runtime.InteropServices\gen\Common\ConvertToSourceGeneratedInteropFixer.cs (2)
198DocumentId documentId = solutionEditor.OriginalSolution.GetDocumentId(diagnostic.Location.SourceTree)!; 200SyntaxNode root = await diagnostic.Location.SourceTree.GetRootAsync(ct).ConfigureAwait(false);
Microsoft.Interop.LibraryImportGenerator (7)
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\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)
198DocumentId documentId = solutionEditor.OriginalSolution.GetDocumentId(diagnostic.Location.SourceTree)!; 200SyntaxNode root = await diagnostic.Location.SourceTree.GetRootAsync(ct).ConfigureAwait(false);
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);
Roslyn.Diagnostics.Analyzers (30)
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)
42tree = symbol.Locations[0].SourceTree; 321=> options.GetDisallowedSymbolNamesWithValueOption(rule, symbol.Locations[0].SourceTree, compilation); 335=> options.GetAdditionalRequiredSuffixesOption(rule, symbol.Locations[0].SourceTree, compilation); 384=> 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)
213TryAddToWorker(declarations, checkGeneratedCode, out declaration, out availableIndices, d => d.SyntaxTree == location?.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationHelpers.cs (2)
202if (info.Context.AfterThisLocation?.SourceTree is { } afterSourceTree && 218if (info.Context.BeforeThisLocation?.SourceTree is { } beforeSourceTree &&
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\ProjectExtensions.cs (1)
57var diagnosticFilePath = PathUtilities.GetDirectoryName(diagnostic?.Location.SourceTree?.FilePath ?? project.FilePath);
Roslyn.Diagnostics.CSharp.Analyzers (3)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SemanticFacts\CSharpSemanticFacts.cs (2)
72if (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)
203? contextLocation.SourceTree
System.Text.Json.SourceGeneration (3)
Helpers\RoslynExtensions.cs (2)
41=> location.SourceTree != null && compilation.ContainsSyntaxTree(location.SourceTree);
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);
Test.Utilities (20)
src\RoslynAnalyzers\Utilities\Compiler\Options\AnalyzerOptionsExtensions.cs (4)
42tree = symbol.Locations[0].SourceTree; 321=> options.GetDisallowedSymbolNamesWithValueOption(rule, symbol.Locations[0].SourceTree, compilation); 335=> options.GetAdditionalRequiredSuffixesOption(rule, symbol.Locations[0].SourceTree, compilation); 384=> 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 (25)
src\RoslynAnalyzers\Utilities\Compiler\Options\AnalyzerOptionsExtensions.cs (4)
42tree = symbol.Locations[0].SourceTree; 321=> options.GetDisallowedSymbolNamesWithValueOption(rule, symbol.Locations[0].SourceTree, compilation); 335=> options.GetAdditionalRequiredSuffixesOption(rule, symbol.Locations[0].SourceTree, compilation); 384=> 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)
213TryAddToWorker(declarations, checkGeneratedCode, out declaration, out availableIndices, d => d.SyntaxTree == location?.SourceTree);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationHelpers.cs (2)
202if (info.Context.AfterThisLocation?.SourceTree is { } afterSourceTree && 218if (info.Context.BeforeThisLocation?.SourceTree is { } beforeSourceTree &&
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\ProjectExtensions.cs (1)
57var diagnosticFilePath = PathUtilities.GetDirectoryName(diagnostic?.Location.SourceTree?.FilePath ?? project.FilePath);