6 implementations of DeclaringSyntaxReferences
Microsoft.CodeAnalysis.CodeStyle.Fixes (1)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationSymbol.cs (1)
156public ImmutableArray<SyntaxReference> DeclaringSyntaxReferences
Microsoft.CodeAnalysis.CSharp (2)
Symbols\PublicModel\PreprocessingSymbol.cs (1)
62ImmutableArray<SyntaxReference> ISymbol.DeclaringSyntaxReferences => ImmutableArray<SyntaxReference>.Empty;
Symbols\PublicModel\Symbol.cs (1)
112ImmutableArray<SyntaxReference> ISymbol.DeclaringSyntaxReferences
Microsoft.CodeAnalysis.Features (1)
MetadataAsSource\AbstractMetadataAsSourceService.AbstractWrappedSymbol.cs (1)
43public ImmutableArray<SyntaxReference> DeclaringSyntaxReferences => _symbol.DeclaringSyntaxReferences;
Microsoft.CodeAnalysis.VisualBasic (1)
Symbols\Symbol.vb (1)
1301Private ReadOnly Property ISymbol_DeclaringSyntaxReferences As ImmutableArray(Of SyntaxReference) Implements ISymbol.DeclaringSyntaxReferences
Microsoft.CodeAnalysis.Workspaces (1)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationSymbol.cs (1)
156public ImmutableArray<SyntaxReference> DeclaringSyntaxReferences
476 references to DeclaringSyntaxReferences
ILLink.RoslynAnalyzer (2)
TrimAnalysis\DiagnosticContext.cs (2)
66 if (symbol.DeclaringSyntaxReferences.Length == 0 76 symbolLocation = symbol.DeclaringSyntaxReferences[0].GetSyntax ().GetLocation ();
Microsoft.AspNetCore.Analyzers (1)
CompilationFeatureDetector.cs (1)
36var syntaxReferences = configureMethod.DeclaringSyntaxReferences;
Microsoft.AspNetCore.App.Analyzers (11)
Kestrel\ListenOnIPv6AnyAnalyzer.cs (1)
79var localVariableDeclaration = localReferenceOperation.Local.DeclaringSyntaxReferences.FirstOrDefault();
RouteEmbeddedLanguage\RoutePatternHighlighter.cs (2)
76foreach (var item in matchingParameter.DeclaringSyntaxReferences) 87foreach (var item in methodSymbol.DeclaringSyntaxReferences)
RouteHandlers\AtMostOneFromBodyAttribute.cs (2)
50if (symbol.DeclaringSyntaxReferences.Length > 0) 52var syntax = symbol.DeclaringSyntaxReferences[0].GetSyntax(context.CancellationToken);
RouteHandlers\DetectMismatchedParameterOptionality.cs (1)
35var location = parameter.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax().GetLocation();
RouteHandlers\DisallowMvcBindArgumentsOnParameters.cs (2)
30if (!parameter.DeclaringSyntaxReferences.IsEmpty) 32var syntax = parameter.DeclaringSyntaxReferences[0].GetSyntax(context.CancellationToken);
RouteHandlers\DisallowNonParsableComplexTypesOnParameters.cs (1)
47var syntax = (ParameterSyntax)handlerDelegateParameter.DeclaringSyntaxReferences[0].GetSyntax(context.CancellationToken);
RouteHandlers\RouteHandlerAnalyzer.cs (2)
124if (!methodReference.Method.DeclaringSyntaxReferences.IsEmpty) 126var syntaxReference = methodReference.Method.DeclaringSyntaxReferences.Single();
Microsoft.AspNetCore.App.SourceGenerators (1)
PublicTopLevelProgramGenerator.cs (1)
32.Select(static (symbol, _) => symbol is { DeclaringSyntaxReferences: { Length: 1 } declaringSyntaxReferences } ? declaringSyntaxReferences.Single() : null)
Microsoft.AspNetCore.Components.Analyzers (4)
ComponentParameterAnalyzer.cs (2)
151if (symbol.DeclaringSyntaxReferences.Length == 1 && 152symbol.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken) is PropertyDeclarationSyntax syntax &&
InternalUsageAnalyzer.cs (2)
168symbolForDiagnostic.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax().GetLocation() ?? Location.None, 178symbolForDiagnostic.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax().GetLocation() ?? Location.None,
Microsoft.AspNetCore.Components.SdkAnalyzers (2)
InternalUsageAnalyzer.cs (2)
168symbolForDiagnostic.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax().GetLocation() ?? Location.None, 178symbolForDiagnostic.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax().GetLocation() ?? Location.None,
Microsoft.AspNetCore.Http.RequestDelegateGenerator (1)
StaticRouteHandlerModel\InvocationOperationExtensions.cs (1)
99foreach (var syntaxReference in symbol.DeclaringSyntaxReferences)
Microsoft.CodeAnalysis (4)
Compilation\IImportScope.cs (1)
14/// cref="ISymbol.DeclaringSyntaxReferences"/> on the <see cref="IAliasSymbol"/> itself. For <see cref="Imports"/>
DiagnosticAnalyzer\AnalyzerDriver.cs (1)
2285foreach (var declaringRef in symbol.DeclaringSyntaxReferences)
DiagnosticAnalyzer\SymbolDeclaredCompilationEvent.cs (1)
44static self => self.Symbol.DeclaringSyntaxReferences,
SourceGeneration\GeneratedCodeUtilities.cs (1)
31if (symbol.DeclaringSyntaxReferences.Length > 1)
Microsoft.CodeAnalysis.CodeStyle (29)
src\Analyzers\Core\Analyzers\Helpers\HashCodeAnalyzer\HashCodeAnalyzer.cs (1)
67if (method.Locations.Length != 1 || method.DeclaringSyntaxReferences.Length != 1)
src\Analyzers\Core\Analyzers\MatchFolderAndNamespace\AbstractMatchFolderAndNamespaceDiagnosticAnalyzer.cs (1)
182if (symbol is ITypeSymbol typeSymbol && typeSymbol.DeclaringSyntaxReferences.Length > 1)
src\Analyzers\Core\Analyzers\RemoveUnusedMembers\AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs (1)
563var fadingLocation = member.DeclaringSyntaxReferences.FirstOrDefault(
src\Analyzers\Core\Analyzers\RemoveUnusedParametersAndValues\AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.SymbolStartAnalyzer.cs (2)
78foreach (var syntaxRef in namedTypeSymbol.DeclaringSyntaxReferences) 263var methodSyntax = method.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax(cancellationToken);
src\Analyzers\Core\Analyzers\UseAutoProperty\AbstractUseAutoPropertyAnalyzer.cs (5)
144DeclaringSyntaxReferences.Length: 1, 194if (!namedType.DeclaringSyntaxReferences.Select(d => d.SyntaxTree).Distinct().Any(tree => 321if (field.DeclaringSyntaxReferences is [var fieldReference]) 350if (property.DeclaringSyntaxReferences.Length != 1) 528Field.DeclaringSyntaxReferences.Length: 1,
src\Analyzers\Core\Analyzers\UseSystemHashCode\UseSystemHashCodeDiagnosticAnalyzer.cs (1)
78var declarationLocation = context.OwningSymbol.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken).GetLocation();
src\Compilers\Core\Portable\SourceGeneration\GeneratedCodeUtilities.cs (1)
31if (symbol.DeclaringSyntaxReferences.Length > 1)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\IParameterSymbolExtensions.cs (9)
27DeclaringSyntaxReferences.Length: > 0, 31DeclaringSyntaxReferences.Length: > 0, 37var parameterSyntax = parameter.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken); 38var constructorSyntax = constructor.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken); 39if (containingType.DeclaringSyntaxReferences.Any(static (r, arg) => r.GetSyntax(arg.cancellationToken) == arg.constructorSyntax, (constructorSyntax, cancellationToken))) 44if (member is IPropertySymbol { DeclaringSyntaxReferences.Length: > 0 } property && 45property.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken) == parameterSyntax) 63DeclaringSyntaxReferences: [var constructorReference, ..], 69return containingType.DeclaringSyntaxReferences.Any(static (r, arg) => r.GetSyntax(arg.cancellationToken) == arg.constructorSyntax, (constructorSyntax, cancellationToken));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\ISymbolExtensions.cs (1)
605var declarationSyntax = symbol.DeclaringSyntaxReferences.Select(r => r.GetSyntax()).FirstOrDefault();
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.AliasSymbolKey.cs (1)
22visitor.WriteString(symbol.DeclaringSyntaxReferences.FirstOrDefault()?.SyntaxTree.FilePath ?? "");
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.BodyLevelSymbolKey.cs (4)
23Contract.ThrowIfTrue(symbol.DeclaringSyntaxReferences.IsEmpty && symbol.Locations.IsEmpty); 33foreach (var syntaxRef in symbol.DeclaringSyntaxReferences) 62Contract.ThrowIfTrue(symbol.DeclaringSyntaxReferences.IsEmpty && symbol.Locations.IsEmpty); 105foreach (var reference in container.DeclaringSyntaxReferences)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.NamedTypeSymbolKey.cs (2)
23? symbol.DeclaringSyntaxReferences[0].SyntaxTree.FilePath 182type.DeclaringSyntaxReferences[0].SyntaxTree.FilePath != filePath)
Microsoft.CodeAnalysis.CodeStyle.Fixes (7)
src\Analyzers\Core\CodeFixes\AddParameter\AddParameterService.cs (1)
194if (parameter.ContainingSymbol is not IMethodSymbol { MethodKind: MethodKind.Constructor, DeclaringSyntaxReferences: [var reference] } constructor)
src\Analyzers\Core\CodeFixes\ImplementInterface\ImplementHelpers.cs (2)
70if (field.DeclaringSyntaxReferences is [var syntaxRef, ..]) 86if (property.DeclaringSyntaxReferences is [var syntaxRef, ..])
src\Analyzers\Core\CodeFixes\MakeTypePartial\AbstractMakeTypePartialCodeFixProvider.cs (1)
46foreach (var reference in symbol.DeclaringSyntaxReferences)
src\Analyzers\Core\CodeFixes\UnsealClass\AbstractUnsealClassCodeFixProvider.cs (2)
44if (definition is not null && definition.DeclaringSyntaxReferences.Length > 0) 50c => UnsealDeclarationsAsync(document.Project.Solution, definition.DeclaringSyntaxReferences, c),
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\InitializeParameter\AbstractInitializerParameterService.cs (1)
88if (parameter is { DeclaringSyntaxReferences: [var parameterReference] })
Microsoft.CodeAnalysis.CSharp.CodeStyle (25)
src\Analyzers\CSharp\Analyzers\ConvertProgram\ConvertProgramAnalysis_TopLevelStatements.cs (1)
101if (containingType.DeclaringSyntaxReferences.Length > 1)
src\Analyzers\CSharp\Analyzers\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionDiagnosticAnalyzer.Analyzer.cs (1)
91{ Kind: SymbolKind.Local, DeclaringSyntaxReferences: { Length: 1 } syntaxRefs })
src\Analyzers\CSharp\Analyzers\InlineDeclaration\CSharpInlineDeclarationDiagnosticAnalyzer.cs (1)
139var localReference = outLocalSymbol.DeclaringSyntaxReferences.FirstOrDefault();
src\Analyzers\CSharp\Analyzers\MakeLocalFunctionStatic\MakeLocalFunctionStaticHelper.cs (1)
32var node = calledLocationFunction.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax();
src\Analyzers\CSharp\Analyzers\MakeStructMemberReadOnly\CSharpMakeStructMemberReadOnlyAnalyzer.cs (3)
62DeclaringSyntaxReferences: [var reference, ..], 187owningMethod.AssociatedSymbol is IPropertySymbol { DeclaringSyntaxReferences: [var reference, ..] } && 194var methodReference = owningMethod.DeclaringSyntaxReferences[0];
src\Analyzers\CSharp\Analyzers\MakeStructReadOnly\CSharpMakeStructReadOnlyDiagnosticAnalyzer.cs (2)
89if (typeSymbol.DeclaringSyntaxReferences is not [var typeReference, ..]) 113if (ev.AddMethod is { DeclaringSyntaxReferences.Length: 0 })
src\Analyzers\CSharp\Analyzers\NamingStyle\CSharpNamingStyleDiagnosticAnalyzer.cs (1)
31&& symbol.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax() is ParameterSyntax
src\Analyzers\CSharp\Analyzers\QualifyMemberAccess\CSharpQualifyMemberAccessDiagnosticAnalyzer.cs (1)
56containingSymbol.DeclaringSyntaxReferences
src\Analyzers\CSharp\Analyzers\RemoveUnusedMembers\CSharpRemoveUnusedMembersDiagnosticAnalyzer.cs (1)
28return namedType.DeclaringSyntaxReferences
src\Analyzers\CSharp\Analyzers\UseAutoProperty\CSharpUseAutoPropertyAnalyzer.cs (3)
208var declaration = getMethod.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken); 231var setAccessor = setMethod.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken) as AccessorDeclarationSyntax; 263var syntax = accessor.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken);
src\Analyzers\CSharp\Analyzers\UsePatternMatching\CSharpAsAndNullCheckDiagnosticAnalyzer.cs (1)
323declarator = localSymbol?.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax() as VariableDeclaratorSyntax;
src\Analyzers\CSharp\Analyzers\UsePrimaryConstructor\CSharpUsePrimaryConstructorDiagnosticAnalyzer.cs (4)
105if (member.DeclaringSyntaxReferences is not [var memberReference, ..]) 263if (namedType.DeclaringSyntaxReferences is not [var reference, ..]) 357if (constructor.DeclaringSyntaxReferences is not [var constructorReference]) 521if (operation is ILocalReferenceOperation { Local.DeclaringSyntaxReferences: [var syntaxRef, ..] } &&
src\Analyzers\CSharp\Analyzers\UseSystemThreadingLock\CSharpUseSystemThreadingLockDiagnosticAnalyzer.cs (1)
96DeclaringSyntaxReferences: [var fieldSyntaxReference],
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ITypeSymbolExtensions.cs (1)
53c => c.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax() is RecordDeclarationSyntax or ClassDeclarationSyntax or StructDeclarationSyntax);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SemanticFacts\CSharpSemanticFacts.cs (3)
95var enumDecl = namedTypeSymbol.DeclaringSyntaxReferences.Select(r => r.GetSyntax()).OfType<EnumDeclarationSyntax>().FirstOrDefault(); 232foreach (var syntaxRef in typeSymbol.DeclaringSyntaxReferences) 374foreach (var syntaxReference in symbol.DeclaringSyntaxReferences)
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (19)
src\Analyzers\CSharp\CodeFixes\ConvertToAsync\CSharpConvertToAsyncMethodCodeFixProvider.cs (1)
76var methodReference = methodSymbol.DeclaringSyntaxReferences.FirstOrDefault();
src\Analyzers\CSharp\CodeFixes\ConvertToRecord\ConvertToRecordHelpers.cs (2)
315=> member.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax() == 316param.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax());
src\Analyzers\CSharp\CodeFixes\GenerateConstructor\CSharpGenerateConstructorService.cs (1)
188if (constructor.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken) is ConstructorDeclarationSyntax constructorDeclarationSyntax &&
src\Analyzers\CSharp\CodeFixes\Nullable\CSharpDeclareAsNullableCodeFixProvider.cs (7)
174if (symbol is ILocalSymbol { DeclaringSyntaxReferences.Length: > 0 } local) 176var syntax = local.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken); 184else if (symbol is IFieldSymbol { IsImplicitlyDeclared: false, DeclaringSyntaxReferences.Length: > 0 } field) 187var syntax = field.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken); 202else if (symbol is IPropertySymbol { DeclaringSyntaxReferences.Length: > 0 } property) 204var syntax = property.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken); 304if (parameterSymbol?.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax(cancellationToken) is ParameterSyntax parameterSyntax &&
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationHelpers.cs (2)
273if (info.Context.ReuseSyntax && symbol.DeclaringSyntaxReferences.Length == 1) 275var reusableSyntaxNode = symbol.DeclaringSyntaxReferences[0].GetSyntax();
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ITypeSymbolExtensions.cs (1)
99foreach (var reference in containingType.DeclaringSyntaxReferences)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpSymbolDeclarationService.cs (1)
26? symbol.DeclaringSyntaxReferences
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\InitializeParameter\InitializeParameterHelpers.cs (4)
59foreach (var syntaxRef in property.DeclaringSyntaxReferences) 79foreach (var syntaxRef in field.DeclaringSyntaxReferences) 104var documents = namedType.DeclaringSyntaxReferences 255var node = accessor.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken);
Microsoft.CodeAnalysis.CSharp.EditorFeatures (1)
GoToBase\CSharpGoToBaseService.cs (1)
29if (constructor.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax(cancellationToken) is not ConstructorDeclarationSyntax constructorDeclaration)
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (1)
SymbolKey\SymbolKeyTestBase.cs (1)
128foreach (var node in symbol.DeclaringSyntaxReferences.Select(d => d.GetSyntax()))
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (23)
Diagnostics\GetDiagnosticsTests.cs (1)
1725var diag = CodeAnalysis.Diagnostic.Create(Descriptor, field.DeclaringSyntaxReferences[0].GetLocation());
Semantics\OutVarTests.cs (3)
968Assert.Equal(variableDeclaratorSyntax, symbol.DeclaringSyntaxReferences.Single().GetSyntax()); 1142Assert.Equal(variableDesignationSyntax, symbol.DeclaringSyntaxReferences.Single().GetSyntax()); 32735Assert.Equal(variableDesignationSyntax, symbol.DeclaringSyntaxReferences.Single().GetSyntax());
Semantics\PatternMatchingTestBase.cs (5)
83Assert.Equal(designation, symbol.DeclaringSyntaxReferences.Single().GetSyntax()); 144Assert.Equal(designation, symbol.DeclaringSyntaxReferences.Single().GetSyntax()); 170Assert.Equal(declarator, symbol.DeclaringSyntaxReferences.Single().GetSyntax()); 184Assert.Equal(designation, symbol.DeclaringSyntaxReferences.Single().GetSyntax()); 247Assert.Equal(designation, symbol.DeclaringSyntaxReferences.Single().GetSyntax());
Semantics\PrimaryConstructorTests.cs (9)
3802Assert.Same(literal.SyntaxTree, context.ContainingSymbol.DeclaringSyntaxReferences.Single().SyntaxTree); 3828Assert.Same(equalsValue.SyntaxTree, context.ContainingSymbol.DeclaringSyntaxReferences.Single().SyntaxTree); 3846Assert.Same(initializer.SyntaxTree, context.ContainingSymbol.DeclaringSyntaxReferences.Single().SyntaxTree); 3877Assert.Same(baseType.SyntaxTree, context.ContainingSymbol.DeclaringSyntaxReferences.Single().SyntaxTree); 3904Assert.Same(@class.SyntaxTree, context.ContainingSymbol.DeclaringSyntaxReferences.Single().SyntaxTree); 5291Assert.Same(literal.SyntaxTree, context.ContainingSymbol!.DeclaringSyntaxReferences.Single().SyntaxTree); 5309Assert.Same(equalsValue.SyntaxTree, context.ContainingSymbol!.DeclaringSyntaxReferences.Single().SyntaxTree); 5327Assert.Same(initializer.SyntaxTree, context.ContainingSymbol!.DeclaringSyntaxReferences.Single().SyntaxTree); 5356Assert.Same(record.SyntaxTree, context.ContainingSymbol!.DeclaringSyntaxReferences.Single().SyntaxTree);
Semantics\RecordTests.cs (5)
26287Assert.Same(literal.SyntaxTree, context.ContainingSymbol!.DeclaringSyntaxReferences.Single().SyntaxTree); 26313Assert.Same(equalsValue.SyntaxTree, context.ContainingSymbol!.DeclaringSyntaxReferences.Single().SyntaxTree); 26331Assert.Same(initializer.SyntaxTree, context.ContainingSymbol!.DeclaringSyntaxReferences.Single().SyntaxTree); 26362Assert.Same(baseType.SyntaxTree, context.ContainingSymbol!.DeclaringSyntaxReferences.Single().SyntaxTree); 26385Assert.Same(record.SyntaxTree, context.ContainingSymbol!.DeclaringSyntaxReferences.Single().SyntaxTree);
Microsoft.CodeAnalysis.CSharp.Features (57)
Completion\CompletionProviders\CompletionUtilities.cs (1)
169symbol.DeclaringSyntaxReferences[0].GetSyntax().Kind() == SyntaxKind.DefaultSwitchLabel)
Completion\CompletionProviders\PartialMethodCompletionProvider.cs (2)
38var declaration = (MethodDeclarationSyntax)method.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken); 84var declarations = method.DeclaringSyntaxReferences.Select(r => r.GetSyntax()).OfType<MethodDeclarationSyntax>();
Completion\CompletionProviders\PartialTypeCompletionProvider.cs (1)
72return candidates?.Where(symbol => symbol.DeclaringSyntaxReferences.Any(static (reference, cancellationToken) => IsPartialTypeDeclaration(reference.GetSyntax(cancellationToken)), cancellationToken));
ConvertLinq\ConvertForEachToLinqQuery\CSharpConvertForEachToLinqQueryProvider.cs (1)
285var memberDeclarationSyntax = memberDeclarationSymbol.DeclaringSyntaxReferences.Single().GetSyntax();
ConvertLinq\CSharpConvertLinqQueryToForEachProvider.cs (1)
781return declaredSymbol.DeclaringSyntaxReferences.Single().GetSyntax();
ConvertProgram\ConvertProgramTransform_ProgramMain.cs (1)
85var hasExistingPart = programType.DeclaringSyntaxReferences.Any(static (d, cancellationToken) => d.GetSyntax(cancellationToken) is TypeDeclarationSyntax, cancellationToken);
EditAndContinue\CSharpEditAndContinueAnalyzer.cs (4)
977var ctorInitializer = ((ConstructorDeclarationSyntax)symbol.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken)).Initializer; 992var syntaxRefs = type.DeclaringSyntaxReferences; 1015_ => selector(symbol.DeclaringSyntaxReferences)?.GetSyntax(cancellationToken) 1029return recordType.InstanceConstructors.Single(ctor => ctor.DeclaringSyntaxReferences is [var syntaxRef] && syntaxRef.GetSyntax(cancellationToken) == declaration.Parent);
EncapsulateField\CSharpEncapsulateFieldService.cs (2)
191=> field.DeclaringSyntaxReferences.Any(static d => d.GetSyntax().GetAncestor<FieldDeclarationSyntax>().Modifiers.Any(SyntaxKind.NewKeyword)); 204c => c.DeclaringSyntaxReferences.Select(d => d.GetSyntax()).OfType<ConstructorDeclarationSyntax>());
ExtractMethod\CSharpMethodExtractor.Analyzer.cs (1)
68symbol is ILocalSymbol { IsUsing: true, DeclaringSyntaxReferences: [var reference] } &&
GenerateConstructors\CSharpGenerateConstructorsCodeRefactoringProvider.cs (2)
59if (property.DeclaringSyntaxReferences.Length == 0) 62if (property.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken) is not PropertyDeclarationSyntax propertyDeclaration)
GoToDefinition\CSharpGoToDefinitionSymbolService.cs (1)
84return target.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax()?.SpanStart;
InitializeParameter\CSharpInitializeMemberFromPrimaryConstructorParameterCodeRefactoringProvider.cs (3)
103if (memberWithName is IFieldSymbol { IsConst: false, DeclaringSyntaxReferences: [var syntaxRef1, ..] } field && 112if (memberWithName is IPropertySymbol { DeclaringSyntaxReferences: [var syntaxRef2, ..] } property && 275foreach (var group in parameter.ContainingType.DeclaringSyntaxReferences.GroupBy(r => r.SyntaxTree))
InitializeParameter\CSharpInitializeMemberFromPrimaryConstructorParameterCodeRefactoringProvider_Update.cs (1)
145fieldOrProperty is TSymbol { DeclaringSyntaxReferences: [var syntaxReference, ..] } symbol)
LanguageServices\CSharpSymbolDisplayService.SymbolDescriptionBuilder.cs (2)
223foreach (var syntaxRef in symbol.DeclaringSyntaxReferences) 256var syntax = method.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax();
ReplacePropertyWithMethods\CSharpReplacePropertyWithMethodsService.cs (2)
125var setAccessorDeclaration = (AccessorDeclarationSyntax)setMethod.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken); 198var getAccessorDeclaration = (AccessorDeclarationSyntax)getMethod.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken);
src\Analyzers\CSharp\Analyzers\ConvertProgram\ConvertProgramAnalysis_TopLevelStatements.cs (1)
101if (containingType.DeclaringSyntaxReferences.Length > 1)
src\Analyzers\CSharp\Analyzers\ConvertSwitchStatementToExpression\ConvertSwitchStatementToExpressionDiagnosticAnalyzer.Analyzer.cs (1)
91{ Kind: SymbolKind.Local, DeclaringSyntaxReferences: { Length: 1 } syntaxRefs })
src\Analyzers\CSharp\Analyzers\InlineDeclaration\CSharpInlineDeclarationDiagnosticAnalyzer.cs (1)
139var localReference = outLocalSymbol.DeclaringSyntaxReferences.FirstOrDefault();
src\Analyzers\CSharp\Analyzers\MakeLocalFunctionStatic\MakeLocalFunctionStaticHelper.cs (1)
32var node = calledLocationFunction.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax();
src\Analyzers\CSharp\Analyzers\MakeStructMemberReadOnly\CSharpMakeStructMemberReadOnlyAnalyzer.cs (3)
62DeclaringSyntaxReferences: [var reference, ..], 187owningMethod.AssociatedSymbol is IPropertySymbol { DeclaringSyntaxReferences: [var reference, ..] } && 194var methodReference = owningMethod.DeclaringSyntaxReferences[0];
src\Analyzers\CSharp\Analyzers\MakeStructReadOnly\CSharpMakeStructReadOnlyDiagnosticAnalyzer.cs (2)
89if (typeSymbol.DeclaringSyntaxReferences is not [var typeReference, ..]) 113if (ev.AddMethod is { DeclaringSyntaxReferences.Length: 0 })
src\Analyzers\CSharp\Analyzers\NamingStyle\CSharpNamingStyleDiagnosticAnalyzer.cs (1)
31&& symbol.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax() is ParameterSyntax
src\Analyzers\CSharp\Analyzers\QualifyMemberAccess\CSharpQualifyMemberAccessDiagnosticAnalyzer.cs (1)
56containingSymbol.DeclaringSyntaxReferences
src\Analyzers\CSharp\Analyzers\RemoveUnusedMembers\CSharpRemoveUnusedMembersDiagnosticAnalyzer.cs (1)
28return namedType.DeclaringSyntaxReferences
src\Analyzers\CSharp\Analyzers\UseAutoProperty\CSharpUseAutoPropertyAnalyzer.cs (3)
208var declaration = getMethod.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken); 231var setAccessor = setMethod.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken) as AccessorDeclarationSyntax; 263var syntax = accessor.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken);
src\Analyzers\CSharp\Analyzers\UsePatternMatching\CSharpAsAndNullCheckDiagnosticAnalyzer.cs (1)
323declarator = localSymbol?.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax() as VariableDeclaratorSyntax;
src\Analyzers\CSharp\Analyzers\UsePrimaryConstructor\CSharpUsePrimaryConstructorDiagnosticAnalyzer.cs (4)
105if (member.DeclaringSyntaxReferences is not [var memberReference, ..]) 263if (namedType.DeclaringSyntaxReferences is not [var reference, ..]) 357if (constructor.DeclaringSyntaxReferences is not [var constructorReference]) 521if (operation is ILocalReferenceOperation { Local.DeclaringSyntaxReferences: [var syntaxRef, ..] } &&
src\Analyzers\CSharp\Analyzers\UseSystemThreadingLock\CSharpUseSystemThreadingLockDiagnosticAnalyzer.cs (1)
96DeclaringSyntaxReferences: [var fieldSyntaxReference],
src\Analyzers\CSharp\CodeFixes\ConvertToAsync\CSharpConvertToAsyncMethodCodeFixProvider.cs (1)
76var methodReference = methodSymbol.DeclaringSyntaxReferences.FirstOrDefault();
src\Analyzers\CSharp\CodeFixes\ConvertToRecord\ConvertToRecordHelpers.cs (2)
315=> member.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax() == 316param.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax());
src\Analyzers\CSharp\CodeFixes\GenerateConstructor\CSharpGenerateConstructorService.cs (1)
188if (constructor.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken) is ConstructorDeclarationSyntax constructorDeclarationSyntax &&
src\Analyzers\CSharp\CodeFixes\Nullable\CSharpDeclareAsNullableCodeFixProvider.cs (7)
174if (symbol is ILocalSymbol { DeclaringSyntaxReferences.Length: > 0 } local) 176var syntax = local.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken); 184else if (symbol is IFieldSymbol { IsImplicitlyDeclared: false, DeclaringSyntaxReferences.Length: > 0 } field) 187var syntax = field.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken); 202else if (symbol is IPropertySymbol { DeclaringSyntaxReferences.Length: > 0 } property) 204var syntax = property.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken); 304if (parameterSymbol?.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax(cancellationToken) is ParameterSyntax parameterSyntax &&
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (14)
Semantics\RecordStructTests.cs (4)
5990Assert.Same(literal.SyntaxTree, context.ContainingSymbol!.DeclaringSyntaxReferences.Single().SyntaxTree); 6008Assert.Same(equalsValue.SyntaxTree, context.ContainingSymbol!.DeclaringSyntaxReferences.Single().SyntaxTree); 6026Assert.Same(initializer.SyntaxTree, context.ContainingSymbol!.DeclaringSyntaxReferences.Single().SyntaxTree); 6055Assert.Same(record.SyntaxTree, context.ContainingSymbol!.DeclaringSyntaxReferences.Single().SyntaxTree);
Semantics\TopLevelStatementsTests.cs (10)
6455Assert.Same(globalStatement.SyntaxTree, context.ContainingSymbol.DeclaringSyntaxReferences.Single().SyntaxTree); 6537switch (context.Symbol.DeclaringSyntaxReferences.Single().GetSyntax().ToString()) 6613switch (context.Symbol.DeclaringSyntaxReferences.Single().GetSyntax().ToString()) 6635foreach (var syntaxReference in context.Symbol.DeclaringSyntaxReferences) 6656Assert.Equal("System.Console.WriteLine(1);", context.Symbol.DeclaringSyntaxReferences.Single().GetSyntax().ToString()); 6663Assert.Equal("System.Console.WriteLine(2);", context.Symbol.DeclaringSyntaxReferences.Single().GetSyntax().ToString()); 6721Assert.Same(context.ContainingSymbol.DeclaringSyntaxReferences.Single().SyntaxTree, context.Operation.Syntax.SyntaxTree); 6742Assert.Same(context.ContainingSymbol.DeclaringSyntaxReferences.Single().GetSyntax(), context.Operation.Syntax); 7086var decl = (CSharpSyntaxNode)context.ContainingSymbol.DeclaringSyntaxReferences.Single().GetSyntax(); 7420Assert.Same(context.ContainingSymbol.DeclaringSyntaxReferences.Single().GetSyntax(), context.Operation.Syntax);
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (45)
Compilation\GetImportScopesTests.cs (24)
245Assert.True(scopes.Single().Aliases.Single().DeclaringSyntaxReferences.Single().GetSyntax() is UsingDirectiveSyntax); 261Assert.True(scopes.Single().Aliases.Single().DeclaringSyntaxReferences.Single().GetSyntax() is UsingDirectiveSyntax); 292Assert.True(scopes.Single().Aliases.Single().DeclaringSyntaxReferences.Single().GetSyntax() is UsingDirectiveSyntax); 320Assert.True(scopes.Single().Aliases.Single().DeclaringSyntaxReferences.Single().GetSyntax() is UsingDirectiveSyntax); 338Assert.True(scopes.Single().Aliases.Any(a => a.DeclaringSyntaxReferences.Single().GetSyntax() is UsingDirectiveSyntax { Name: IdentifierNameSyntax { Identifier.Text: nameof(System) } })); 339Assert.True(scopes.Single().Aliases.Any(a => a.DeclaringSyntaxReferences.Single().GetSyntax() is UsingDirectiveSyntax { Name: IdentifierNameSyntax { Identifier.Text: nameof(Microsoft) } })); 365Assert.True(scopes.Single().Aliases.Single().DeclaringSyntaxReferences.Single().GetSyntax() is UsingDirectiveSyntax { Name: IdentifierNameSyntax { Identifier.Text: nameof(System) } }); 388Assert.True(scopes[0].Aliases.Single().DeclaringSyntaxReferences.Single().GetSyntax() is UsingDirectiveSyntax { Name: IdentifierNameSyntax { Identifier.Text: nameof(Microsoft) } }); 390Assert.True(scopes[1].Aliases.Single().DeclaringSyntaxReferences.Single().GetSyntax() is UsingDirectiveSyntax { Name: IdentifierNameSyntax { Identifier.Text: nameof(System) } }); 419Assert.True(scopes.Single().ExternAliases.Single().DeclaringSyntaxReferences.Single().GetSyntax() is ExternAliasDirectiveSyntax); 438Assert.True(scopes.Single().ExternAliases.Single().DeclaringSyntaxReferences.Single().GetSyntax() is ExternAliasDirectiveSyntax); 460Assert.True(scopes.Single().ExternAliases.Single().DeclaringSyntaxReferences.Single().GetSyntax() is ExternAliasDirectiveSyntax); 481Assert.True(scopes.Single().ExternAliases.Single().DeclaringSyntaxReferences.Single().GetSyntax() is ExternAliasDirectiveSyntax); 500Assert.True(scopes.Single().ExternAliases.Single().DeclaringSyntaxReferences.Single().GetSyntax() is ExternAliasDirectiveSyntax); 517Assert.True(scopes.Single().ExternAliases.Single().DeclaringSyntaxReferences.Single().GetSyntax() is ExternAliasDirectiveSyntax); 538Assert.True(scopes.Single().ExternAliases.Any(a => a.DeclaringSyntaxReferences.Single().GetSyntax() is ExternAliasDirectiveSyntax { Identifier.Text: "CORE1" })); 539Assert.True(scopes.Single().ExternAliases.Any(a => a.DeclaringSyntaxReferences.Single().GetSyntax() is ExternAliasDirectiveSyntax { Identifier.Text: "CORE2" })); 568Assert.True(scopes.Single().ExternAliases.Single().DeclaringSyntaxReferences.Single().GetSyntax() is ExternAliasDirectiveSyntax { Identifier.Text: "CORE1" }); 594Assert.True(scopes[0].ExternAliases.Single().DeclaringSyntaxReferences.Single().GetSyntax() is ExternAliasDirectiveSyntax { Identifier.Text: "CORE2" }); 596Assert.True(scopes[1].ExternAliases.Single().DeclaringSyntaxReferences.Single().GetSyntax() is ExternAliasDirectiveSyntax { Identifier.Text: "CORE1" }); 623Assert.True(scopes.Single().Aliases.Single().DeclaringSyntaxReferences.Single().GetSyntax() is UsingDirectiveSyntax { Alias.Name.Identifier.Text: "M" }); 653Assert.True(scopes.Single().Aliases.Single().DeclaringSyntaxReferences.Single().GetSyntax() is UsingDirectiveSyntax { Alias.Name.Identifier.Text: "M" }); 689Assert.True(scopes.Single().Aliases.Any(i => i.DeclaringSyntaxReferences.Single().GetSyntax() is UsingDirectiveSyntax { Name: IdentifierNameSyntax { Identifier.Text: nameof(Microsoft) } })); 691Assert.True(scopes.Single().Aliases.Any(i => i.DeclaringSyntaxReferences.Single().GetSyntax() is UsingDirectiveSyntax { Name: QualifiedNameSyntax { Right: IdentifierNameSyntax { Identifier.Text: nameof(System.Threading) } } }));
Compilation\SemanticModelGetDeclaredSymbolAPITests.cs (12)
4801Assert.Equal("(1, 2)", type.DeclaringSyntaxReferences.Single().GetSyntax().ToString()); 4824Assert.Equal("(Alice: 1, Bob: 2)", type.DeclaringSyntaxReferences.Single().GetSyntax().ToString()); 4847Assert.Equal("(1, 1)", type.DeclaringSyntaxReferences.Single().GetSyntax().ToString()); 4870Assert.Equal("(1, null)", type.DeclaringSyntaxReferences.Single().GetSyntax().ToString()); 4893Assert.Equal("(Alice:1, Bob:null)", type.DeclaringSyntaxReferences.Single().GetSyntax().ToString()); 4916Assert.Equal("Bob", element.DeclaringSyntaxReferences.Single().GetSyntax().ToString()); 4939Assert.Equal("Bob", element.DeclaringSyntaxReferences.Single().GetSyntax().ToString()); 4962Assert.Equal("Bob", element.DeclaringSyntaxReferences.Single().GetSyntax().ToString()); 4997Assert.Equal("Bob", element.DeclaringSyntaxReferences.Single().GetSyntax().ToString()); 5043Assert.Equal("Bob", element.DeclaringSyntaxReferences.Single().GetSyntax().ToString()); 5092Assert.Equal("Bob", element.DeclaringSyntaxReferences.Single().GetSyntax().ToString()); 5115Assert.Equal("Bob", element.DeclaringSyntaxReferences.Single().GetSyntax().ToString());
Symbols\Source\DeclaringSyntaxNodeTests.cs (7)
27var declaringReferences = symbol.DeclaringSyntaxReferences; 82var declaringReferences = symbol.DeclaringSyntaxReferences; 345Assert.Same(localType.DeclaringSyntaxReferences[0].GetSyntax(), symbol.DeclaringSyntaxReferences[0].GetSyntax()); 371Assert.Equal(1, member.DeclaringSyntaxReferences.Length); 372Assert.Same(propertyInitializer, member.DeclaringSyntaxReferences[0].GetSyntax()); 378Assert.Same(propertyInitializer, propSymbol.DeclaringSyntaxReferences[0].GetSyntax());
Symbols\Source\ExternAliasTests.cs (2)
491Assert.Equal(1, externAliasSymbol.DeclaringSyntaxReferences.Length); 492Assert.Same(externAliasSyntax, externAliasSymbol.DeclaringSyntaxReferences.Single().GetSyntax());
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (1)
Syntax\LambdaUtilitiesTests.cs (1)
48var enclosingSyntax = enclosingMethod.DeclaringSyntaxReferences.Single().GetSyntax();
Microsoft.CodeAnalysis.CSharp.Test.Utilities (1)
Extensions.cs (1)
191return type.InstanceConstructors.Single(c => c.DeclaringSyntaxReferences.Any(r => r.GetSyntax() is TypeDeclarationSyntax));
Microsoft.CodeAnalysis.CSharp.Workspaces (19)
Recommendations\CSharpRecommendationServiceRunner.cs (2)
453foreach (var reference in enclosingNamedType.DeclaringSyntaxReferences) 520if (s is not IParameterSymbol { DeclaringSyntaxReferences: [var parameterReference] })
Simplification\Simplifiers\ExpressionSimplifier.cs (1)
144var syntaxRef = aliasReplacement.DeclaringSyntaxReferences.FirstOrDefault();
Simplification\Simplifiers\NameSimplifier.cs (2)
120var syntaxRef = aliasReplacement.DeclaringSyntaxReferences.FirstOrDefault(); 448var argumentDecl = argument.DeclaringSyntaxReferences.FirstOrDefault();
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ITypeSymbolExtensions.cs (1)
53c => c.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax() is RecordDeclarationSyntax or ClassDeclarationSyntax or StructDeclarationSyntax);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SemanticFacts\CSharpSemanticFacts.cs (3)
95var enumDecl = namedTypeSymbol.DeclaringSyntaxReferences.Select(r => r.GetSyntax()).OfType<EnumDeclarationSyntax>().FirstOrDefault(); 232foreach (var syntaxRef in typeSymbol.DeclaringSyntaxReferences) 374foreach (var syntaxReference in symbol.DeclaringSyntaxReferences)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationHelpers.cs (2)
273if (info.Context.ReuseSyntax && symbol.DeclaringSyntaxReferences.Length == 1) 275var reusableSyntaxNode = symbol.DeclaringSyntaxReferences[0].GetSyntax();
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ITypeSymbolExtensions.cs (1)
99foreach (var reference in containingType.DeclaringSyntaxReferences)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\TypeDeclarationSyntaxExtensions.cs (2)
78if (typeSymbol.DeclaringSyntaxReferences.Length >= 2) 82foreach (var syntaxRef in typeSymbol.DeclaringSyntaxReferences)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpSymbolDeclarationService.cs (1)
26? symbol.DeclaringSyntaxReferences
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\InitializeParameter\InitializeParameterHelpers.cs (4)
59foreach (var syntaxRef in property.DeclaringSyntaxReferences) 79foreach (var syntaxRef in field.DeclaringSyntaxReferences) 104var documents = namedType.DeclaringSyntaxReferences 255var node = accessor.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken);
Microsoft.CodeAnalysis.CSharp.Workspaces.UnitTests (16)
CodeGeneration\SyntaxGeneratorTests.cs (16)
3787var declC = Generator.GetDeclaration(symbolC.DeclaringSyntaxReferences.Select(x => x.GetSyntax()).First()); 3788var declX = Generator.GetDeclaration(symbolX.DeclaringSyntaxReferences.Select(x => x.GetSyntax()).First()); 3789var declY = Generator.GetDeclaration(symbolY.DeclaringSyntaxReferences.Select(x => x.GetSyntax()).First()); 3790var declZ = Generator.GetDeclaration(symbolZ.DeclaringSyntaxReferences.Select(x => x.GetSyntax()).First()); 3964var declC = Generator.GetDeclaration(symbolC.DeclaringSyntaxReferences.Select(x => x.GetSyntax()).First()); 3982var declC = Generator.GetDeclaration(symbolC.DeclaringSyntaxReferences.Select(x => x.GetSyntax()).First()); 4003var declC = Generator.GetDeclaration(symbolC.DeclaringSyntaxReferences.Select(x => x.GetSyntax()).First()); 4021var declC = Generator.GetDeclaration(symbolC.DeclaringSyntaxReferences.Select(x => x.GetSyntax()).First()); 4039var declC = Generator.GetDeclaration(symbolC.DeclaringSyntaxReferences.Select(x => x.GetSyntax()).First()); 4057var declC = Generator.GetDeclaration(symbolC.DeclaringSyntaxReferences.Select(x => x.GetSyntax()).First()); 4075var declC = Generator.GetDeclaration(symbolC.DeclaringSyntaxReferences.Select(x => x.GetSyntax()).First()); 4093var declC = Generator.GetDeclaration(symbolC.DeclaringSyntaxReferences.Select(x => x.GetSyntax()).First()); 4111var declC = Generator.GetDeclaration(symbolC.DeclaringSyntaxReferences.Select(x => x.GetSyntax()).First()); 4130var declC = symbolC.DeclaringSyntaxReferences.First().GetSyntax(); 4307var declC = symbolC.DeclaringSyntaxReferences.First().GetSyntax(); 4399var declC = symbolC.DeclaringSyntaxReferences.First().GetSyntax();
Microsoft.CodeAnalysis.EditorFeatures (1)
Navigation\AbstractDefinitionLocationService.cs (1)
133if (symbol.DeclaringSyntaxReferences is not [{ SyntaxTree: { } definitionTree, Span: var definitionSpan }])
Microsoft.CodeAnalysis.EditorFeatures.UnitTests (1)
Utilities\SymbolEquivalenceComparerTests.cs (1)
1889var method_root = method.DeclaringSyntaxReferences[0].GetSyntax();
Microsoft.CodeAnalysis.Features (49)
ChangeSignature\AbstractChangeSignatureService.cs (1)
166var reference = symbol.DeclaringSyntaxReferences.FirstOrDefault();
CodeLens\CodeLensFindReferenceProgress.cs (1)
79return from syntaxReference in symbol.DeclaringSyntaxReferences
CodeRefactorings\SyncNamespace\AbstractChangeNamespaceService.cs (1)
335&& typeSymbol.DeclaringSyntaxReferences.Length > 1
Completion\Providers\AbstractPartialTypeCompletionProvider.cs (2)
101=> symbol.DeclaringSyntaxReferences.Any(static (r, compilation) => compilation.SyntaxTrees.Contains(r.SyntaxTree), compilation); 105return symbol.DeclaringSyntaxReferences
Completion\Providers\AbstractSymbolCompletionProvider.cs (1)
71var declarationSyntax = symbol.DeclaringSyntaxReferences.Select(r => r.GetSyntax()).SingleOrDefault();
ConvertAutoPropertyToFullProperty\AbstractConvertAutoPropertyToFullPropertyCodeRefactoringProvider.cs (1)
107var typeDeclaration = propertySymbol.ContainingType.DeclaringSyntaxReferences;
EditAndContinue\AbstractEditAndContinueAnalyzer.cs (1)
494/// <see cref="ISymbol.DeclaringSyntaxReferences"/> of a primary constructor returns the type declaration syntax.
EncapsulateField\AbstractEncapsulateFieldService.cs (2)
176var fieldDeclaration = field.DeclaringSyntaxReferences.First(); 324var fieldDeclaration = field.DeclaringSyntaxReferences.First();
InitializeParameter\AbstractInitializeMemberFromParameterCodeRefactoringProviderMemberCreation.cs (1)
551var symbolSyntax = symbol.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken);
MetadataAsSource\AbstractMetadataAsSourceService.AbstractWrappedSymbol.cs (1)
43public ImmutableArray<SyntaxReference> DeclaringSyntaxReferences => _symbol.DeclaringSyntaxReferences;
MoveStaticMembers\MoveStaticMembersOptions.cs (1)
41var sourceLocation = destination.DeclaringSyntaxReferences.First();
MoveStaticMembers\MoveStaticMembersWithDialogCodeAction.cs (1)
172var newTypeNode = newType.DeclaringSyntaxReferences
NavigationBar\AbstractNavigationBarItemService.cs (1)
46return GetSymbolLocation(solution, symbol, tree, computeFullSpan, symbol.DeclaringSyntaxReferences);
ReplaceMethodWithProperty\ReplaceMethodWithPropertyCodeRefactoringProvider.cs (6)
117getMethod.DeclaringSyntaxReferences.Length == 1 && 148setMethod.DeclaringSyntaxReferences.Length == 1; 440Debug.Assert(method.DeclaringSyntaxReferences.Length == 1); 441var reference = method.DeclaringSyntaxReferences[0]; 456if (definition?.DeclaringSyntaxReferences.Length > 0) 458var syntax = await definition.DeclaringSyntaxReferences[0].GetSyntaxAsync(cancellationToken).ConfigureAwait(false);
ReplacePropertyWithMethods\ReplacePropertyWithMethodsCodeRefactoringProvider.cs (4)
322if (definition?.DeclaringSyntaxReferences.Length > 0) 324var syntax = await definition.DeclaringSyntaxReferences[0].GetSyntaxAsync(cancellationToken).ConfigureAwait(false); 417Debug.Assert(property.DeclaringSyntaxReferences.Length == 1); 418var reference = property.DeclaringSyntaxReferences[0];
src\Analyzers\Core\Analyzers\Helpers\HashCodeAnalyzer\HashCodeAnalyzer.cs (1)
67if (method.Locations.Length != 1 || method.DeclaringSyntaxReferences.Length != 1)
src\Analyzers\Core\Analyzers\MatchFolderAndNamespace\AbstractMatchFolderAndNamespaceDiagnosticAnalyzer.cs (1)
182if (symbol is ITypeSymbol typeSymbol && typeSymbol.DeclaringSyntaxReferences.Length > 1)
src\Analyzers\Core\Analyzers\RemoveUnusedMembers\AbstractRemoveUnusedMembersDiagnosticAnalyzer.cs (1)
563var fadingLocation = member.DeclaringSyntaxReferences.FirstOrDefault(
src\Analyzers\Core\Analyzers\RemoveUnusedParametersAndValues\AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.SymbolStartAnalyzer.cs (2)
78foreach (var syntaxRef in namedTypeSymbol.DeclaringSyntaxReferences) 263var methodSyntax = method.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax(cancellationToken);
src\Analyzers\Core\Analyzers\UseAutoProperty\AbstractUseAutoPropertyAnalyzer.cs (5)
144DeclaringSyntaxReferences.Length: 1, 194if (!namedType.DeclaringSyntaxReferences.Select(d => d.SyntaxTree).Distinct().Any(tree => 321if (field.DeclaringSyntaxReferences is [var fieldReference]) 350if (property.DeclaringSyntaxReferences.Length != 1) 528Field.DeclaringSyntaxReferences.Length: 1,
src\Analyzers\Core\Analyzers\UseSystemHashCode\UseSystemHashCodeDiagnosticAnalyzer.cs (1)
78var declarationLocation = context.OwningSymbol.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken).GetLocation();
src\Analyzers\Core\CodeFixes\AddParameter\AddParameterService.cs (1)
194if (parameter.ContainingSymbol is not IMethodSymbol { MethodKind: MethodKind.Constructor, DeclaringSyntaxReferences: [var reference] } constructor)
src\Analyzers\Core\CodeFixes\ImplementInterface\ImplementHelpers.cs (2)
70if (field.DeclaringSyntaxReferences is [var syntaxRef, ..]) 86if (property.DeclaringSyntaxReferences is [var syntaxRef, ..])
src\Analyzers\Core\CodeFixes\MakeTypePartial\AbstractMakeTypePartialCodeFixProvider.cs (1)
46foreach (var reference in symbol.DeclaringSyntaxReferences)
src\Analyzers\Core\CodeFixes\UnsealClass\AbstractUnsealClassCodeFixProvider.cs (2)
44if (definition is not null && definition.DeclaringSyntaxReferences.Length > 0) 50c => UnsealDeclarationsAsync(document.Project.Solution, definition.DeclaringSyntaxReferences, c),
UseAutoProperty\AbstractUseAutoPropertyCodeFixProvider.cs (6)
96var fieldDocument = currentSolution.GetRequiredDocument(field.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken).SyntaxTree); 97var propertyDocument = currentSolution.GetRequiredDocument(property.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken).SyntaxTree); 111var declarator = (TVariableDeclarator)field.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken); 112var propertyDeclaration = GetPropertyDeclaration(property.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken)); 191declarator = (TVariableDeclarator)field.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken); 192propertyDeclaration = GetPropertyDeclaration(property.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken));
ValueTracking\ValueTracker.cs (1)
37var declaringSyntaxReferences = symbol.DeclaringSyntaxReferences;
Microsoft.CodeAnalysis.Test.Utilities (4)
Diagnostics\CommonDiagnosticAnalyzers.cs (3)
2778ReportDiagnostics("RegisterOperationBlockAction", operationBlockContext.OwningSymbol.DeclaringSyntaxReferences[0].SyntaxTree, operationBlockContext.OwningSymbol, operationBlockContext.ReportDiagnostic)); 2789ReportDiagnostics("RegisterOperationBlockEndAction", operationBlockEndContext.OwningSymbol.DeclaringSyntaxReferences[0].SyntaxTree, operationBlockEndContext.OwningSymbol, operationBlockEndContext.ReportDiagnostic)); 2824var trees = symbol.DeclaringSyntaxReferences.Select(syntaxRef => syntaxRef.SyntaxTree).Distinct();
Diagnostics\OperationTestAnalyzer.cs (1)
853Report(operationContext, decl.Symbol.DeclaringSyntaxReferences.Single().GetSyntax(), LocalVarInitializedDeclarationDescriptor);
Microsoft.CodeAnalysis.VisualBasic (1)
Symbols\Symbol.vb (1)
1301Private ReadOnly Property ISymbol_DeclaringSyntaxReferences As ImmutableArray(Of SyntaxReference) Implements ISymbol.DeclaringSyntaxReferences
Microsoft.CodeAnalysis.VisualBasic.CodeStyle (6)
src\Analyzers\VisualBasic\Analyzers\RemoveUnusedMembers\VisualBasicRemoveUnusedMembersDiagnosticAnalyzer.vb (1)
56Return namedType.DeclaringSyntaxReferences.
src\Analyzers\VisualBasic\Analyzers\RemoveUnusedParametersAndValues\VisualBasicRemoveUnusedParametersAndValuesDiagnosticAnalyzer.vb (1)
40Return method.DeclaringSyntaxReferences().Any(Function(decl)
src\Analyzers\VisualBasic\Analyzers\UseAutoProperty\VisualBasicUseAutoPropertyAnalyzer.vb (2)
105Dim accessor = TryCast(TryCast(getMethod.DeclaringSyntaxReferences(0).GetSyntax(cancellationToken), AccessorStatementSyntax)?.Parent, AccessorBlockSyntax) 128Dim setAccessor = TryCast(TryCast(setMethod.DeclaringSyntaxReferences(0).GetSyntax(cancellationToken), AccessorStatementSyntax)?.Parent, AccessorBlockSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Services\SemanticFacts\VisualBasicSemanticFacts.vb (2)
95Dim enumStatement = namedTypeSymbol.DeclaringSyntaxReferences.Select(Function(r) r.GetSyntax()).OfType(Of EnumStatementSyntax).FirstOrDefault() 216Dim syntaxRefs = typeSymbol.DeclaringSyntaxReferences
Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes (8)
src\Analyzers\VisualBasic\CodeFixes\ConvertToAsync\VisualBasicConvertToAsyncFunctionCodeFixProvider.vb (1)
63Dim methodReference = methodSymbol.DeclaringSyntaxReferences.FirstOrDefault()
src\Analyzers\VisualBasic\CodeFixes\GenerateConstructor\VisualBasicGenerateConstructorService.vb (1)
174Dim constructorStatements = constructor.DeclaringSyntaxReferences(0).GetSyntax(cancellationToken).Parent.GetStatements()
src\Analyzers\VisualBasic\CodeFixes\Iterator\VisualBasicConvertToIteratorCodeFixProvider.vb (1)
81Dim syntaxReference = method.DeclaringSyntaxReferences.FirstOrDefault
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\CodeGeneration\VisualBasicCodeGenerationHelpers.vb (2)
201If options.Context.ReuseSyntax AndAlso symbol.DeclaringSyntaxReferences.Length = 1 Then 202Dim reusableNode = symbol.DeclaringSyntaxReferences(0).GetSyntax()
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\LanguageServices\InitializeParameter\VisualBasicInitializeParameterService.vb (2)
24If accessor.DeclaringSyntaxReferences.Length = 0 Then 28Dim reference = accessor.DeclaringSyntaxReferences(0).GetSyntax(cancellationToken)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\LanguageServices\VisualBasicSymbolDeclarationService.vb (1)
29symbol.DeclaringSyntaxReferences.SelectAsArray(Of SyntaxReference)(
Microsoft.CodeAnalysis.VisualBasic.EditorFeatures (1)
GoToBase\VisualBasicGoToBaseService.vb (1)
22Dim subNew = TryCast(constructor.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax(cancellationToken), SubNewStatementSyntax)
Microsoft.CodeAnalysis.VisualBasic.Features (24)
EditAndContinue\VisualBasicEditAndContinueAnalyzer.vb (4)
537syntaxRefs = symbol.ContainingType.DeclaringSyntaxReferences 543syntaxRefs = symbol.DeclaringSyntaxReferences 658Dim ctor = TryCast(symbol.DeclaringSyntaxReferences(0).GetSyntax(cancellationToken).Parent, ConstructorBlockSyntax) 700Dim syntaxRefs = type.DeclaringSyntaxReferences
EncapsulateField\VisualBasicEncapsulateFieldService.vb (2)
123Return field.DeclaringSyntaxReferences.Any(Function(d) d.GetSyntax().GetAncestor(Of FieldDeclarationSyntax)().Modifiers.Any(SyntaxKind.ShadowsKeyword)) 133SelectMany(Function(c As IMethodSymbol) c.DeclaringSyntaxReferences.Select(Function(d) d.GetSyntax().Parent)).
GoToDefinition\VisualBasicGoToDefinitionSymbolService.vb (1)
65Return target.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax()?.SpanStart
IntroduceVariable\VisualBasicIntroduceVariableService_IntroduceField.vb (1)
68For Each declNode In oldType.DeclaringSyntaxReferences.Select(Function(r) r.GetSyntax().Parent).OfType(Of TypeBlockSyntax)()
LanguageServices\VisualBasicSymbolDisplayService.SymbolDescriptionBuilder.vb (3)
98For Each syntaxRef In symbol.DeclaringSyntaxReferences 111For Each syntaxRef In symbol.DeclaringSyntaxReferences 171Dim syntax = method.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax()
NavigationBar\VisualBasicNavigationBarItemService.vb (1)
456Return method.DeclaringSyntaxReferences.Select(Function(r) r.GetSyntax()).OfType(Of MethodStatementSyntax)().Any(Function(m) m.Modifiers.Any(Function(t) t.Kind = SyntaxKind.PartialKeyword))
ReplacePropertyWithMethods\VisualBasicReplacePropertyWithMethods.vb (4)
89Dim getAccessorDeclaration = If(getMethod.DeclaringSyntaxReferences.Length = 0, 91TryCast(getMethod.DeclaringSyntaxReferences(0).GetSyntax(cancellationToken), AccessorStatementSyntax)) 122Dim setAccessorDeclaration = If(setMethod.DeclaringSyntaxReferences.Length = 0, 124TryCast(setMethod.DeclaringSyntaxReferences(0).GetSyntax(cancellationToken), AccessorStatementSyntax))
src\Analyzers\VisualBasic\Analyzers\RemoveUnusedMembers\VisualBasicRemoveUnusedMembersDiagnosticAnalyzer.vb (1)
56Return namedType.DeclaringSyntaxReferences.
src\Analyzers\VisualBasic\Analyzers\RemoveUnusedParametersAndValues\VisualBasicRemoveUnusedParametersAndValuesDiagnosticAnalyzer.vb (1)
40Return method.DeclaringSyntaxReferences().Any(Function(decl)
src\Analyzers\VisualBasic\Analyzers\UseAutoProperty\VisualBasicUseAutoPropertyAnalyzer.vb (2)
105Dim accessor = TryCast(TryCast(getMethod.DeclaringSyntaxReferences(0).GetSyntax(cancellationToken), AccessorStatementSyntax)?.Parent, AccessorBlockSyntax) 128Dim setAccessor = TryCast(TryCast(setMethod.DeclaringSyntaxReferences(0).GetSyntax(cancellationToken), AccessorStatementSyntax)?.Parent, AccessorBlockSyntax)
src\Analyzers\VisualBasic\CodeFixes\ConvertToAsync\VisualBasicConvertToAsyncFunctionCodeFixProvider.vb (1)
63Dim methodReference = methodSymbol.DeclaringSyntaxReferences.FirstOrDefault()
src\Analyzers\VisualBasic\CodeFixes\GenerateConstructor\VisualBasicGenerateConstructorService.vb (1)
174Dim constructorStatements = constructor.DeclaringSyntaxReferences(0).GetSyntax(cancellationToken).Parent.GetStatements()
src\Analyzers\VisualBasic\CodeFixes\Iterator\VisualBasicConvertToIteratorCodeFixProvider.vb (1)
81Dim syntaxReference = method.DeclaringSyntaxReferences.FirstOrDefault
UseAutoProperty\VisualBasicUseAutoPropertyCodeFixProvider.vb (1)
95Dim identifier = TryCast(Await fieldSymbol.DeclaringSyntaxReferences(0).GetSyntaxAsync(cancellationToken).ConfigureAwait(False), ModifiedIdentifierSyntax)
Microsoft.CodeAnalysis.VisualBasic.Semantic.UnitTests (3)
Compilation\GetImportScopesTests.vb (1)
59Dim syntax = aliasSymbol.DeclaringSyntaxReferences.Single().GetSyntax()
Diagnostics\DiagnosticAnalyzerTests.vb (1)
412context.ReportDiagnostic(CodeAnalysis.Diagnostic.Create(s_descriptor, context.OwningSymbol.DeclaringSyntaxReferences.First.GetLocation))
Diagnostics\GetDiagnosticsTests.vb (1)
724Dim diag = CodeAnalysis.Diagnostic.Create(Descriptor, field.DeclaringSyntaxReferences(0).GetLocation())
Microsoft.CodeAnalysis.VisualBasic.Symbol.UnitTests (2)
SymbolsTests\AnonymousTypes\AnonymousTypesSemanticsTests.vb (2)
148Assert.Same(anonObjectCreation, symbol.DeclaringSyntaxReferences(0).GetSyntax()) 180Assert.Same(propertyInitializer, propSymbol.DeclaringSyntaxReferences(0).GetSyntax())
Microsoft.CodeAnalysis.VisualBasic.Workspaces (7)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Services\SemanticFacts\VisualBasicSemanticFacts.vb (2)
95Dim enumStatement = namedTypeSymbol.DeclaringSyntaxReferences.Select(Function(r) r.GetSyntax()).OfType(Of EnumStatementSyntax).FirstOrDefault() 216Dim syntaxRefs = typeSymbol.DeclaringSyntaxReferences
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\CodeGeneration\VisualBasicCodeGenerationHelpers.vb (2)
201If options.Context.ReuseSyntax AndAlso symbol.DeclaringSyntaxReferences.Length = 1 Then 202Dim reusableNode = symbol.DeclaringSyntaxReferences(0).GetSyntax()
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\LanguageServices\InitializeParameter\VisualBasicInitializeParameterService.vb (2)
24If accessor.DeclaringSyntaxReferences.Length = 0 Then 28Dim reference = accessor.DeclaringSyntaxReferences(0).GetSyntax(cancellationToken)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\LanguageServices\VisualBasicSymbolDeclarationService.vb (1)
29symbol.DeclaringSyntaxReferences.SelectAsArray(Of SyntaxReference)(
Microsoft.CodeAnalysis.VisualBasic.Workspaces.UnitTests (5)
CodeGeneration\SyntaxGeneratorTests.vb (5)
3474Dim declC = Generator.GetDeclaration(symbolC.DeclaringSyntaxReferences.Select(Function(x) x.GetSyntax()).First()) 3475Dim declX = Generator.GetDeclaration(symbolX.DeclaringSyntaxReferences.Select(Function(x) x.GetSyntax()).First()) 3476Dim declY = Generator.GetDeclaration(symbolY.DeclaringSyntaxReferences.Select(Function(x) x.GetSyntax()).First()) 3477Dim declZ = Generator.GetDeclaration(symbolZ.DeclaringSyntaxReferences.Select(Function(x) x.GetSyntax()).First()) 3728Dim declC = Generator.GetDeclaration(symbolC.DeclaringSyntaxReferences.First().GetSyntax())
Microsoft.CodeAnalysis.Workspaces (40)
Editing\SymbolEditor.cs (1)
194return symbol.DeclaringSyntaxReferences
FindSymbols\FindReferences\Finders\AbstractMemberScopedReferenceFinder.cs (1)
76if (current.DeclaringSyntaxReferences.Length == 0)
FindSymbols\FindReferences\Finders\ParameterSymbolReferenceFinder.cs (3)
97var parameterNode = parameter.DeclaringSyntaxReferences.Select(r => r.GetSyntax(cancellationToken)).FirstOrDefault(); 108var lambdaNode = parameter.ContainingSymbol.DeclaringSyntaxReferences.Select(r => r.GetSyntax(cancellationToken)).First(); 148var lambdaNode = symbol.ContainingSymbol.DeclaringSyntaxReferences.Select(r => r.GetSyntax(cancellationToken)).First();
FindSymbols\FindReferences\Finders\PropertySymbolReferenceFinder.cs (5)
75DeclaringSyntaxReferences.Length: > 0, 79DeclaringSyntaxReferences.Length: > 0, 84var containingTypeSyntaxes = containingType.DeclaringSyntaxReferences.SelectAsArray(r => r.GetSyntax(cancellationToken)); 87if (constructor.DeclaringSyntaxReferences.Length > 0) 89var constructorSyntax = constructor.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken);
FindSymbols\SymbolFinder.cs (2)
195foreach (var location in symbol.DeclaringSyntaxReferences) 236c => c.DeclaringSyntaxReferences.Any(r => linkedNode.Equals(r.GetSyntax(cancellationToken))));
LanguageServices\FixAllSpanMappingService\AbstractFixAllSpanMappingService.cs (2)
46if (symbol?.DeclaringSyntaxReferences.Length > 1) 50foreach (var syntaxRef in symbol.DeclaringSyntaxReferences)
ReassignedVariable\AbstractReassignedVariableService.cs (5)
190if (methodOrProperty.DeclaringSyntaxReferences.Length == 0) 198foreach (var group in containingType.DeclaringSyntaxReferences.GroupBy(r => r.SyntaxTree)) 226var methodOrPropertyDeclaration = methodOrProperty.DeclaringSyntaxReferences.First().GetSyntax(cancellationToken); 268if (local.DeclaringSyntaxReferences.Length == 0) 271var localDeclaration = local.DeclaringSyntaxReferences
Recommendations\AbstractRecommendationServiceRunner.cs (2)
74if (owningMethod.DeclaringSyntaxReferences.Length != 1) 81if (owningMethod.DeclaringSyntaxReferences.Single().GetSyntax(_cancellationToken) is not TAnonymousFunctionSyntax lambdaSyntax)
src\Compilers\Core\Portable\SourceGeneration\GeneratedCodeUtilities.cs (1)
31if (symbol.DeclaringSyntaxReferences.Length > 1)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\IParameterSymbolExtensions.cs (9)
27DeclaringSyntaxReferences.Length: > 0, 31DeclaringSyntaxReferences.Length: > 0, 37var parameterSyntax = parameter.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken); 38var constructorSyntax = constructor.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken); 39if (containingType.DeclaringSyntaxReferences.Any(static (r, arg) => r.GetSyntax(arg.cancellationToken) == arg.constructorSyntax, (constructorSyntax, cancellationToken))) 44if (member is IPropertySymbol { DeclaringSyntaxReferences.Length: > 0 } property && 45property.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken) == parameterSyntax) 63DeclaringSyntaxReferences: [var constructorReference, ..], 69return containingType.DeclaringSyntaxReferences.Any(static (r, arg) => r.GetSyntax(arg.cancellationToken) == arg.constructorSyntax, (constructorSyntax, cancellationToken));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\ISymbolExtensions.cs (1)
605var declarationSyntax = symbol.DeclaringSyntaxReferences.Select(r => r.GetSyntax()).FirstOrDefault();
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.AliasSymbolKey.cs (1)
22visitor.WriteString(symbol.DeclaringSyntaxReferences.FirstOrDefault()?.SyntaxTree.FilePath ?? "");
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.BodyLevelSymbolKey.cs (4)
23Contract.ThrowIfTrue(symbol.DeclaringSyntaxReferences.IsEmpty && symbol.Locations.IsEmpty); 33foreach (var syntaxRef in symbol.DeclaringSyntaxReferences) 62Contract.ThrowIfTrue(symbol.DeclaringSyntaxReferences.IsEmpty && symbol.Locations.IsEmpty); 105foreach (var reference in container.DeclaringSyntaxReferences)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\SymbolKey\SymbolKey.NamedTypeSymbolKey.cs (2)
23? symbol.DeclaringSyntaxReferences[0].SyntaxTree.FilePath 182type.DeclaringSyntaxReferences[0].SyntaxTree.FilePath != filePath)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\LanguageServices\InitializeParameter\AbstractInitializerParameterService.cs (1)
88if (parameter is { DeclaringSyntaxReferences: [var parameterReference] })
Microsoft.CodeAnalysis.Workspaces.UnitTests (1)
SymbolKeyTests.cs (1)
1553foreach (var declaringLocation in containingSymbol.DeclaringSyntaxReferences)
Microsoft.DotNet.CodeAnalysis (1)
Analyzers\PinvokeAnalyzer.cs (1)
161foreach (SyntaxReference synref in methodSymbol.DeclaringSyntaxReferences)
Microsoft.Extensions.Logging.Generators (3)
LoggerMessageGenerator.Parser.cs (3)
340if (paramSymbol.DeclaringSyntaxReferences.Length > 0) 342ParameterSyntax paramSyntax = paramSymbol.DeclaringSyntaxReferences[0].GetSyntax(_cancellationToken) as ParameterSyntax; 687.Where(ic => ic.DeclaringSyntaxReferences
Microsoft.Extensions.Options.SourceGeneration (1)
ParserUtilities.cs (1)
35.DeclaringSyntaxReferences
Microsoft.Gen.Logging (6)
Parsing\Parser.cs (3)
521if (!paramSymbol.DeclaringSyntaxReferences.IsDefaultOrEmpty) 523var paramSyntax = paramSymbol.DeclaringSyntaxReferences[0].GetSyntax(_cancellationToken) as ParameterSyntax; 709.Where(ic => ic.DeclaringSyntaxReferences
Parsing\Parser.LogProperties.cs (2)
75var syntax = property.DeclaringSyntaxReferences[0].GetSyntax(token); 210if (!property.DeclaringSyntaxReferences.IsDefaultOrEmpty)
src\Generators\Shared\ParserUtilities.cs (1)
40.DeclaringSyntaxReferences
Microsoft.Gen.Logging.Unit.Tests (2)
ParserUtilitiesTests.cs (2)
50.SetupGet(x => x.DeclaringSyntaxReferences) 71.SetupGet(x => x.DeclaringSyntaxReferences)
Microsoft.Gen.Metrics (1)
src\Generators\Shared\ParserUtilities.cs (1)
40.DeclaringSyntaxReferences
Microsoft.Gen.MetricsReports (1)
src\Generators\Shared\ParserUtilities.cs (1)
40.DeclaringSyntaxReferences
Microsoft.Interop.ComInterfaceGenerator (3)
Analyzers\ConvertComImportToGeneratedComInterfaceAnalyzer.cs (2)
60if (type.DeclaringSyntaxReferences.Length > 1) 75GeneratorDiagnosticsBag diagnostics = new(new DiagnosticDescriptorProvider(), new MethodSignatureDiagnosticLocations((MethodDeclarationSyntax)method.DeclaringSyntaxReferences[0].GetSyntax()), SR.ResourceManager, typeof(FxResources.Microsoft.Interop.ComInterfaceGenerator.SR));
ComMethodInfo.cs (1)
124foreach (var declaringSyntaxReference in method.DeclaringSyntaxReferences)
Microsoft.Interop.LibraryImportGenerator (1)
Analyzers\ConvertToLibraryImportAnalyzer.cs (1)
141GeneratorDiagnosticsBag diagnostics = new(new DiagnosticDescriptorProvider(), new MethodSignatureDiagnosticLocations((MethodDeclarationSyntax)method.DeclaringSyntaxReferences[0].GetSyntax()), SR.ResourceManager, typeof(FxResources.Microsoft.Interop.LibraryImportGenerator.SR));
Microsoft.Interop.SourceGeneration (1)
TypePositionInfo.cs (1)
99IsExplicitThis = ((ParameterSyntax)paramSymbol.DeclaringSyntaxReferences[0].GetSyntax()).Modifiers.Any(SyntaxKind.ThisKeyword)
Microsoft.ML.InternalCodeAnalyzer (1)
InstanceInitializerAnalyzer.cs (1)
68var syntaxRefs = symbol.DeclaringSyntaxReferences;
Microsoft.VisualStudio.LanguageServices (6)
CallHierarchy\Finders\ImplementerFinder.cs (1)
44var sourceLocations = implementation.DeclaringSyntaxReferences.Select(d => project.Solution.GetDocument(d.SyntaxTree)).WhereNotNull();
CallHierarchy\Finders\OverridingMemberFinder.cs (1)
40var sourceLocations = @override.DeclaringSyntaxReferences.Select(d => project.Solution.GetDocument(d.SyntaxTree)).WhereNotNull();
Progression\GraphNodeIdCreation.cs (1)
521foreach (var reference in symbol.ContainingSymbol.DeclaringSyntaxReferences)
Progression\GraphQueries\CallsGraphQuery.cs (1)
46foreach (var reference in symbol.DeclaringSyntaxReferences)
Venus\ContainedLanguageCodeSupport.cs (2)
66var typeNode = type.DeclaringSyntaxReferences.Where(r => r.SyntaxTree == tree).Select(r => r.GetSyntax(cancellationToken)).First(); 270var memberNode = member.DeclaringSyntaxReferences.Select(r => r.GetSyntax(cancellationToken)).FirstOrDefault();
Microsoft.VisualStudio.LanguageServices.CSharp (1)
LanguageService\CSharpHelpContextService.cs (1)
182if (symbol is ILocalSymbol localSymbol && !symbol.DeclaringSyntaxReferences.Any(static (d, token) => d.GetSyntax().DescendantTokens().Contains(token), token))
Microsoft.VisualStudio.LanguageServices.VisualBasic (6)
CodeModel\VisualBasicCodeModelService.vb (3)
2159If typeSymbol.DeclaringSyntaxReferences.Length > 1 Then 2374If symbol.DeclaringSyntaxReferences.Length > 1 Then 2581Dim statements = typeSymbol.DeclaringSyntaxReferences _
CodeModel\VisualBasicCodeModelService_Prototype.vb (2)
125Dim modifiedIdentifier = TryCast(symbol.DeclaringSyntaxReferences.FirstOrDefault().GetSyntax(), ModifiedIdentifierSyntax) 194Dim parameterNode = TryCast(parameter.DeclaringSyntaxReferences(0).GetSyntax(), ParameterSyntax)
Venus\ContainedLanguageStaticEventBinding.vb (1)
134Return member.DeclaringSyntaxReferences.Select(Function(r) r.GetSyntax()).FirstOrDefault()
Mvc.Api.Analyzers.Test (4)
ActualApiResponseMetadataFactoryTest.cs (4)
74var syntaxTree = returnType.DeclaringSyntaxReferences[0].SyntaxTree; 373var syntaxTree = method.DeclaringSyntaxReferences[0].SyntaxTree; 391var syntaxTree = controllerType.DeclaringSyntaxReferences[0].SyntaxTree; 410var syntaxTree = returnType.DeclaringSyntaxReferences[0].SyntaxTree;
System.Private.CoreLib.Generators (1)
IntrinsicsInSystemPrivateCoreLibAnalyzer.cs (1)
290var propertyDefiningSyntax = symbolInfo.Symbol.DeclaringSyntaxReferences[0].GetSyntax();