586 references to AttributeSyntax
Microsoft.AspNetCore.App.Analyzers (5)
Mvc\MvcAnalyzer.cs (1)
177if (attribute.ApplicationSyntaxReference.GetSyntax(cancellationToken) is AttributeSyntax attributeSyntax &&
RouteEmbeddedLanguage\FrameworkParametersCompletionProvider.cs (2)
297foreach (var attribute in attributeList.Attributes) 362foreach (var attribute in attributeList.Attributes)
RouteEmbeddedLanguage\Infrastructure\RouteStringSyntaxDetector.cs (1)
476if (argumentList.Parent is not AttributeSyntax invocableExpression)
RouteEmbeddedLanguage\Infrastructure\RouteUsageDetector.cs (1)
199if (argumentList.Parent is not AttributeSyntax attribute)
Microsoft.AspNetCore.Mvc.Api.Analyzers (4)
AddResponseTypeAttributeCodeFixAction.cs (4)
72AttributeSyntax attributeSyntax; 201private static AttributeSyntax CreateProducesResponseTypeAttribute(in CodeActionContext context, int statusCode, out bool addUsingDirective) 214private static AttributeSyntax CreateProducesResponseTypeAttribute(in CodeActionContext context, int statusCode, ITypeSymbol typeSymbol, out bool addUsingDirective) 246private static AttributeSyntax CreateProducesDefaultResponseTypeAttribute()
Microsoft.AspNetCore.SignalR.Client.SourceGenerator (6)
HubClientProxyGenerator.Parser.cs (3)
18internal static bool IsSyntaxTargetForAttribute(SyntaxNode node) => node is AttributeSyntax 38var attributeSyntax = (AttributeSyntax)context.Node;
HubServerProxyGenerator.Parser.cs (3)
18internal static bool IsSyntaxTargetForAttribute(SyntaxNode node) => node is AttributeSyntax 38var attributeSyntax = (AttributeSyntax)context.Node;
Microsoft.CodeAnalysis.CSharp (204)
Binder\Binder_Attributes.cs (18)
30ImmutableArray<Binder> binders, ImmutableArray<AttributeSyntax> attributesToBind, Symbol ownerSymbol, NamedTypeSymbol[] boundAttributeTypes, 31Action<AttributeSyntax>? beforeAttributePartBound, 32Action<AttributeSyntax>? afterAttributePartBound, 47AttributeSyntax attributeToBind = attributesToBind[i]; 73ImmutableArray<AttributeSyntax> attributesToBind, 77Action<AttributeSyntax>? beforeAttributePartBound, 78Action<AttributeSyntax>? afterAttributePartBound, 90AttributeSyntax attributeSyntax = attributesToBind[i]; 127AttributeSyntax node, NamedTypeSymbol boundAttributeType, 128Action<AttributeSyntax>? beforeAttributePartBound, 129Action<AttributeSyntax>? afterAttributePartBound, 138internal BoundAttribute BindAttribute(AttributeSyntax node, NamedTypeSymbol attributeType, Symbol? attributedMember, BindingDiagnosticBag diagnostics) 155private static BoundAttribute BindAttributeCore(Binder binder, AttributeSyntax node, NamedTypeSymbol attributeType, Symbol? attributedMember, BindingDiagnosticBag diagnostics) 296return new SourceAttributeData(Compilation, (AttributeSyntax)boundAttribute.Syntax, attributeType, attributeConstructor, hasErrors); 300ValidateTypeForAttributeParameters(attributeConstructor.Parameters, ((AttributeSyntax)boundAttribute.Syntax).Name, diagnostics, ref hasErrors); 321(AttributeSyntax)boundAttribute.Syntax, 335(AttributeSyntax)boundAttribute.Syntax, 699AttributeSyntax syntax,
Binder\Binder_Expressions.cs (1)
6072AttributeSyntax { Name: { } name } => name.Location,
Binder\Binder_Symbols.cs (1)
1002case AttributeSyntax parent when parent.Name == node: // [nint]
Binder\EarlyWellKnownAttributeBinder.cs (6)
27AttributeSyntax node, NamedTypeSymbol boundAttributeType, 28Action<AttributeSyntax> beforeAttributePartBound, 29Action<AttributeSyntax> afterAttributePartBound, 43AttributeSyntax node, NamedTypeSymbol boundAttributeType, 44Action<AttributeSyntax> beforeAttributePartBound, 45Action<AttributeSyntax> afterAttributePartBound,
Binder\ExpressionVariableFinder.cs (1)
167public override void VisitAttribute(AttributeSyntax node)
Binder\LocalBinderFactory.cs (1)
480public override void VisitAttribute(AttributeSyntax node)
Compilation\AttributeSemanticModel.cs (7)
22AttributeSyntax syntax, 39public static AttributeSemanticModel Create(PublicSemanticModel containingSemanticModel, AttributeSyntax syntax, NamedTypeSymbol attributeType, AliasSymbol aliasOpt, Symbol? attributeTarget, Binder rootBinder, ImmutableDictionary<Symbol, Symbol>? parentRemappedSymbolsOpt) 48public static SpeculativeSemanticModelWithMemberModel CreateSpeculative(SyntaxTreeSemanticModel parentSemanticModel, AttributeSyntax syntax, NamedTypeSymbol attributeType, AliasSymbol aliasOpt, Binder rootBinder, ImmutableDictionary<Symbol, Symbol> parentRemappedSymbolsOpt, int position) 89var attribute = (AttributeSyntax)node; 120return IsNullableAnalysisEnabledIn(Compilation, (AttributeSyntax)Root); 123internal static bool IsNullableAnalysisEnabledIn(CSharpCompilation compilation, AttributeSyntax syntax)
Compilation\CSharpSemanticModel.cs (13)
124(node is AttributeSyntax) || 238private Binder GetSpeculativeBinderForAttribute(int position, AttributeSyntax attribute) 399private BoundAttribute GetSpeculativelyBoundAttribute(int position, AttributeSyntax attribute, out Binder binder) 672public SymbolInfo GetSymbolInfo(AttributeSyntax attributeSyntax, CancellationToken cancellationToken = default(CancellationToken)) 747public SymbolInfo GetSpeculativeSymbolInfo(int position, AttributeSyntax attribute) 996public TypeInfo GetTypeInfo(AttributeSyntax attributeSyntax, CancellationToken cancellationToken = default(CancellationToken)) 1098public ImmutableArray<ISymbol> GetMemberGroup(AttributeSyntax attribute, CancellationToken cancellationToken = default(CancellationToken)) 2760public bool TryGetSpeculativeSemanticModel(int position, AttributeSyntax attribute, out SemanticModel speculativeModel) 3976parentSyntax.Kind() == SyntaxKind.Attribute && ((AttributeSyntax)parentSyntax).Name == boundNode.Syntax) 4955case AttributeSyntax attribute: 4980case AttributeSyntax attribute: 5001case AttributeSyntax attribute: 5024case AttributeSyntax attribute:
Compilation\PublicSemanticModel.cs (1)
17protected AttributeSemanticModel CreateModelForAttribute(Binder enclosingBinder, AttributeSyntax attribute, MemberSemanticModel containingModel)
Compilation\SpeculativeSemanticModelWithMemberModel.cs (4)
44AttributeSyntax syntax, 164case AttributeSyntax attribute: 178private MemberSemanticModel GetOrAddModelForAttribute(MemberSemanticModel containing, AttributeSyntax attribute) 181(node, binderAndModel) => CreateModelForAttribute(binderAndModel.binder, (AttributeSyntax)node, binderAndModel.model),
Compilation\SyntaxTreeSemanticModel.cs (5)
760internal PublicSemanticModel CreateSpeculativeAttributeSemanticModel(int position, AttributeSyntax attribute, Binder binder, AliasSymbol aliasOpt, NamedTypeSymbol attributeType) 953return GetOrAddModelForAttribute((AttributeSyntax)memberDecl); 975private MemberSemanticModel GetOrAddModelForAttribute(AttributeSyntax attribute) 985(node, binderAndModel) => CreateModelForAttribute(binderAndModel.binder, (AttributeSyntax)node, binderAndModel.model), 1236return CreateModelForAttribute(defaultOuter(), (AttributeSyntax)node, containingModel: null);
CSharpExtensions.cs (5)
561public static SymbolInfo GetSymbolInfo(this SemanticModel? semanticModel, AttributeSyntax attributeSyntax, CancellationToken cancellationToken = default(CancellationToken)) 631public static SymbolInfo GetSpeculativeSymbolInfo(this SemanticModel? semanticModel, int position, AttributeSyntax attribute) 733public static TypeInfo GetTypeInfo(this SemanticModel? semanticModel, AttributeSyntax attributeSyntax, CancellationToken cancellationToken = default(CancellationToken)) 953public static ImmutableArray<ISymbol> GetMemberGroup(this SemanticModel? semanticModel, AttributeSyntax attribute, CancellationToken cancellationToken = default(CancellationToken)) 1287public static bool TryGetSpeculativeSemanticModel([NotNullWhen(true)] this SemanticModel? semanticModel, int position, AttributeSyntax attribute, [NotNullWhen(true)] out SemanticModel? speculativeModel)
Errors\MessageProvider.cs (10)
260var node = (AttributeSyntax)attributeSyntax; 266var node = (AttributeSyntax)attributeSyntax; 272var node = (AttributeSyntax)attributeSyntax; 288var node = (AttributeSyntax)attributeSyntax; 294var node = (AttributeSyntax)attributeSyntax;
Parser\LanguageParser.cs (3)
1174LanguageParser @this, ref SyntaxToken openBracket, SeparatedSyntaxListBuilder<AttributeSyntax> list, SyntaxKind expectedKind, SyntaxKind closeKind) 1188private AttributeSyntax ParseAttribute() 1192return (AttributeSyntax)this.EatNode();
SourceGeneration\CSharpSyntaxHelper.cs (2)
29=> node is AttributeSyntax; 32=> ((AttributeSyntax)node).Name;
Symbols\Attributes\AttributeData.cs (13)
88internal static bool IsTargetEarlyAttribute(NamedTypeSymbol attributeType, AttributeSyntax attributeSyntax, AttributeDescription description) 215internal void DecodeSecurityAttribute<T>(Symbol targetSymbol, CSharpCompilation compilation, ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 241internal static void DecodeSkipLocalsInitAttribute<T>(CSharpCompilation compilation, ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 252internal static void DecodeMemberNotNullAttribute<T>(TypeSymbol type, ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 288private static void ReportBadNotNullMemberIfNeeded(TypeSymbol type, DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments, string memberName) 302internal static void DecodeMemberNotNullWhenAttribute<T>(TypeSymbol type, ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 339private DeclarativeSecurityAction DecodeSecurityAttributeAction(Symbol targetSymbol, CSharpCompilation compilation, AttributeSyntax? nodeOpt, out bool hasErrors, BindingDiagnosticBag diagnostics) 382private DeclarativeSecurityAction DecodeSecurityAction(TypedConstant typedValue, Symbol targetSymbol, AttributeSyntax? nodeOpt, BindingDiagnosticBag diagnostics, out bool hasErrors) 470private static Location GetSecurityAttributeActionSyntaxLocation(AttributeSyntax? nodeOpt, TypedConstant typedValue, out object displayString) 508private string? DecodePermissionSetAttribute(CSharpCompilation compilation, AttributeSyntax? nodeOpt, BindingDiagnosticBag diagnostics) 572internal void DecodeClassInterfaceAttribute(AttributeSyntax? nodeOpt, BindingDiagnosticBag diagnostics) 597internal void DecodeInterfaceTypeAttribute(AttributeSyntax node, BindingDiagnosticBag diagnostics) 623internal string DecodeGuidAttribute(AttributeSyntax? nodeOpt, BindingDiagnosticBag diagnostics)
Symbols\Attributes\SourceAttributeData.cs (4)
61internal SourceAttributeData(CSharpCompilation compilation, AttributeSyntax attributeSyntax, NamedTypeSymbol attributeClass, MethodSymbol? attributeConstructor, bool hasErrors) 77AttributeSyntax attributeSyntax, 134var attributeSyntax = (AttributeSyntax)_applicationNode.GetSyntax();
Symbols\Source\FieldSymbolWithAttributesAndModifiers.cs (5)
117internal sealed override (CSharpAttributeData?, BoundAttribute?) EarlyDecodeWellKnownAttribute(ref EarlyDecodeWellKnownAttributeArguments<EarlyWellKnownAttributeBinder, NamedTypeSymbol, AttributeSyntax, AttributeLocation> arguments) 162protected override void DecodeWellKnownAttributeImpl(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 203MarshalAsAttributeDecoder<FieldWellKnownAttributeData, AttributeSyntax, CSharpAttributeData, AttributeLocation>.Decode(ref arguments, AttributeTargets.Field, MessageProvider.Instance); 264private void VerifyConstantValueMatches(ConstantValue attrValue, ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 312internal override void PostDecodeWellKnownAttributes(ImmutableArray<CSharpAttributeData> boundAttributes, ImmutableArray<AttributeSyntax> allAttributeSyntaxNodes, BindingDiagnosticBag diagnostics, AttributeLocation symbolPart, WellKnownAttributeData decodedData)
Symbols\Source\QuickAttributeChecker.cs (1)
122public bool IsPossibleMatch(AttributeSyntax attr, QuickAttributes pattern)
Symbols\Source\SourceAssemblySymbol.cs (16)
1327var arguments = new DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation>(); 1669Func<AttributeSyntax, bool> attributeMatches = attribute switch 1681bool isPossibleAssemblySignatureKeyAttribute(AttributeSyntax node) 1687bool isPossibleAssemblyKeyNameAttribute(AttributeSyntax node) 1693bool isPossibleAssemblyKeyFileAttribute(AttributeSyntax node) 1703private static PooledHashSet<AttributeSyntax> t_forwardedTypesAttributesInProgress; 1721t_forwardedTypesAttributesInProgress = PooledHashSet<AttributeSyntax>.GetInstance(); 1747private static void BeforePossibleForwardedTypesAttributePartBound(AttributeSyntax node) 1753private static void AfterPossibleForwardedTypesAttributePartBound(AttributeSyntax node) 1759private bool IsPossibleForwardedTypesAttribute(AttributeSyntax node) 2196private static Location GetAssemblyAttributeLocationForDiagnostic(AttributeSyntax attributeSyntaxOpt) 2201private void DecodeTypeForwardedToAttribute(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 2268AttributeSyntax nodeOpt, 2357protected override void DecodeWellKnownAttributeImpl(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 2362private void DecodeWellKnownAttribute(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments, int index, bool isFromNetModule) 2593private static void ValidateIntegralAttributeNonNegativeArguments(CSharpAttributeData attribute, AttributeSyntax nodeOpt, BindingDiagnosticBag diagnostics)
Symbols\Source\SourceComplexParameterSymbol.cs (19)
621internal override void EarlyDecodeWellKnownAttributeType(NamedTypeSymbol attributeType, AttributeSyntax attributeSyntax) 644internal override (CSharpAttributeData?, BoundAttribute?) EarlyDecodeWellKnownAttribute(ref EarlyDecodeWellKnownAttributeArguments<EarlyWellKnownAttributeBinder, NamedTypeSymbol, AttributeSyntax, AttributeLocation> arguments) 708private (CSharpAttributeData?, BoundAttribute?) EarlyDecodeAttributeForDefaultParameterValue(AttributeDescription description, ref EarlyDecodeWellKnownAttributeArguments<EarlyWellKnownAttributeBinder, NamedTypeSymbol, AttributeSyntax, AttributeLocation> arguments) 737protected override void DecodeWellKnownAttributeImpl(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 787MarshalAsAttributeDecoder<ParameterWellKnownAttributeData, AttributeSyntax, CSharpAttributeData, AttributeLocation>.Decode(ref arguments, AttributeTargets.Parameter, MessageProvider.Instance); 892private void DecodeDefaultParameterValueAttribute(AttributeDescription description, ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 934private ConstantValue DecodeDefaultParameterValueAttribute(AttributeDescription description, CSharpAttributeData attribute, AttributeSyntax node, bool diagnose, BindingDiagnosticBag diagnosticsOpt) 953private ConstantValue DecodeDefaultParameterValueAttribute(CSharpAttributeData attribute, AttributeSyntax node, bool diagnose, BindingDiagnosticBag diagnosticsOpt) 1034private bool IsValidCallerInfoContext(AttributeSyntax node) => !ContainingSymbol.IsExplicitInterfaceImplementation() 1044private bool IsOnPartialImplementation(AttributeSyntax node) 1059private void ValidateCallerLineNumberAttribute(AttributeSyntax node, BindingDiagnosticBag diagnostics) 1087private void ValidateCallerFilePathAttribute(AttributeSyntax node, BindingDiagnosticBag diagnostics) 1120private void ValidateCallerMemberNameAttribute(AttributeSyntax node, BindingDiagnosticBag diagnostics) 1158private void ValidateCallerArgumentExpressionAttribute(AttributeSyntax node, CSharpAttributeData attribute, BindingDiagnosticBag diagnostics) 1215private void ValidateCancellationTokenAttribute(AttributeSyntax node, BindingDiagnosticBag diagnostics) 1241private void DecodeInterpolatedStringHandlerArgumentAttribute(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments, BindingDiagnosticBag diagnostics, int attributeIndex) 1324(int Ordinal, ParameterSymbol? Parameter)? decodeName(TypedConstant constant, ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 1381static void setInterpolatedStringHandlerAttributeError(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 1388internal override void PostDecodeWellKnownAttributes(ImmutableArray<CSharpAttributeData> boundAttributes, ImmutableArray<AttributeSyntax> allAttributeSyntaxNodes, BindingDiagnosticBag diagnostics, AttributeLocation symbolPart, WellKnownAttributeData decodedData)
Symbols\Source\SourceConstructorSymbolBase.cs (1)
232internal override (CSharpAttributeData?, BoundAttribute?) EarlyDecodeWellKnownAttribute(ref EarlyDecodeWellKnownAttributeArguments<EarlyWellKnownAttributeBinder, NamedTypeSymbol, AttributeSyntax, AttributeLocation> arguments)
Symbols\Source\SourceEventSymbol.cs (2)
253internal override (CSharpAttributeData?, BoundAttribute?) EarlyDecodeWellKnownAttribute(ref EarlyDecodeWellKnownAttributeArguments<EarlyWellKnownAttributeBinder, NamedTypeSymbol, AttributeSyntax, AttributeLocation> arguments) 296protected sealed override void DecodeWellKnownAttributeImpl(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments)
Symbols\Source\SourceFieldSymbol.cs (1)
114protected sealed override void DecodeWellKnownAttributeImpl(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments)
Symbols\Source\SourceMemberFieldSymbol.cs (1)
131internal override void PostDecodeWellKnownAttributes(ImmutableArray<CSharpAttributeData> boundAttributes, ImmutableArray<AttributeSyntax> allAttributeSyntaxNodes, BindingDiagnosticBag diagnostics, AttributeLocation symbolPart, WellKnownAttributeData decodedData)
Symbols\Source\SourceMethodSymbolWithAttributes.cs (16)
332internal override (CSharpAttributeData?, BoundAttribute?) EarlyDecodeWellKnownAttribute(ref EarlyDecodeWellKnownAttributeArguments<EarlyWellKnownAttributeBinder, NamedTypeSymbol, AttributeSyntax, AttributeLocation> arguments) 510protected override void DecodeWellKnownAttributeImpl(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 525private void DecodeWellKnownAttributeAppliedToMethod(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 539AttributeData.DecodeMethodImplAttribute<MethodWellKnownAttributeData, AttributeSyntax, CSharpAttributeData, AttributeLocation>(ref arguments, MessageProvider.Instance); 682ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments, 709private void ValidateConditionalAttribute(CSharpAttributeData attribute, AttributeSyntax node, BindingDiagnosticBag diagnostics) 773private void DecodeWellKnownAttributeAppliedToReturnValue(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 784MarshalAsAttributeDecoder<ReturnTypeWellKnownAttributeData, AttributeSyntax, CSharpAttributeData, AttributeLocation>.Decode(ref arguments, AttributeTargets.ReturnValue, MessageProvider.Instance); 812private void DecodeDllImportAttribute(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 937private void DecodeModuleInitializerAttribute(DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 986private void DecodeInterceptsLocationAttribute(DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 1004private void DecodeInterceptsLocationChecksumBased(DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments, int version, string? data) 1160DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments, 1357static void reportFeatureNotEnabled(BindingDiagnosticBag diagnostics, AttributeSyntax attributeSyntax, ArrayBuilder<string> namespaceNames) 1371private void DecodeUnmanagedCallersOnlyAttribute(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 1457internal override void PostDecodeWellKnownAttributes(ImmutableArray<CSharpAttributeData> boundAttributes, ImmutableArray<AttributeSyntax> allAttributeSyntaxNodes, BindingDiagnosticBag diagnostics, AttributeLocation symbolPart, WellKnownAttributeData decodedData)
Symbols\Source\SourceModuleSymbol.cs (1)
551protected override void DecodeWellKnownAttributeImpl(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments)
Symbols\Source\SourceNamedTypeSymbol.cs (8)
897internal override (CSharpAttributeData?, BoundAttribute?) EarlyDecodeWellKnownAttribute(ref EarlyDecodeWellKnownAttributeArguments<EarlyWellKnownAttributeBinder, NamedTypeSymbol, AttributeSyntax, AttributeLocation> arguments) 1090protected sealed override void DecodeWellKnownAttributeImpl(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 1133AttributeData.DecodeStructLayoutAttribute<TypeWellKnownAttributeData, AttributeSyntax, CSharpAttributeData, AttributeLocation>( 1275foreach (AttributeSyntax attr in attrList.Attributes) 1291private AttributeUsageInfo DecodeAttributeUsageAttribute(CSharpAttributeData attribute, AttributeSyntax node, bool diagnose, BindingDiagnosticBag diagnosticsOpt = null) 1328private void DecodeCoClassAttribute(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 1381private void ValidateConditionalAttribute(CSharpAttributeData attribute, AttributeSyntax node, BindingDiagnosticBag diagnostics) 1563internal override void PostDecodeWellKnownAttributes(ImmutableArray<CSharpAttributeData> boundAttributes, ImmutableArray<AttributeSyntax> allAttributeSyntaxNodes, BindingDiagnosticBag diagnostics, AttributeLocation symbolPart, WellKnownAttributeData decodedData)
Symbols\Source\SourcePropertySymbolBase.cs (4)
1240internal override (CSharpAttributeData?, BoundAttribute?) EarlyDecodeWellKnownAttribute(ref EarlyDecodeWellKnownAttributeArguments<EarlyWellKnownAttributeBinder, NamedTypeSymbol, AttributeSyntax, AttributeLocation> arguments) 1320protected override void DecodeWellKnownAttributeImpl(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 1498internal override void PostDecodeWellKnownAttributes(ImmutableArray<CSharpAttributeData> boundAttributes, ImmutableArray<AttributeSyntax> allAttributeSyntaxNodes, BindingDiagnosticBag diagnostics, AttributeLocation symbolPart, WellKnownAttributeData decodedData) 1510private void ValidateIndexerNameAttribute(CSharpAttributeData attribute, AttributeSyntax node, BindingDiagnosticBag diagnostics)
Symbols\Source\SourceTypeParameterSymbol.cs (1)
426protected sealed override void DecodeWellKnownAttributeImpl(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments)
Symbols\Symbol.cs (2)
1524internal bool ReportExplicitUseOfReservedAttributes(in DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments, ReservedAttributes reserved) 1604bool reportExplicitUseOfReservedAttribute(CSharpAttributeData attribute, in DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments, in AttributeDescription attributeDescription)
Symbols\Symbol_Attributes.cs (23)
122internal virtual void EarlyDecodeWellKnownAttributeType(NamedTypeSymbol attributeType, AttributeSyntax attributeSyntax) 142internal virtual (CSharpAttributeData?, BoundAttribute?) EarlyDecodeWellKnownAttribute(ref EarlyDecodeWellKnownAttributeArguments<EarlyWellKnownAttributeBinder, NamedTypeSymbol, AttributeSyntax, AttributeLocation> arguments) 148ref EarlyDecodeWellKnownAttributeArguments<EarlyWellKnownAttributeBinder, NamedTypeSymbol, AttributeSyntax, AttributeLocation> arguments, 216protected void DecodeWellKnownAttribute(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 238protected virtual void DecodeWellKnownAttributeImpl(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 260internal virtual void PostDecodeWellKnownAttributes(ImmutableArray<CSharpAttributeData> boundAttributes, ImmutableArray<AttributeSyntax> allAttributeSyntaxNodes, BindingDiagnosticBag diagnostics, AttributeLocation symbolPart, WellKnownAttributeData decodedData) 305Func<AttributeSyntax, bool>? attributeMatchesOpt = null, 306Action<AttributeSyntax>? beforeAttributePartBound = null, 307Action<AttributeSyntax>? afterAttributePartBound = null) 314ImmutableArray<AttributeSyntax> attributesToBind = this.GetAttributesToBind(attributesSyntaxLists, symbolPart, diagnostics, compilation, attributeMatchesOpt, binderOpt, out binders); 442void removeObsoleteDiagnosticsForForwardedTypes(ImmutableArray<CSharpAttributeData> boundAttributes, ImmutableArray<AttributeSyntax> attributesToBind, ref BindingDiagnosticBag diagnostics) 584private ImmutableArray<AttributeSyntax> GetAttributesToBind( 589Func<AttributeSyntax, bool> attributeMatchesOpt, 595ArrayBuilder<AttributeSyntax> syntaxBuilder = null; 613syntaxBuilder = new ArrayBuilder<AttributeSyntax>(); 659return ImmutableArray<AttributeSyntax>.Empty; 768ImmutableArray<AttributeSyntax> attributesToBind, 780var arguments = new EarlyDecodeWellKnownAttributeArguments<EarlyWellKnownAttributeBinder, NamedTypeSymbol, AttributeSyntax, AttributeLocation>(); 814private void EarlyDecodeWellKnownAttributeTypes(ImmutableArray<NamedTypeSymbol> attributeTypes, ImmutableArray<AttributeSyntax> attributeSyntaxList) 839ImmutableArray<AttributeSyntax> attributeSyntaxList, 852var arguments = new DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation>(); 860AttributeSyntax attributeSyntax = attributeSyntaxList[i]; 888AttributeSyntax node,
Symbols\Synthesized\Records\SynthesizedPrimaryConstructor.cs (3)
140internal override (CSharpAttributeData?, BoundAttribute?) EarlyDecodeWellKnownAttribute(ref EarlyDecodeWellKnownAttributeArguments<EarlyWellKnownAttributeBinder, NamedTypeSymbol, AttributeSyntax, AttributeLocation> arguments) 149protected override void DecodeWellKnownAttributeImpl(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 157internal override void PostDecodeWellKnownAttributes(ImmutableArray<CSharpAttributeData> boundAttributes, ImmutableArray<AttributeSyntax> allAttributeSyntaxNodes, BindingDiagnosticBag diagnostics, AttributeLocation symbolPart, WellKnownAttributeData decodedData)
Symbols\Synthesized\SynthesizedBackingFieldSymbol.cs (2)
122protected sealed override void DecodeWellKnownAttributeImpl(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 148internal override void PostDecodeWellKnownAttributes(ImmutableArray<CSharpAttributeData> boundAttributes, ImmutableArray<AttributeSyntax> allAttributeSyntaxNodes, BindingDiagnosticBag diagnostics, AttributeLocation symbolPart, WellKnownAttributeData decodedData)
Syntax\SyntaxFacts.cs (3)
47var p = node.Parent as AttributeSyntax; 91return ((AttributeSyntax)parent).Name == node;
Microsoft.CodeAnalysis.CSharp.CodeStyle (12)
src\Analyzers\CSharp\Analyzers\QualifyMemberAccess\CSharpQualifyMemberAccessDiagnosticAnalyzer.cs (1)
32if (node.GetAncestorOrThis<AttributeSyntax>() != null)
src\Analyzers\CSharp\Analyzers\RemoveUnnecessarySuppressions\CSharpRemoveUnnecessaryAttributeSuppressionsDiagnosticAnalyzer.cs (1)
23foreach (var attribute in attributeList.Attributes)
src\Analyzers\CSharp\Analyzers\UseNameofInNullableAttribute\CSharpUseNameofInNullableAttributeDiagnosticAnalyzer.cs (3)
58var attribute = (AttributeSyntax)context.Node; 117private static bool MatchesParameterOnContainer(AttributeSyntax attribute, string stringValue)
src\Analyzers\CSharp\Analyzers\UseUtf8StringLiteral\UseUtf8StringLiteralDiagnosticAnalyzer.cs (1)
82if (arrayCreationOperation.Syntax.Ancestors().OfType<AttributeSyntax>().Any())
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\AttributeArgumentSyntaxExtensions.cs (1)
36if (argumentList.Parent is not AttributeSyntax invocableExpression)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SemanticModelExtensions.cs (1)
139case AttributeSyntax attribute:
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpSyntaxFacts.cs (2)
1588var attribute = (AttributeSyntax)node;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\SpeculationAnalyzer.cs (2)
32AttributeSyntax, 146semanticModel.TryGetSpeculativeSemanticModel(position, (AttributeSyntax)nodeToSpeculate, out speculativeModel);
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (14)
src\Analyzers\CSharp\CodeFixes\AddExplicitCast\AttributeArgumentFixer.cs (3)
15private class AttributeArgumentFixer : Fixer<AttributeArgumentSyntax, AttributeArgumentListSyntax, AttributeSyntax> 31var newAttribute = (AttributeSyntax)newArgumentList.Parent!;
src\Analyzers\CSharp\CodeFixes\AddExplicitCast\CSharpAddExplicitCastCodeFixProvider.cs (1)
80&& attributeArgumentList.Parent is AttributeSyntax attributeNode)
src\Analyzers\CSharp\CodeFixes\GenerateConstructor\CSharpGenerateConstructorService.cs (1)
126if (fullName.Parent is AttributeSyntax attribute)
src\Analyzers\CSharp\CodeFixes\GenerateConstructor\GenerateConstructorCodeFixProvider.cs (2)
54AttributeSyntax; 63case AttributeSyntax attributeNode:
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\AttributeGenerator.cs (3)
51var attributeSyntax = TryGenerateAttribute(attribute, info); 61private static AttributeSyntax? TryGenerateAttribute(AttributeData attribute, CSharpCodeGenerationContextInfo info) 68var reusableSyntax = GetReuseableSyntaxNodeForAttribute<AttributeSyntax>(attribute, info);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpTypeInferenceService.TypeInferrer.cs (4)
146AttributeSyntax _ => InferTypeInAttribute(), 375if (argument.Parent.Parent is AttributeSyntax attribute) 531if (attributeArgumentList.Parent is AttributeSyntax attribute) 540private IEnumerable<TypeInferenceInfo> InferTypeInAttribute(AttributeSyntax attribute, int index, AttributeArgumentSyntax argumentOpt = null)
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (37)
Attributes\AttributeTests.cs (32)
53var typeForwardedTo = SyntaxFactory.Attribute(SyntaxFactory.ParseName("TypeForwardedTo")); 54var typeIdentifier = SyntaxFactory.Attribute(SyntaxFactory.ParseName("TypeIdentifier")); 64var alias1 = SyntaxFactory.Attribute(SyntaxFactory.ParseName("alias1")); 74var alias2 = SyntaxFactory.Attribute(SyntaxFactory.ParseName("alias2")); 81var alias3 = SyntaxFactory.Attribute(SyntaxFactory.ParseName("alias3")); 707var attrSyntax = root.DescendantNodes().OfType<AttributeSyntax>().Last(); 748var attrSyntax = root.DescendantNodes().OfType<AttributeSyntax>().Last(); 752var newAttrSyntax = newRoot.DescendantNodes().OfType<AttributeSyntax>().Last(); 812var attrSyntax = root.DescendantNodes().OfType<AttributeSyntax>().Last(); 817var newAttrSyntax = newRoot.DescendantNodes().OfType<AttributeSyntax>().Last(); 854var attrSyntax = root.DescendantNodes().OfType<AttributeSyntax>().Last(); 858var newAttrSyntax = newRoot.DescendantNodes().OfType<AttributeSyntax>().Last(); 895var attrSyntax = root.DescendantNodes().OfType<AttributeSyntax>().Last(); 899var newAttrSyntax = newRoot.DescendantNodes().OfType<AttributeSyntax>().Last(); 934var attrSyntax = root.DescendantNodes().OfType<AttributeSyntax>().First(); 938var newAttrSyntax = newRoot.DescendantNodes().OfType<AttributeSyntax>().First(); 3124var syntax = (AttributeSyntax)attrs[0].ApplicationSyntaxReference.GetSyntax(); 3126syntax = (AttributeSyntax)attrs[1].ApplicationSyntaxReference.GetSyntax(); 3421Assert.IsType<AttributeSyntax>(syntax); 11632VerifyOperationTreeAndDiagnosticsForTest<AttributeSyntax>(comp, expectedOperationTree, expectedDiagnostics);
Semantics\OutVarTests.cs (1)
36323Assert.True(model.TryGetSpeculativeSemanticModel(method.Body.SpanStart + 1, method.DescendantNodes().OfType<AttributeSyntax>().Single(), out speculativeModel));
Semantics\PrimaryConstructorTests.cs (2)
6859var attrApplication = tree.GetRoot().DescendantNodes().OfType<AttributeSyntax>().Single();
Semantics\RecordTests.cs (2)
30396var attrApplication = tree.GetRoot().DescendantNodes().OfType<AttributeSyntax>().Single();
Microsoft.CodeAnalysis.CSharp.Features (39)
ChangeSignature\CSharpChangeSignatureService.cs (3)
487if (updatedNode is AttributeSyntax attribute) 489var symbolInfo = semanticModel.GetSymbolInfo((AttributeSyntax)originalNode, cancellationToken); 592if (node is AttributeSyntax attribute)
CodeFixes\Suppression\CSharpSuppressionCodeFixProvider.cs (2)
160var attributes = new SeparatedSyntaxList<AttributeSyntax>() 214if (attribute is AttributeSyntax attributeSyntax)
Completion\CompletionProviders\AttributeNamedParameterCompletionProvider.cs (5)
73if (token.Parent!.Parent is not AttributeSyntax attributeSyntax || token.Parent is not AttributeArgumentListSyntax attributeArgumentList) 155SyntaxToken token, AttributeSyntax attributeSyntax, ISet<string> existingNamedParameters) 177CompletionContext context, SemanticModel semanticModel, SyntaxToken token, AttributeSyntax attributeSyntax, ISet<string> existingNamedParameters) 221AttributeSyntax attribute, 237AttributeSyntax attribute,
Completion\CompletionProviders\InternalsVisibleToCompletionProvider.cs (1)
50var arguments = ((AttributeSyntax)internalsVisibleToAttribute).ArgumentList!.Arguments;
Completion\KeywordRecommenders\TypeOfKeywordRecommender.cs (1)
32context.LeftToken.GetAncestor<AttributeSyntax>() != null;
EditAndContinue\SyntaxComparer.cs (3)
917distance = ComputeDistance((AttributeSyntax)leftNode, (AttributeSyntax)rightNode); 1499return ((AttributeSyntax)node).Name;
MetadataAsSource\CSharpMetadataAsSourceService.cs (1)
135return annotatedChildren.Any(n => n.GetAncestorOrThis<AttributeSyntax>() == null);
QuickInfo\CSharpDiagnosticAnalyzerQuickInfoProvider.cs (1)
103Parent: AttributeSyntax
SignatureHelp\AttributeSignatureHelpProvider.cs (6)
47[NotNullWhen(true)] out AttributeSyntax? attribute) 64token.Parent.Parent is AttributeSyntax; 67private static bool IsArgumentListToken(AttributeSyntax expression, SyntaxToken token) 77if (!TryGetAttributeExpression(root, position, document.GetRequiredLanguageService<ISyntaxFactsService>(), triggerInfo.TriggerReason, cancellationToken, out var attribute)) 119if (TryGetAttributeExpression(root, position, syntaxFacts, SignatureHelpTriggerReason.InvokeSignatureHelpCommand, cancellationToken, out var expression) && 131AttributeSyntax attribute,
src\Analyzers\CSharp\Analyzers\QualifyMemberAccess\CSharpQualifyMemberAccessDiagnosticAnalyzer.cs (1)
32if (node.GetAncestorOrThis<AttributeSyntax>() != null)
src\Analyzers\CSharp\Analyzers\RemoveUnnecessarySuppressions\CSharpRemoveUnnecessaryAttributeSuppressionsDiagnosticAnalyzer.cs (1)
23foreach (var attribute in attributeList.Attributes)
src\Analyzers\CSharp\Analyzers\UseNameofInNullableAttribute\CSharpUseNameofInNullableAttributeDiagnosticAnalyzer.cs (3)
58var attribute = (AttributeSyntax)context.Node; 117private static bool MatchesParameterOnContainer(AttributeSyntax attribute, string stringValue)
src\Analyzers\CSharp\Analyzers\UseUtf8StringLiteral\UseUtf8StringLiteralDiagnosticAnalyzer.cs (1)
82if (arrayCreationOperation.Syntax.Ancestors().OfType<AttributeSyntax>().Any())
src\Analyzers\CSharp\CodeFixes\AddExplicitCast\AttributeArgumentFixer.cs (3)
15private class AttributeArgumentFixer : Fixer<AttributeArgumentSyntax, AttributeArgumentListSyntax, AttributeSyntax> 31var newAttribute = (AttributeSyntax)newArgumentList.Parent!;
src\Analyzers\CSharp\CodeFixes\AddExplicitCast\CSharpAddExplicitCastCodeFixProvider.cs (1)
80&& attributeArgumentList.Parent is AttributeSyntax attributeNode)
src\Analyzers\CSharp\CodeFixes\GenerateConstructor\CSharpGenerateConstructorService.cs (1)
126if (fullName.Parent is AttributeSyntax attribute)
src\Analyzers\CSharp\CodeFixes\GenerateConstructor\GenerateConstructorCodeFixProvider.cs (2)
54AttributeSyntax; 63case AttributeSyntax attributeNode:
src\Compilers\CSharp\CSharpAnalyzerDriver\CSharpDeclarationComputer.cs (1)
338foreach (var attribute in attributeList.Attributes)
Testing\CSharpTestMethodFinder.cs (2)
31foreach (var attribute in attributeList.Attributes) 44private bool IsTestAttribute(AttributeSyntax attribute)
Microsoft.CodeAnalysis.CSharp.IOperation.UnitTests (37)
IOperation\IOperationTests_IArgument.cs (1)
3558VerifyOperationTreeAndDiagnosticsForTest<AttributeSyntax>(source, expectedOperationTree, expectedDiagnostics);
IOperation\IOperationTests_IAttributeOperation.cs (35)
67VerifyOperationTreeAndDiagnosticsForTest<AttributeSyntax>(source, expectedOperationTree, expectedDiagnostics); 68VerifyFlowGraphAndDiagnosticsForTest<AttributeSyntax>(source, expectedFlowGraph, expectedDiagnostics); 104VerifyOperationTreeAndDiagnosticsForTest<AttributeSyntax>(source, expectedOperationTree, expectedDiagnostics); 141VerifyOperationTreeAndDiagnosticsForTest<AttributeSyntax>(source, expectedOperationTree, expectedDiagnostics); 176VerifyOperationTreeAndDiagnosticsForTest<AttributeSyntax>(source, expectedOperationTree, expectedDiagnostics); 205VerifyOperationTreeAndDiagnosticsForTest<AttributeSyntax>(source, expectedOperationTree, expectedDiagnostics); 230VerifyOperationTreeAndDiagnosticsForTest<AttributeSyntax>(source, expectedOperationTree, expectedDiagnostics); 262VerifyOperationTreeAndDiagnosticsForTest<AttributeSyntax>(source, expectedOperationTree, expectedDiagnostics); 294VerifyOperationTreeAndDiagnosticsForTest<AttributeSyntax>(source, expectedOperationTree, expectedDiagnostics); 326VerifyOperationTreeAndDiagnosticsForTest<AttributeSyntax>(source, expectedOperationTree, expectedDiagnostics); 362VerifyOperationTreeAndDiagnosticsForTest<AttributeSyntax>(source, expectedOperationTree, expectedDiagnostics); 398VerifyOperationTreeAndDiagnosticsForTest<AttributeSyntax>(source, expectedOperationTree, expectedDiagnostics); 442VerifyOperationTreeAndDiagnosticsForTest<AttributeSyntax>(source, expectedOperationTree, expectedDiagnostics); 473VerifyOperationTreeAndDiagnosticsForTest<AttributeSyntax>(source, expectedOperationTree, expectedDiagnostics); 531VerifyOperationTreeAndDiagnosticsForTest<AttributeSyntax>(source, expectedOperationTree, expectedDiagnostics); 568VerifyOperationTreeAndDiagnosticsForTest<AttributeSyntax>(source, expectedOperationTree, expectedDiagnostics); 605VerifyOperationTreeAndDiagnosticsForTest<AttributeSyntax>(source, expectedOperationTree, expectedDiagnostics); 637VerifyOperationTreeAndDiagnosticsForTest<AttributeSyntax>(source, expectedOperationTree, expectedDiagnostics); 666VerifyOperationTreeAndDiagnosticsForTest<AttributeSyntax>(source, expectedOperationTree, expectedDiagnostics); 696VerifyOperationTreeAndDiagnosticsForTest<AttributeSyntax>(source, expectedOperationTree, expectedDiagnostics); 737VerifyOperationTreeAndDiagnosticsForTest<AttributeSyntax>(source, expectedOperationTree, expectedDiagnostics); 774VerifyOperationTreeAndDiagnosticsForTest<AttributeSyntax>(source, expectedOperationTree, expectedDiagnostics); 811VerifyOperationTreeAndDiagnosticsForTest<AttributeSyntax>(source, expectedOperationTree, expectedDiagnostics); 847VerifyOperationTreeAndDiagnosticsForTest<AttributeSyntax>(source, expectedOperationTree, expectedDiagnostics); 893VerifyOperationTreeAndDiagnosticsForTest<AttributeSyntax>(source, expectedOperationTree, expectedDiagnostics); 1023VerifyOperationTreeAndDiagnosticsForTest<AttributeSyntax>(source, expectedOperationTree, expectedDiagnostics); 1024VerifyFlowGraphAndDiagnosticsForTest<AttributeSyntax>(source, expectedFlowGraph, expectedDiagnostics); 1056VerifyOperationTreeAndDiagnosticsForTest<AttributeSyntax>(source, expectedOperationTree, expectedDiagnostics); 1087VerifyOperationTreeAndDiagnosticsForTest<AttributeSyntax>(source, expectedOperationTree, expectedDiagnostics); 1118VerifyOperationTreeAndDiagnosticsForTest<AttributeSyntax>(source, expectedOperationTree, expectedDiagnostics, targetFramework: TargetFramework.NetCoreApp); 1162VerifyOperationTreeAndDiagnosticsForTest<AttributeSyntax>(source, expectedOperationTree, expectedDiagnostics); 1197VerifyOperationTreeAndDiagnosticsForTest<AttributeSyntax>(source, expectedOperationTree, expectedDiagnostics); 1230VerifyOperationTreeAndDiagnosticsForTest<AttributeSyntax>(source, expectedOperationTree, expectedDiagnostics); 1265VerifyOperationTreeAndDiagnosticsForTest<AttributeSyntax>(source, expectedOperationTree, expectedDiagnostics); 1299VerifyOperationTreeAndDiagnosticsForTest<AttributeSyntax>(source, expectedOperationTree, expectedDiagnostics);
IOperation\IOperationTests_IFieldReferenceExpression.cs (1)
51VerifyOperationTreeAndDiagnosticsForTest<AttributeSyntax>(source, expectedOperationTree, expectedDiagnostics);
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (37)
Semantics\LambdaTests.cs (4)
3937var attributeSyntaxes = tree.GetRoot().DescendantNodes().OfType<AttributeSyntax>().ToImmutableArray(); 3944void verify(AttributeSyntax attributeSyntax, string expectedAttributeName) 3977var a = (IdentifierNameSyntax)tree.GetRoot().DescendantNodes().OfType<AttributeSyntax>().Single().Name; 3990a = (IdentifierNameSyntax)newTree.GetRoot().DescendantNodes().OfType<AttributeSyntax>().Single().Name;
Semantics\LocalFunctionTests.cs (29)
451var attributeSyntax = tree.GetRoot().DescendantNodes().OfType<AttributeSyntax>().Single(); 500var attribute = attributeList.Attributes.Single(); 548var attribute = attributeList.Attributes.Single(); 812var attribute = attributeList.Attributes.Single(); 1022var attributeSyntaxes = tree.GetRoot().DescendantNodes().OfType<AttributeSyntax>().ToList(); 1026foreach (var attributeSyntax in attributeSyntaxes) 1060var attrSyntax = tree.GetRoot().DescendantNodes().OfType<AttributeSyntax>().Single(); 7348var attr = parseAttributeSyntax("[My(nameof(TParameter))]", parseOptions); 7359static AttributeSyntax parseAttributeSyntax(string source, CSharpParseOptions parseOptions) 7360=> SyntaxFactory.ParseCompilationUnit($@"class X {{ {source} void M() {{ }} }}", options: parseOptions).DescendantNodes().OfType<AttributeSyntax>().Single(); 7363static void VerifyTParameterSpeculation(SemanticModel parentModel, int localFuncPosition, AttributeSyntax attr1, bool found = true) 7500var attr = parseAttributeSyntax("[My(nameof(TParameter))]", TestOptions.Regular10); 7531static AttributeSyntax parseAttributeSyntax(string source, CSharpParseOptions parseOptions) 7532=> SyntaxFactory.ParseCompilationUnit($@"class X {{ {source} void M() {{ }} }}", options: parseOptions).DescendantNodes().OfType<AttributeSyntax>().Single(); 7574var attr = parseAttributeSyntax("[My(nameof(TParameter))]", parseOptions); 7584static AttributeSyntax parseAttributeSyntax(string source, CSharpParseOptions parseOptions) 7585=> SyntaxFactory.ParseCompilationUnit($@"class X {{ {source} void M() {{ }} }}", options: parseOptions).DescendantNodes().OfType<AttributeSyntax>().Single(); 8930var attr = parseAttributeSyntax("[My(nameof(parameter))]", parseOptions); 8940static AttributeSyntax parseAttributeSyntax(string source, CSharpParseOptions parseOptions) 8941=> SyntaxFactory.ParseCompilationUnit($@"class X {{ {source} void M() {{ }} }}", options: parseOptions).DescendantNodes().OfType<AttributeSyntax>().Single(); 8944static void VerifyParameterSpeculation(SemanticModel parentModel, int localFuncPosition, AttributeSyntax attr1, bool found = true) 9434var attr = parseAttributeSyntax("[My(nameof(parameter))]", TestOptions.Regular10); 9444static AttributeSyntax parseAttributeSyntax(string source, CSharpParseOptions parseOptions) 9445=> SyntaxFactory.ParseCompilationUnit($@"class X {{ {source} void M() {{ }} }}", options: parseOptions).DescendantNodes().OfType<AttributeSyntax>().Single(); 9752var attr = parseAttributeSyntax("[My(nameof(parameter))]", TestOptions.Regular10); 9762static AttributeSyntax parseAttributeSyntax(string source, CSharpParseOptions parseOptions) 9763=> SyntaxFactory.ParseCompilationUnit($@"class X {{ {source} void M() {{ }} }}", options: parseOptions).DescendantNodes().OfType<AttributeSyntax>().Single();
Semantics\LookupTests.cs (2)
2122var node = tree.GetRoot().DescendantNodes().OfType<AttributeSyntax>().Single();
Semantics\NonTrailingNamedArgumentsTests.cs (2)
984var invocation = nodes.OfType<AttributeSyntax>().ElementAt(1);
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (47)
Compilation\SemanticModelAPITests.cs (6)
2178var attribute = methodDecl.AttributeLists[0].Attributes[0]; 2223var attribute = methodDecl.AttributeLists[0].Attributes[0]; 3525var attr2 = ParseAttributeSyntax("[ObsoleteAttribute(string.Empty is string s ? s : string.Empty)]"); 3546var attr2 = ParseAttributeSyntax("[ObsoleteAttribute(string.Empty is string s ? s : string.Empty)]"); 3555private AttributeSyntax ParseAttributeSyntax(string source) 3585var attributeSyntax = SyntaxFactory.Attribute(SyntaxFactory.IdentifierName("Category"));
Compilation\SemanticModelGetDeclaredSymbolAPITests.cs (18)
3966var attr = (AttributeSyntax)((ClassDeclarationSyntax)((CompilationUnitSyntax)tree2.GetCompilationUnitRoot()).Members[0]).AttributeLists[0].Attributes[0]; 4104private AttributeSyntax ParseAttributeSyntax(string source) 4170var attr1 = ParseAttributeSyntax("[Obsolete]"); 4178var attr2 = ParseAttributeSyntax("[ObsoleteAttribute(4)]"); 4188var attr3 = ParseAttributeSyntax(@"[O(""hello"")]"); 4196var attr4 = ParseAttributeSyntax("[P]"); 4203var attr5 = ParseAttributeSyntax("[D]"); 4211var attr6 = ParseAttributeSyntax(@"[O(""hello"")]"); 4220var attr7 = ParseAttributeSyntax(@"[O(""hello"")]"); 4249var attr1 = ParseAttributeSyntax("[Obsolete]"); 4262var attr2 = ParseAttributeSyntax("[ObsoleteAttribute(4)]"); 4279var attr3 = ParseAttributeSyntax(@"[O(""hello"")]"); 4300var attr4 = ParseAttributeSyntax("[P]"); 4311var attr5 = ParseAttributeSyntax("[D]"); 4323var attr6 = ParseAttributeSyntax(@"[O(""hello"")]"); 4346var attr7 = ParseAttributeSyntax(@"[O(""hello"")]"); 4369var attr8 = SyntaxFactory.ParseCompilationUnit(@"[assembly: O(""hello"")]").AttributeLists.First().Attributes.First();
Compilation\SemanticModelGetSemanticInfoTests.cs (19)
5103var semanticInfo = GetSemanticInfoForTest<AttributeSyntax>(sourceCode); 5275var semanticInfo = GetSemanticInfoForTest<AttributeSyntax>(sourceCode); 7755var semanticInfo = GetSemanticInfoForTest<AttributeSyntax>(sourceCode); 8366var semanticInfo = GetSemanticInfoForTest<AttributeSyntax>(sourceCode); 8400var semanticInfo = GetSemanticInfoForTest<AttributeSyntax>(sourceCode); 8433var attributeNode = tree.FindNodeOrTokenByKind(SyntaxKind.Attribute).AsNode() as AttributeSyntax; 8457var attributeNode = tree.FindNodeOrTokenByKind(SyntaxKind.Attribute).AsNode() as AttributeSyntax; 9451var semanticInfo = GetSemanticInfoForTest<AttributeSyntax>(sourceCode); 9531var semanticInfo = GetSemanticInfoForTest<AttributeSyntax>(sourceCode); 9914var semanticInfo = GetSemanticInfoForTest<AttributeSyntax>(sourceCode); 9948var semanticInfo = GetSemanticInfoForTest<AttributeSyntax>(sourceCode); 10020var semanticInfo = GetSemanticInfoForTest<AttributeSyntax>(sourceCode); 10244var semanticInfo = GetSemanticInfoForTest<AttributeSyntax>(sourceCode); 10314var semanticInfo = GetSemanticInfoForTest<AttributeSyntax>(sourceCode); 10832var semanticInfo = GetSemanticInfoForTest<AttributeSyntax>(sourceCode); 11125var semanticInfo = GetSemanticInfoForTest<AttributeSyntax>(sourceCode); 11606var semanticInfo = GetSemanticInfoForTest<AttributeSyntax>(sourceCode);
Symbols\Source\NullablePublicAPITests.cs (4)
4064var speculativeAttribute = SyntaxFactory.Attribute(SyntaxFactory.ParseName("A"), SyntaxFactory.ParseAttributeArgumentList("(o2)")); 4211var attributeUsage = root.DescendantNodes().OfType<AttributeSyntax>().ElementAt(1); 4212var newAttributeUsage = SyntaxFactory.Attribute(SyntaxFactory.ParseName("Attr"), SyntaxFactory.ParseAttributeArgumentList("(Constant)"));
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (10)
Generated\Syntax.Test.xml.Generated.cs (6)
10653=> SyntaxFactory.AttributeList(SyntaxFactory.Token(SyntaxKind.OpenBracketToken), default(AttributeTargetSpecifierSyntax), new SeparatedSyntaxList<AttributeSyntax>(), SyntaxFactory.Token(SyntaxKind.CloseBracketToken)); 10658private static AttributeSyntax GenerateAttribute() 12857var node = GenerateAttribute(); 12861var newNode = node.WithName(node.Name).WithArgumentList(node.ArgumentList); 18103var oldNode = GenerateAttribute(); 18119var oldNode = GenerateAttribute();
IncrementalParsing\IncrementalParsingTests.cs (4)
491Assert.True(tree.GetRoot().DescendantNodesAndSelf().Any(n => n is AttributeSyntax)); 501Assert.False(tree.GetRoot().DescendantNodesAndSelf().Any(n => n is AttributeSyntax)); 523Assert.False(tree.GetRoot().DescendantNodesAndSelf().Any(n => n is AttributeSyntax)); 533Assert.True(tree.GetRoot().DescendantNodesAndSelf().Any(n => n is AttributeSyntax));
Microsoft.CodeAnalysis.CSharp.Test.Utilities (1)
CompilationTestUtils.cs (1)
245else if (node is AttributeSyntax attribute)
Microsoft.CodeAnalysis.CSharp.Workspaces (30)
CodeGeneration\CSharpSyntaxGenerator.cs (13)
997return node is AttributeSyntax attr ? SyntaxFactory.AttributeList([attr]) : (AttributeListSyntax)node; 1122var attr = (AttributeSyntax)attributeDeclaration; 1170var attr = (AttributeSyntax)declaration; 1190var attr = (AttributeSyntax)declaration; 1918AttributeSyntax attribute => attribute.Name.ToString(), 1952AttributeSyntax attribute => ReplaceWithTrivia(declaration, attribute.Name, this.DottedName(name)), 2046var attr = (AttributeSyntax)declaration; 3014var attr = (AttributeSyntax)declaration;
Rename\CSharpRenameRewriterLanguageService.cs (2)
198(node is AttributeSyntax || 1202var attributeSyntax = token.GetAncestor<AttributeSyntax>();
Simplification\CSharpSimplificationService.cs (1)
56if (node is AttributeSyntax or
Simplification\CSharpSimplificationService.Expander.cs (1)
587if (originalSimpleName.GetAncestor<AttributeSyntax>() != null)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\AttributeArgumentSyntaxExtensions.cs (1)
36if (argumentList.Parent is not AttributeSyntax invocableExpression)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SemanticModelExtensions.cs (1)
139case AttributeSyntax attribute:
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpSyntaxFacts.cs (2)
1588var attribute = (AttributeSyntax)node;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\SpeculationAnalyzer.cs (2)
32AttributeSyntax, 146semanticModel.TryGetSpeculativeSemanticModel(position, (AttributeSyntax)nodeToSpeculate, out speculativeModel);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\AttributeGenerator.cs (3)
51var attributeSyntax = TryGenerateAttribute(attribute, info); 61private static AttributeSyntax? TryGenerateAttribute(AttributeData attribute, CSharpCodeGenerationContextInfo info) 68var reusableSyntax = GetReuseableSyntaxNodeForAttribute<AttributeSyntax>(attribute, info);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpTypeInferenceService.TypeInferrer.cs (4)
146AttributeSyntax _ => InferTypeInAttribute(), 375if (argument.Parent.Parent is AttributeSyntax attribute) 531if (attributeArgumentList.Parent is AttributeSyntax attribute) 540private IEnumerable<TypeInferenceInfo> InferTypeInAttribute(AttributeSyntax attribute, int index, AttributeArgumentSyntax argumentOpt = null)
Microsoft.DotNet.GenFacades (1)
TypeParser.cs (1)
43foreach (var item in attribute.Attributes)
Microsoft.Extensions.Logging.Generators (2)
LoggerMessageGenerator.Parser.cs (1)
110foreach (AttributeSyntax ma in mal.Attributes)
LoggerMessageGenerator.Roslyn3.11.cs (1)
73foreach (AttributeSyntax attributeSyntax in attributeListSyntax.Attributes)
Microsoft.Gen.ComplianceReports (4)
src\Generators\Shared\GeneratorUtilities.cs (4)
90var attr = (AttributeSyntax)node; 107var attributeSyntax = (AttributeSyntax)context.Node;
Microsoft.Gen.ContextualOptions (4)
src\Generators\Shared\GeneratorUtilities.cs (4)
90var attr = (AttributeSyntax)node; 107var attributeSyntax = (AttributeSyntax)context.Node;
Microsoft.Gen.Logging (5)
Parsing\Parser.cs (1)
607foreach (var methodAttr in mal.Attributes)
src\Generators\Shared\GeneratorUtilities.cs (4)
90var attr = (AttributeSyntax)node; 107var attributeSyntax = (AttributeSyntax)context.Node;
Microsoft.Gen.Metrics (5)
Parser.cs (1)
324attribute.ApplicationSyntaxReference.GetSyntax(_cancellationToken) is AttributeSyntax syntax &&
src\Generators\Shared\GeneratorUtilities.cs (4)
90var attr = (AttributeSyntax)node; 107var attributeSyntax = (AttributeSyntax)context.Node;
Microsoft.Gen.MetricsReports (5)
src\Generators\Microsoft.Gen.Metrics\Parser.cs (1)
324attribute.ApplicationSyntaxReference.GetSyntax(_cancellationToken) is AttributeSyntax syntax &&
src\Generators\Shared\GeneratorUtilities.cs (4)
90var attr = (AttributeSyntax)node; 107var attributeSyntax = (AttributeSyntax)context.Node;
Microsoft.Interop.ComInterfaceGenerator (4)
AttributeInfo.cs (1)
17internal AttributeSyntax GenerateSyntax()
ComClassGenerator.cs (1)
64private static readonly AttributeSyntax s_comExposedClassAttributeTemplate =
ComInterfaceGenerator.cs (1)
215private static readonly AttributeSyntax s_iUnknownDerivedAttributeTemplate =
VirtualMethodPointerStubGenerator.cs (1)
151AttributeSyntax unmanagedCallersOnlyAttribute = Attribute(
Microsoft.Interop.JavaScript.JSImportGenerator (1)
JSExportGenerator.cs (1)
254SeparatedList<AttributeSyntax>(
Microsoft.Interop.LibraryImportGenerator (13)
Analyzers\ConvertToLibraryImportFixer.cs (5)
216var dllImportSyntax = (AttributeSyntax)await dllImportAttr!.ApplicationSyntaxReference!.GetSyntaxAsync(cancellationToken).ConfigureAwait(false); 414AttributeSyntax dllImportSyntax, 549return SortDllImportAttributeArguments((AttributeSyntax)libraryImportSyntax, generator); 552private static SyntaxNode SortDllImportAttributeArguments(AttributeSyntax attribute, SyntaxGenerator generator)
LibraryImportGenerator.cs (8)
28SequenceEqualImmutableArray<AttributeSyntax> ForwardedAttributes, 112private static List<AttributeSyntax> GenerateSyntaxForForwardedAttributes(AttributeData? suppressGCTransitionAttribute, AttributeData? unmanagedCallConvAttribute, AttributeData? defaultDllImportSearchPathsAttribute) 116List<AttributeSyntax> attributes = new(); 124AttributeSyntax unmanagedCallConvSyntax = Attribute(NameSyntaxes.UnmanagedCallConvAttribute); 302List<AttributeSyntax> additionalAttributes = GenerateSyntaxForForwardedAttributes(suppressGCTransitionAttribute, unmanagedCallConvAttribute, defaultDllImportSearchPathsAttribute); 308new SequenceEqualImmutableArray<AttributeSyntax>(additionalAttributes.ToImmutableArray(), SyntaxEquivalentComparer.Instance), 348ImmutableArray<AttributeSyntax> forwardedAttributes = pinvokeStub.ForwardedAttributes.Array; 470private static AttributeSyntax CreateForwarderDllImport(LibraryImportData target)
Microsoft.Interop.LibraryImportGenerator.Downlevel (7)
DownlevelLibraryImportGenerator.cs (7)
28SequenceEqualImmutableArray<AttributeSyntax> ForwardedAttributes, 88private static List<AttributeSyntax> GenerateSyntaxForForwardedAttributes(AttributeData? defaultDllImportSearchPathsAttribute) 91List<AttributeSyntax> attributes = []; 218List<AttributeSyntax> additionalAttributes = GenerateSyntaxForForwardedAttributes(defaultDllImportSearchPathsAttribute); 224new SequenceEqualImmutableArray<AttributeSyntax>(additionalAttributes.ToImmutableArray(), SyntaxEquivalentComparer.Instance), 253ImmutableArray<AttributeSyntax> forwardedAttributes = pinvokeStub.ForwardedAttributes.Array; 355private static AttributeSyntax CreateForwarderDllImport(LibraryImportData target)
Microsoft.Interop.SourceGeneration (8)
MarshalAsParser.cs (4)
27private protected abstract bool TryCreateAttributeSyntax([NotNullWhen(true)] out AttributeSyntax? attribute); 29bool IForwardedMarshallingInfo.TryCreateAttributeSyntax([NotNullWhen(true)] out AttributeSyntax? attribute) => TryCreateAttributeSyntax(out attribute); 36private protected override bool TryCreateAttributeSyntax([NotNullWhen(true)] out AttributeSyntax? attribute) 65private protected override bool TryCreateAttributeSyntax([NotNullWhen(true)] out AttributeSyntax? attribute)
Marshalling\IForwardedMarshallingInfo.cs (1)
11bool TryCreateAttributeSyntax([NotNullWhen(true)] out AttributeSyntax? attribute);
Marshalling\MarshallingGeneratorExtensions.cs (3)
44&& forwarded.TryCreateAttributeSyntax(out AttributeSyntax forwardedAttribute)) 110List<AttributeSyntax> rehydratedAttributes = new(); 112&& forwardedMarshallingInfo.TryCreateAttributeSyntax(out AttributeSyntax forwardedAttribute))
Microsoft.VisualStudio.LanguageServices.CSharp (42)
CodeModel\CSharpCodeModelService.CodeModelEventCollector.cs (10)
74AttributeSyntax oldAttribute, 75AttributeSyntax newAttribute, 868foreach (var attribute in attributeList.Attributes) 873else if (node is AttributeSyntax attribute) 904foreach (var attribute in attributeList.Attributes) 909else if (node is AttributeSyntax attribute) 919private static void ChangeEventQueueForAttributes(AttributeSyntax attribute, SyntaxNode parent, CodeModelEventType eventType, CodeModelEventQueue eventQueue) 955foreach (var attribute in attributeList.Attributes) 960else if (node is AttributeSyntax attribute) 970private static void AddEventToEventQueueForAttributes(AttributeSyntax attribute, SyntaxNode parent, Action<SyntaxNode, SyntaxNode> enqueueAddOrRemoveEvent)
CodeModel\CSharpCodeModelService.cs (28)
294foreach (var attribute in attributeDeclaration.Attributes) 350if (parent is AttributeSyntax attribute) 776=> node is AttributeSyntax; 843return ((AttributeSyntax)node).Name.ToString(); 914return ((AttributeSyntax)node).WithName( 961var symbol = node is AttributeSyntax 1585foreach (AttributeSyntax attribute in GetAttributeNodes(parentNode)) 1604Debug.Assert(attributeNode is AttributeSyntax); 1606var attribute = (AttributeSyntax)attributeNode; 1638Debug.Assert(attributeNode is AttributeSyntax); 1640name = ((AttributeSyntax)attributeNode).Name.ToString(); 1643foreach (AttributeSyntax attribute in GetAttributeNodes(parentNode)) 1662var attribute = (AttributeSyntax)argument.Ancestors().First(n => n.Kind() == SyntaxKind.Attribute); 1670Debug.Assert(attributeNode is AttributeSyntax); 1678Debug.Assert(attributeNode is AttributeSyntax); 1709Debug.Assert(attributeNode is AttributeSyntax); 1711var attribute = (AttributeSyntax)attributeNode; 1723Debug.Assert(attributeNode is AttributeSyntax); 1725var attribute = (AttributeSyntax)attributeNode; 2788private static Document Delete(Document document, AttributeSyntax node) 2887SyntaxKind.Attribute => Delete(document, (AttributeSyntax)node), 3077var attribute = (AttributeSyntax)attributes[index]; 3321if (container is AttributeSyntax attribute)
CodeModel\CSharpCodeModelService.NodeLocator.cs (4)
40return GetStartPoint(text, (AttributeSyntax)node, part); 91return GetEndPoint(text, (AttributeSyntax)node, part); 242private static VirtualTreePoint GetStartPoint(SourceText text, AttributeSyntax node, EnvDTE.vsCMPart part) 817private static VirtualTreePoint GetEndPoint(SourceText text, AttributeSyntax node, EnvDTE.vsCMPart part)
System.Text.Json.SourceGeneration (1)
JsonSourceGenerator.Roslyn3.11.cs (1)
119foreach (AttributeSyntax attributeSyntax in attributeListSyntax.Attributes)
System.Windows.Forms.Analyzers.CodeFixes.CSharp (1)
System\Windows\Forms\CSharp\CodeFixes\AddDesignerSerializationVisibility\AddDesignerSerializationVisibilityCodeFixProvider.cs (1)
81AttributeSyntax designerSerializationVisibilityAttribute = SyntaxFactory.Attribute(