1 override of SourceTree
Microsoft.CodeAnalysis (1)
Diagnostic\SourceLocation.cs (1)
72public override SyntaxTree SourceTree
456 references to SourceTree
ConfigurationSchemaGenerator (1)
RuntimeSource\SourceGenerators\DiagnosticInfo.cs (1)
34=> Location.Create(location.SourceTree?.FilePath ?? "", location.SourceSpan, location.GetLineSpan().Span);
dotnet-format (6)
Analyzers\AnalyzerFormatter.cs (1)
178var document = solution.GetDocument(diagnostic.Location.SourceTree);
Analyzers\AnalyzerRunner.cs (2)
87diagnostic.Location.SourceTree != null && 88formattableDocumentPaths.Contains(diagnostic.Location.SourceTree.FilePath))
Analyzers\SolutionCodeFixApplier.cs (3)
33.Where(diagnostic => diagnostic.Location.SourceTree != null) 41var document = solution.GetDocument(diagnostic.Location.SourceTree); 112return projectDiagnostics.Where(diagnostic => diagnostic.Location.SourceTree?.FilePath == document.FilePath).ToImmutableArray();
GenerateDocumentationAndConfigFiles (26)
src\roslyn\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\roslyn\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\roslyn\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\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.AnonymousFunctionOrDelegateSymbolKey.cs (1)
46var syntaxTree = location.SourceTree;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.BodyLevelSymbolKey.cs (2)
77var syntaxTree = locations[0]!.SourceTree; 181var firstSourceTree = locations[0]?.SourceTree;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.cs (1)
160return compilation.SyntaxTrees.Contains(firstNonNull.SourceTree);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyReader.cs (2)
725if (location.SourceTree != null) 728var semanticModel = Compilation.GetSemanticModel(location.SourceTree);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyWriter.cs (1)
262WriteString(location.SourceTree.FilePath);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService.cs (1)
493if (location.SourceTree != destinationMember.SyntaxTree)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService_FindDeclaration.cs (1)
226TryAddToWorker(declarations, checkGeneratedCode, out declaration, out availableIndices, d => d.SyntaxTree == location?.SourceTree);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationHelpers.cs (2)
205if (info.Context.AfterThisLocation?.SourceTree is { } afterSourceTree && 219if (info.Context.BeforeThisLocation?.SourceTree is { } beforeSourceTree &&
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\ISolutionExtensions.cs (1)
159return solution.GetDocument(location.SourceTree);
src\roslyn\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!;
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.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)
907if (location.SourceTree != null) 909partialTrees.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\roslyn\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\roslyn\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\roslyn\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\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.AnonymousFunctionOrDelegateSymbolKey.cs (1)
46var syntaxTree = location.SourceTree;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.BodyLevelSymbolKey.cs (2)
77var syntaxTree = locations[0]!.SourceTree; 181var firstSourceTree = locations[0]?.SourceTree;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.cs (1)
160return compilation.SyntaxTrees.Contains(firstNonNull.SourceTree);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyReader.cs (2)
725if (location.SourceTree != null) 728var semanticModel = Compilation.GetSemanticModel(location.SourceTree);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyWriter.cs (1)
262WriteString(location.SourceTree.FilePath);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService.cs (1)
493if (location.SourceTree != destinationMember.SyntaxTree)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService_FindDeclaration.cs (1)
226TryAddToWorker(declarations, checkGeneratedCode, out declaration, out availableIndices, d => d.SyntaxTree == location?.SourceTree);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationHelpers.cs (2)
205if (info.Context.AfterThisLocation?.SourceTree is { } afterSourceTree && 219if (info.Context.BeforeThisLocation?.SourceTree is { } beforeSourceTree &&
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\ISolutionExtensions.cs (1)
159return solution.GetDocument(location.SourceTree);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\ProjectExtensions.cs (1)
42var diagnosticFilePath = PathUtilities.GetDirectoryName(diagnostic?.Location.SourceTree?.FilePath ?? project.FilePath);
Microsoft.CodeAnalysis.AnalyzerUtilities (20)
src\roslyn\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\roslyn\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\roslyn\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\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.AnonymousFunctionOrDelegateSymbolKey.cs (1)
46var syntaxTree = location.SourceTree;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.BodyLevelSymbolKey.cs (2)
77var syntaxTree = locations[0]!.SourceTree; 181var firstSourceTree = locations[0]?.SourceTree;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.cs (1)
160return compilation.SyntaxTrees.Contains(firstNonNull.SourceTree);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyReader.cs (2)
725if (location.SourceTree != null) 728var semanticModel = Compilation.GetSemanticModel(location.SourceTree);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyWriter.cs (1)
262WriteString(location.SourceTree.FilePath);
Microsoft.CodeAnalysis.CodeStyle (25)
src\roslyn\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\roslyn\src\Analyzers\Core\Analyzers\NamingStyle\NamingStyleDiagnosticAnalyzerBase.cs (2)
58var sourceTree = symbolContext.Symbol.Locations.FirstOrDefault()?.SourceTree; 86if (symbol?.Locations.FirstOrDefault()?.SourceTree is not { } sourceTree)
src\roslyn\src\Analyzers\Core\Analyzers\RemoveUnnecessarySuppressions\AbstractRemoveUnnecessaryPragmaSuppressionsDiagnosticAnalyzer.cs (2)
497if (diagnostic.Location.SourceTree == tree) 555Debug.Assert(diagnostic.Location.SourceTree == tree);
src\roslyn\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\roslyn\src\Analyzers\Core\Analyzers\RemoveUnusedParametersAndValues\AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.SymbolStartAnalyzer.cs (1)
133var option = analyzerOptions.GetAnalyzerOptions(location.SourceTree!).UnusedParameters;
src\roslyn\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\roslyn\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\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.AnonymousFunctionOrDelegateSymbolKey.cs (1)
46var syntaxTree = location.SourceTree;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.BodyLevelSymbolKey.cs (2)
77var syntaxTree = locations[0]!.SourceTree; 181var firstSourceTree = locations[0]?.SourceTree;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.cs (1)
160return compilation.SyntaxTrees.Contains(firstNonNull.SourceTree);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyReader.cs (2)
725if (location.SourceTree != null) 728var semanticModel = Compilation.GetSemanticModel(location.SourceTree);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyWriter.cs (1)
262WriteString(location.SourceTree.FilePath);
Microsoft.CodeAnalysis.CodeStyle.Fixes (9)
src\roslyn\src\Analyzers\Core\CodeFixes\AddParameter\AddParameterService.cs (1)
101declarationLocation => solution.GetRequiredDocument(declarationLocation.Locations[0].SourceTree!));
src\roslyn\src\Analyzers\Core\CodeFixes\MatchFolderAndNamespace\AbstractChangeNamespaceToMatchFolderCodeFixProvider.CustomFixAllProvider.cs (1)
78.GroupBy(diagnostic => diagnostic.Location.SourceTree)
src\roslyn\src\Analyzers\Core\CodeFixes\UseIsNullCheck\AbstractUseIsNullForReferenceEqualsCodeFixProvider.cs (1)
40var title = GetTitle(negated, diagnostic.Location.SourceTree!.Options);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService.cs (1)
493if (location.SourceTree != destinationMember.SyntaxTree)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService_FindDeclaration.cs (1)
226TryAddToWorker(declarations, checkGeneratedCode, out declaration, out availableIndices, d => d.SyntaxTree == location?.SourceTree);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationHelpers.cs (2)
205if (info.Context.AfterThisLocation?.SourceTree is { } afterSourceTree && 219if (info.Context.BeforeThisLocation?.SourceTree is { } beforeSourceTree &&
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\ISolutionExtensions.cs (1)
159return solution.GetDocument(location.SourceTree);
src\roslyn\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; 4758var 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)
118=> ((result & modifier) != 0) && !Binder.CheckFeatureAvailability(errorLocation.SourceTree, featureID, diagnostics, errorLocation); 156LanguageVersion availableVersion = ((CSharpParseOptions)errorLocation.SourceTree.Options).LanguageVersion; 183Binder.CheckFeatureAvailability(errorLocation.SourceTree, MessageID.IDS_DefaultInterfaceImplementation, diagnostics, errorLocation); 218Debug.Assert(location.SourceTree is not null); 220LanguageVersion availableVersion = ((CSharpParseOptions)location.SourceTree.Options).LanguageVersion; 232Debug.Assert(location.SourceTree is not null); 234LanguageVersion availableVersion = ((CSharpParseOptions)location.SourceTree.Options).LanguageVersion;
Symbols\Source\SourceMemberContainerSymbol.cs (1)
5300var 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\roslyn\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\roslyn\src\Analyzers\CSharp\CodeFixes\MakeMethodAsynchronous\CSharpMakeMethodAsynchronousCodeFixProvider.cs (2)
46if (diagnostic.Location.SourceTree is null) 49var root = diagnostic.Location.SourceTree.GetRoot(cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseIsNullCheck\CSharpUseIsNullCheckForCastAndEqualityOperatorCodeFixProvider.cs (1)
42var title = GetTitle(negated, diagnostic.Location.SourceTree!.Options);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationHelpers.cs (1)
204? contextLocation.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\roslyn\src\Analyzers\CSharp\CodeFixes\MakeMethodAsynchronous\CSharpMakeMethodAsynchronousCodeFixProvider.cs (2)
46if (diagnostic.Location.SourceTree is null) 49var root = diagnostic.Location.SourceTree.GetRoot(cancellationToken);
src\roslyn\src\Analyzers\CSharp\CodeFixes\UseIsNullCheck\CSharpUseIsNullCheckForCastAndEqualityOperatorCodeFixProvider.cs (1)
42var title = GetTitle(negated, diagnostic.Location.SourceTree!.Options);
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\roslyn\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\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationHelpers.cs (1)
204? contextLocation.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 (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\roslyn\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\roslyn\src\Analyzers\Core\Analyzers\NamingStyle\NamingStyleDiagnosticAnalyzerBase.cs (2)
58var sourceTree = symbolContext.Symbol.Locations.FirstOrDefault()?.SourceTree; 86if (symbol?.Locations.FirstOrDefault()?.SourceTree is not { } sourceTree)
src\roslyn\src\Analyzers\Core\Analyzers\RemoveUnnecessarySuppressions\AbstractRemoveUnnecessaryPragmaSuppressionsDiagnosticAnalyzer.cs (2)
497if (diagnostic.Location.SourceTree == tree) 555Debug.Assert(diagnostic.Location.SourceTree == tree);
src\roslyn\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\roslyn\src\Analyzers\Core\Analyzers\RemoveUnusedParametersAndValues\AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.SymbolStartAnalyzer.cs (1)
133var option = analyzerOptions.GetAnalyzerOptions(location.SourceTree!).UnusedParameters;
src\roslyn\src\Analyzers\Core\CodeFixes\AddParameter\AddParameterService.cs (1)
101declarationLocation => solution.GetRequiredDocument(declarationLocation.Locations[0].SourceTree!));
src\roslyn\src\Analyzers\Core\CodeFixes\MatchFolderAndNamespace\AbstractChangeNamespaceToMatchFolderCodeFixProvider.CustomFixAllProvider.cs (1)
78.GroupBy(diagnostic => diagnostic.Location.SourceTree)
src\roslyn\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.Razor.Compiler (1)
Analyzers\ComponentParameterNullableWarningSuppressor.cs (1)
36var node = diagnostic.Location.SourceTree?.GetRoot(context.CancellationToken).FindNode(diagnostic.Location.SourceSpan);
Microsoft.CodeAnalysis.ResxSourceGenerator (20)
src\roslyn\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\roslyn\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\roslyn\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\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.AnonymousFunctionOrDelegateSymbolKey.cs (1)
46var syntaxTree = location.SourceTree;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.BodyLevelSymbolKey.cs (2)
77var syntaxTree = locations[0]!.SourceTree; 181var firstSourceTree = locations[0]?.SourceTree;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.cs (1)
160return compilation.SyntaxTrees.Contains(firstNonNull.SourceTree);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyReader.cs (2)
725if (location.SourceTree != null) 728var semanticModel = Compilation.GetSemanticModel(location.SourceTree);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyWriter.cs (1)
262WriteString(location.SourceTree.FilePath);
Microsoft.CodeAnalysis.VisualBasic (22)
Binding\Binder_Expressions.vb (2)
3029declarationLocation.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\roslyn\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\roslyn\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\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.AnonymousFunctionOrDelegateSymbolKey.cs (1)
46var syntaxTree = location.SourceTree;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.BodyLevelSymbolKey.cs (2)
77var syntaxTree = locations[0]!.SourceTree; 181var firstSourceTree = locations[0]?.SourceTree;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.cs (1)
160return compilation.SyntaxTrees.Contains(firstNonNull.SourceTree);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyReader.cs (2)
725if (location.SourceTree != null) 728var semanticModel = Compilation.GetSemanticModel(location.SourceTree);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyWriter.cs (1)
262WriteString(location.SourceTree.FilePath);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService.cs (1)
493if (location.SourceTree != destinationMember.SyntaxTree)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService_FindDeclaration.cs (1)
226TryAddToWorker(declarations, checkGeneratedCode, out declaration, out availableIndices, d => d.SyntaxTree == location?.SourceTree);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationHelpers.cs (2)
205if (info.Context.AfterThisLocation?.SourceTree is { } afterSourceTree && 219if (info.Context.BeforeThisLocation?.SourceTree is { } beforeSourceTree &&
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\ISolutionExtensions.cs (1)
159return solution.GetDocument(location.SourceTree);
src\roslyn\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\runtime\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\runtime\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))
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\roslyn\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\roslyn\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\roslyn\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\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.AnonymousFunctionOrDelegateSymbolKey.cs (1)
46var syntaxTree = location.SourceTree;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.BodyLevelSymbolKey.cs (2)
77var syntaxTree = locations[0]!.SourceTree; 181var firstSourceTree = locations[0]?.SourceTree;
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.cs (1)
160return compilation.SyntaxTrees.Contains(firstNonNull.SourceTree);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyReader.cs (2)
725if (location.SourceTree != null) 728var semanticModel = Compilation.GetSemanticModel(location.SourceTree);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.SymbolKeyWriter.cs (1)
262WriteString(location.SourceTree.FilePath);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService.cs (1)
493if (location.SourceTree != destinationMember.SyntaxTree)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService_FindDeclaration.cs (1)
226TryAddToWorker(declarations, checkGeneratedCode, out declaration, out availableIndices, d => d.SyntaxTree == location?.SourceTree);
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationHelpers.cs (2)
205if (info.Context.AfterThisLocation?.SourceTree is { } afterSourceTree && 219if (info.Context.BeforeThisLocation?.SourceTree is { } beforeSourceTree &&
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\Extensions\ISolutionExtensions.cs (1)
159return solution.GetDocument(location.SourceTree);
src\roslyn\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\roslyn\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\roslyn\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);