514 references to AttributeSyntax
Microsoft.CodeAnalysis.CSharp (201)
Binder\Binder_Attributes.cs (16)
30ImmutableArray<Binder> binders, ImmutableArray<AttributeSyntax> attributesToBind, Symbol ownerSymbol, NamedTypeSymbol[] boundAttributeTypes, 31Action<AttributeSyntax>? beforeAttributePartBound, 32Action<AttributeSyntax>? afterAttributePartBound, 47AttributeSyntax attributeToBind = attributesToBind[i]; 74ImmutableArray<AttributeSyntax> attributesToBind, 78Action<AttributeSyntax>? beforeAttributePartBound, 79Action<AttributeSyntax>? afterAttributePartBound, 91AttributeSyntax attributeSyntax = attributesToBind[i]; 128AttributeSyntax node, NamedTypeSymbol boundAttributeType, 129Action<AttributeSyntax>? beforeAttributePartBound, 130Action<AttributeSyntax>? afterAttributePartBound, 139internal BoundAttribute BindAttribute(AttributeSyntax node, NamedTypeSymbol attributeType, Symbol? attributedMember, BindingDiagnosticBag diagnostics) 156private BoundAttribute BindAttributeCore(AttributeSyntax node, NamedTypeSymbol attributeType, Symbol? attributedMember, BindingDiagnosticBag diagnostics) 291ValidateTypeForAttributeParameters(attributeConstructor.Parameters, ((AttributeSyntax)boundAttribute.Syntax).Name, diagnostics, ref hasErrors); 313(AttributeSyntax)boundAttribute.Syntax, 685AttributeSyntax syntax,
Binder\Binder_Expressions.cs (1)
5292AttributeSyntax { Name: { } name } => name.Location,
Binder\Binder_Symbols.cs (1)
1000case 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)
176public override void VisitAttribute(AttributeSyntax node)
Binder\LocalBinderFactory.cs (1)
437public 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)) 2753public bool TryGetSpeculativeSemanticModel(int position, AttributeSyntax attribute, out SemanticModel speculativeModel) 3964parentSyntax.Kind() == SyntaxKind.Attribute && ((AttributeSyntax)parentSyntax).Name == boundNode.Syntax) 4937case AttributeSyntax attribute: 4962case AttributeSyntax attribute: 4983case AttributeSyntax attribute: 5006case AttributeSyntax attribute:
Compilation\PublicSemanticModel.cs (1)
17protected AttributeSemanticModel CreateModelForAttribute(Binder enclosingBinder, AttributeSyntax attribute, MemberSemanticModel containingModel)
Compilation\SpeculativeSemanticModelWithMemberModel.cs (4)
43AttributeSyntax syntax, 160case AttributeSyntax attribute: 174private MemberSemanticModel GetOrAddModelForAttribute(MemberSemanticModel containing, AttributeSyntax attribute) 177(node, binderAndModel) => CreateModelForAttribute(binderAndModel.binder, (AttributeSyntax)node, binderAndModel.model),
Compilation\SyntaxTreeSemanticModel.cs (5)
756internal PublicSemanticModel CreateSpeculativeAttributeSemanticModel(int position, AttributeSyntax attribute, Binder binder, AliasSymbol aliasOpt, NamedTypeSymbol attributeType) 949return GetOrAddModelForAttribute((AttributeSyntax)memberDecl); 971private MemberSemanticModel GetOrAddModelForAttribute(AttributeSyntax attribute) 981(node, binderAndModel) => CreateModelForAttribute(binderAndModel.binder, (AttributeSyntax)node, binderAndModel.model), 1232return CreateModelForAttribute(defaultOuter(), (AttributeSyntax)node, containingModel: null);
CSharpDeclarationComputer.cs (1)
338foreach (var attribute in attributeList.Attributes)
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)) 930public static ImmutableArray<ISymbol> GetMemberGroup(this SemanticModel? semanticModel, AttributeSyntax attribute, CancellationToken cancellationToken = default(CancellationToken)) 1264public static bool TryGetSpeculativeSemanticModel([NotNullWhen(true)] this SemanticModel? semanticModel, int position, AttributeSyntax attribute, [NotNullWhen(true)] out SemanticModel? speculativeModel)
Declarations\DeclarationTreeBuilder.cs (1)
780foreach (var attribute in attributeList.Attributes)
Errors\MessageProvider.cs (14)
268var node = (AttributeSyntax)attributeSyntax; 275var node = (AttributeSyntax)attributeSyntax; 281var node = (AttributeSyntax)attributeSyntax; 287var node = (AttributeSyntax)attributeSyntax; 294var node = (AttributeSyntax)attributeSyntax; 301var node = (AttributeSyntax)attributeSyntax; 307var node = (AttributeSyntax)attributeSyntax;
SourceGeneration\CSharpSyntaxHelper.cs (2)
34=> node is AttributeSyntax; 37=> ((AttributeSyntax)node).Name;
Symbols\Attributes\AttributeData.cs (15)
112internal static bool IsTargetEarlyAttribute(NamedTypeSymbol attributeType, AttributeSyntax attributeSyntax, AttributeDescription description) 235internal void DecodeSecurityAttribute<T>(Symbol targetSymbol, CSharpCompilation compilation, ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 261internal static void DecodeSkipLocalsInitAttribute<T>(CSharpCompilation compilation, ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 272internal static void DecodeMemberNotNullAttribute<T>(TypeSymbol type, ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 308private static void ReportBadNotNullMemberIfNeeded(TypeSymbol type, DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments, string memberName) 322internal static void DecodeMemberNotNullWhenAttribute<T>(TypeSymbol type, ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 359private DeclarativeSecurityAction DecodeSecurityAttributeAction(Symbol targetSymbol, CSharpCompilation compilation, AttributeSyntax? nodeOpt, out bool hasErrors, BindingDiagnosticBag diagnostics) 402private DeclarativeSecurityAction DecodeSecurityAction(TypedConstant typedValue, Symbol targetSymbol, AttributeSyntax? nodeOpt, BindingDiagnosticBag diagnostics, out bool hasErrors) 490private static Location GetSecurityAttributeActionSyntaxLocation(AttributeSyntax? nodeOpt, TypedConstant typedValue, out object displayString) 528private string? DecodePermissionSetAttribute(CSharpCompilation compilation, AttributeSyntax? nodeOpt, BindingDiagnosticBag diagnostics) 592internal void DecodeClassInterfaceAttribute(AttributeSyntax? nodeOpt, BindingDiagnosticBag diagnostics) 618internal void DecodeInterfaceTypeAttribute(AttributeSyntax node, BindingDiagnosticBag diagnostics) 645internal string DecodeGuidAttribute(AttributeSyntax? nodeOpt, BindingDiagnosticBag diagnostics) 825internal static CSharpSyntaxNode GetAttributeArgumentSyntax(this AttributeData attribute, int parameterIndex, AttributeSyntax attributeSyntax) 837internal static Location GetAttributeArgumentSyntaxLocation(this AttributeData attribute, int parameterIndex, AttributeSyntax? attributeSyntaxOpt)
Symbols\Attributes\SourceAttributeData.cs (1)
106internal CSharpSyntaxNode GetAttributeArgumentSyntax(int parameterIndex, AttributeSyntax attributeSyntax)
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) 204MarshalAsAttributeDecoder<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)
1321var arguments = new DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation>(); 1660Func<AttributeSyntax, bool> attributeMatches = attribute switch 1672bool isPossibleAssemblySignatureKeyAttribute(AttributeSyntax node) 1678bool isPossibleAssemblyKeyNameAttribute(AttributeSyntax node) 1684bool isPossibleAssemblyKeyFileAttribute(AttributeSyntax node) 1694private static PooledHashSet<AttributeSyntax> t_forwardedTypesAttributesInProgress; 1712t_forwardedTypesAttributesInProgress = PooledHashSet<AttributeSyntax>.GetInstance(); 1738private static void BeforePossibleForwardedTypesAttributePartBound(AttributeSyntax node) 1744private static void AfterPossibleForwardedTypesAttributePartBound(AttributeSyntax node) 1750private bool IsPossibleForwardedTypesAttribute(AttributeSyntax node) 2171private static Location GetAssemblyAttributeLocationForDiagnostic(AttributeSyntax attributeSyntaxOpt) 2176private void DecodeTypeForwardedToAttribute(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 2243AttributeSyntax nodeOpt, 2332protected override void DecodeWellKnownAttributeImpl(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 2337private void DecodeWellKnownAttribute(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments, int index, bool isFromNetModule) 2549private static void ValidateIntegralAttributeNonNegativeArguments(CSharpAttributeData attribute, AttributeSyntax nodeOpt, BindingDiagnosticBag diagnostics)
Symbols\Source\SourceComplexParameterSymbol.cs (20)
610internal override void EarlyDecodeWellKnownAttributeType(NamedTypeSymbol attributeType, AttributeSyntax attributeSyntax) 633internal override (CSharpAttributeData?, BoundAttribute?) EarlyDecodeWellKnownAttribute(ref EarlyDecodeWellKnownAttributeArguments<EarlyWellKnownAttributeBinder, NamedTypeSymbol, AttributeSyntax, AttributeLocation> arguments) 697private (CSharpAttributeData?, BoundAttribute?) EarlyDecodeAttributeForDefaultParameterValue(AttributeDescription description, ref EarlyDecodeWellKnownAttributeArguments<EarlyWellKnownAttributeBinder, NamedTypeSymbol, AttributeSyntax, AttributeLocation> arguments) 726protected override void DecodeWellKnownAttributeImpl(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 776MarshalAsAttributeDecoder<ParameterWellKnownAttributeData, AttributeSyntax, CSharpAttributeData, AttributeLocation>.Decode(ref arguments, AttributeTargets.Parameter, MessageProvider.Instance); 880private void DecodeDefaultParameterValueAttribute(AttributeDescription description, ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 883var syntax = arguments.AttributeSyntaxOpt; 916private ConstantValue DecodeDefaultParameterValueAttribute(AttributeDescription description, CSharpAttributeData attribute, AttributeSyntax node, bool diagnose, BindingDiagnosticBag diagnosticsOpt) 935private ConstantValue DecodeDefaultParameterValueAttribute(CSharpAttributeData attribute, AttributeSyntax node, bool diagnose, BindingDiagnosticBag diagnosticsOpt) 1016private bool IsValidCallerInfoContext(AttributeSyntax node) => !ContainingSymbol.IsExplicitInterfaceImplementation() 1027private bool IsOnPartialImplementation(AttributeSyntax node) 1048private void ValidateCallerLineNumberAttribute(AttributeSyntax node, BindingDiagnosticBag diagnostics) 1076private void ValidateCallerFilePathAttribute(AttributeSyntax node, BindingDiagnosticBag diagnostics) 1109private void ValidateCallerMemberNameAttribute(AttributeSyntax node, BindingDiagnosticBag diagnostics) 1147private void ValidateCallerArgumentExpressionAttribute(AttributeSyntax node, CSharpAttributeData attribute, BindingDiagnosticBag diagnostics) 1204private void ValidateCancellationTokenAttribute(AttributeSyntax node, BindingDiagnosticBag diagnostics) 1230private void DecodeInterpolatedStringHandlerArgumentAttribute(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments, BindingDiagnosticBag diagnostics, int attributeIndex) 1315(int Ordinal, ParameterSymbol? Parameter)? decodeName(TypedConstant constant, ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 1372static void setInterpolatedStringHandlerAttributeError(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 1379internal override void PostDecodeWellKnownAttributes(ImmutableArray<CSharpAttributeData> boundAttributes, ImmutableArray<AttributeSyntax> allAttributeSyntaxNodes, BindingDiagnosticBag diagnostics, AttributeLocation symbolPart, WellKnownAttributeData decodedData)
Symbols\Source\SourceConstructorSymbolBase.cs (1)
255internal sealed override (CSharpAttributeData?, BoundAttribute?) EarlyDecodeWellKnownAttribute(ref EarlyDecodeWellKnownAttributeArguments<EarlyWellKnownAttributeBinder, NamedTypeSymbol, AttributeSyntax, AttributeLocation> arguments)
Symbols\Source\SourceEventSymbol.cs (2)
245internal override (CSharpAttributeData?, BoundAttribute?) EarlyDecodeWellKnownAttribute(ref EarlyDecodeWellKnownAttributeArguments<EarlyWellKnownAttributeBinder, NamedTypeSymbol, AttributeSyntax, AttributeLocation> arguments) 288protected sealed override void DecodeWellKnownAttributeImpl(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments)
Symbols\Source\SourceFieldSymbol.cs (1)
113protected 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 (12)
323internal override (CSharpAttributeData?, BoundAttribute?) EarlyDecodeWellKnownAttribute(ref EarlyDecodeWellKnownAttributeArguments<EarlyWellKnownAttributeBinder, NamedTypeSymbol, AttributeSyntax, AttributeLocation> arguments) 479protected sealed override void DecodeWellKnownAttributeImpl(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 494private void DecodeWellKnownAttributeAppliedToMethod(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 508AttributeData.DecodeMethodImplAttribute<MethodWellKnownAttributeData, AttributeSyntax, CSharpAttributeData, AttributeLocation>(ref arguments, MessageProvider.Instance); 627ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments, 654private void ValidateConditionalAttribute(CSharpAttributeData attribute, AttributeSyntax node, BindingDiagnosticBag diagnostics) 719private void DecodeWellKnownAttributeAppliedToReturnValue(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 730MarshalAsAttributeDecoder<ReturnTypeWellKnownAttributeData, AttributeSyntax, CSharpAttributeData, AttributeLocation>.Decode(ref arguments, AttributeTargets.ReturnValue, MessageProvider.Instance); 757private void DecodeDllImportAttribute(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 883private void DecodeModuleInitializerAttribute(DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 932private void DecodeUnmanagedCallersOnlyAttribute(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 1018internal sealed override void PostDecodeWellKnownAttributes(ImmutableArray<CSharpAttributeData> boundAttributes, ImmutableArray<AttributeSyntax> allAttributeSyntaxNodes, BindingDiagnosticBag diagnostics, AttributeLocation symbolPart, WellKnownAttributeData decodedData)
Symbols\Source\SourceModuleSymbol.cs (1)
505protected override void DecodeWellKnownAttributeImpl(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments)
Symbols\Source\SourceNamedTypeSymbol.cs (8)
900internal override (CSharpAttributeData?, BoundAttribute?) EarlyDecodeWellKnownAttribute(ref EarlyDecodeWellKnownAttributeArguments<EarlyWellKnownAttributeBinder, NamedTypeSymbol, AttributeSyntax, AttributeLocation> arguments) 1054protected sealed override void DecodeWellKnownAttributeImpl(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 1097AttributeData.DecodeStructLayoutAttribute<TypeWellKnownAttributeData, AttributeSyntax, CSharpAttributeData, AttributeLocation>( 1196foreach (AttributeSyntax attr in attrList.Attributes) 1212private AttributeUsageInfo DecodeAttributeUsageAttribute(CSharpAttributeData attribute, AttributeSyntax node, bool diagnose, BindingDiagnosticBag diagnosticsOpt = null) 1250private void DecodeCoClassAttribute(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 1286private void ValidateConditionalAttribute(CSharpAttributeData attribute, AttributeSyntax node, BindingDiagnosticBag diagnostics) 1463internal override void PostDecodeWellKnownAttributes(ImmutableArray<CSharpAttributeData> boundAttributes, ImmutableArray<AttributeSyntax> allAttributeSyntaxNodes, BindingDiagnosticBag diagnostics, AttributeLocation symbolPart, WellKnownAttributeData decodedData)
Symbols\Source\SourcePropertySymbolBase.cs (4)
1172internal override (CSharpAttributeData?, BoundAttribute?) EarlyDecodeWellKnownAttribute(ref EarlyDecodeWellKnownAttributeArguments<EarlyWellKnownAttributeBinder, NamedTypeSymbol, AttributeSyntax, AttributeLocation> arguments) 1236protected override void DecodeWellKnownAttributeImpl(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 1394internal override void PostDecodeWellKnownAttributes(ImmutableArray<CSharpAttributeData> boundAttributes, ImmutableArray<AttributeSyntax> allAttributeSyntaxNodes, BindingDiagnosticBag diagnostics, AttributeLocation symbolPart, WellKnownAttributeData decodedData) 1406private void ValidateIndexerNameAttribute(CSharpAttributeData attribute, AttributeSyntax node, BindingDiagnosticBag diagnostics)
Symbols\Source\SourceTypeParameterSymbol.cs (1)
421protected sealed override void DecodeWellKnownAttributeImpl(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments)
Symbols\Symbol.cs (2)
1384internal bool ReportExplicitUseOfReservedAttributes(in DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments, ReservedAttributes reserved) 1458bool reportExplicitUseOfReservedAttribute(CSharpAttributeData attribute, in DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments, in AttributeDescription attributeDescription)
Symbols\Symbol_Attributes.cs (26)
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, 154var syntax = arguments.AttributeSyntax; 214protected void DecodeWellKnownAttribute(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 229protected virtual void DecodeWellKnownAttributeImpl(ref DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation> arguments) 251internal virtual void PostDecodeWellKnownAttributes(ImmutableArray<CSharpAttributeData> boundAttributes, ImmutableArray<AttributeSyntax> allAttributeSyntaxNodes, BindingDiagnosticBag diagnostics, AttributeLocation symbolPart, WellKnownAttributeData decodedData) 296Func<AttributeSyntax, bool>? attributeMatchesOpt = null, 297Action<AttributeSyntax>? beforeAttributePartBound = null, 298Action<AttributeSyntax>? afterAttributePartBound = null) 305ImmutableArray<AttributeSyntax> attributesToBind = this.GetAttributesToBind(attributesSyntaxLists, symbolPart, diagnostics, compilation, attributeMatchesOpt, binderOpt, out binders); 427void removeObsoleteDiagnosticsForForwardedTypes(ImmutableArray<CSharpAttributeData> boundAttributes, ImmutableArray<AttributeSyntax> attributesToBind, ref BindingDiagnosticBag diagnostics) 533foreach (var attributeSyntax in attributeListSyntax.Attributes) 569private ImmutableArray<AttributeSyntax> GetAttributesToBind( 574Func<AttributeSyntax, bool> attributeMatchesOpt, 580ArrayBuilder<AttributeSyntax> syntaxBuilder = null; 597syntaxBuilder = new ArrayBuilder<AttributeSyntax>(); 609foreach (var attribute in attributesToBind) 643return ImmutableArray<AttributeSyntax>.Empty; 747ImmutableArray<AttributeSyntax> attributesToBind, 759var arguments = new EarlyDecodeWellKnownAttributeArguments<EarlyWellKnownAttributeBinder, NamedTypeSymbol, AttributeSyntax, AttributeLocation>(); 793private void EarlyDecodeWellKnownAttributeTypes(ImmutableArray<NamedTypeSymbol> attributeTypes, ImmutableArray<AttributeSyntax> attributeSyntaxList) 818ImmutableArray<AttributeSyntax> attributeSyntaxList, 831var arguments = new DecodeWellKnownAttributeArguments<AttributeSyntax, CSharpAttributeData, AttributeLocation>(); 839AttributeSyntax attributeSyntax = attributeSyntaxList[i]; 867AttributeSyntax node,
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 (11)
AttributeArgumentSyntaxExtensions.cs (1)
36if (argumentList.Parent is not AttributeSyntax invocableExpression)
CSharpQualifyMemberAccessDiagnosticAnalyzer.cs (1)
32if (node.GetAncestorOrThis<AttributeSyntax>() != null)
CSharpRemoveUnnecessaryAttributeSuppressionsDiagnosticAnalyzer.cs (1)
23foreach (var attribute in attributeList.Attributes)
CSharpSyntaxFacts.cs (1)
616=> ((AttributeSyntax)node).Name;
CSharpUseNameofInNullableAttributeDiagnosticAnalyzer.cs (3)
55var attribute = (AttributeSyntax)context.Node; 113private static bool MatchesParameterOnContainer(AttributeSyntax attribute, string stringValue)
SemanticModelExtensions.cs (1)
139case AttributeSyntax attribute:
SpeculationAnalyzer.cs (2)
32AttributeSyntax, 150semanticModel.TryGetSpeculativeSemanticModel(position, (AttributeSyntax)nodeToSpeculate, out speculativeModel);
UseUtf8StringLiteralDiagnosticAnalyzer.cs (1)
82if (arrayCreationOperation.Syntax.Ancestors().OfType<AttributeSyntax>().Any())
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (12)
AttributeArgumentFixer.cs (3)
15private class AttributeArgumentFixer : Fixer<AttributeArgumentSyntax, AttributeArgumentListSyntax, AttributeSyntax> 31var newAttribute = (AttributeSyntax)newArgumentList.Parent!;
AttributeGenerator.cs (4)
52var attributeSyntax = TryGenerateAttribute(attribute, info); 62private static AttributeSyntax? TryGenerateAttribute(AttributeData attribute, CSharpCodeGenerationContextInfo info) 69var reusableSyntax = GetReuseableSyntaxNodeForAttribute<AttributeSyntax>(attribute, info);
CSharpAddExplicitCastCodeFixProvider.cs (1)
89&& attributeArgumentList.Parent is AttributeSyntax attributeNode)
CSharpTypeInferenceService.TypeInferrer.cs (4)
148AttributeSyntax _ => InferTypeInAttribute(), 381if (argument.Parent.Parent is AttributeSyntax attribute) 543if (attributeArgumentList.Parent is AttributeSyntax attribute) 552private IEnumerable<TypeInferenceInfo> InferTypeInAttribute(AttributeSyntax attribute, int index, AttributeArgumentSyntax argumentOpt = null)
Microsoft.CodeAnalysis.CSharp.Emit2.UnitTests (45)
Attributes\AttributeTests.cs (45)
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")); 591var attributeSyntax = (AttributeSyntax)attributeData.ApplicationSyntaxReference.GetSyntax(); 623var attributeSyntax = (AttributeSyntax)attributeData.ApplicationSyntaxReference.GetSyntax(); 708var attrSyntax = root.DescendantNodes().OfType<AttributeSyntax>().Last(); 749var attrSyntax = root.DescendantNodes().OfType<AttributeSyntax>().Last(); 753var newAttrSyntax = newRoot.DescendantNodes().OfType<AttributeSyntax>().Last(); 813var attrSyntax = root.DescendantNodes().OfType<AttributeSyntax>().Last(); 818var newAttrSyntax = newRoot.DescendantNodes().OfType<AttributeSyntax>().Last(); 855var attrSyntax = root.DescendantNodes().OfType<AttributeSyntax>().Last(); 859var newAttrSyntax = newRoot.DescendantNodes().OfType<AttributeSyntax>().Last(); 896var attrSyntax = root.DescendantNodes().OfType<AttributeSyntax>().Last(); 900var newAttrSyntax = newRoot.DescendantNodes().OfType<AttributeSyntax>().Last(); 935var attrSyntax = root.DescendantNodes().OfType<AttributeSyntax>().First(); 939var newAttrSyntax = newRoot.DescendantNodes().OfType<AttributeSyntax>().First(); 1106var attributeSyntax = (AttributeSyntax)attributeData.ApplicationSyntaxReference.GetSyntax(); 1147var attributeSyntax = comp.SyntaxTrees[0].GetRoot().DescendantNodes().OfType<AttributeSyntax>().First(); 1187var attributeSyntax = (AttributeSyntax)attributeData.ApplicationSyntaxReference.GetSyntax(); 1227var attributeSyntax = (AttributeSyntax)attributeData.ApplicationSyntaxReference.GetSyntax(); 1266var attributeSyntax = (AttributeSyntax)attributeData.ApplicationSyntaxReference.GetSyntax(); 3086var syntax = (AttributeSyntax)attrs[0].ApplicationSyntaxReference.GetSyntax(); 3088syntax = (AttributeSyntax)attrs[1].ApplicationSyntaxReference.GetSyntax(); 3383Assert.IsType<AttributeSyntax>(syntax);
Microsoft.CodeAnalysis.CSharp.Features (37)
AttributeArgumentFixer.cs (3)
15private class AttributeArgumentFixer : Fixer<AttributeArgumentSyntax, AttributeArgumentListSyntax, AttributeSyntax> 31var newAttribute = (AttributeSyntax)newArgumentList.Parent!;
ChangeSignature\CSharpChangeSignatureService.cs (3)
477if (updatedNode is AttributeSyntax attribute) 479var symbolInfo = semanticModel.GetSymbolInfo((AttributeSyntax)originalNode, cancellationToken); 582if (node is AttributeSyntax attribute)
CodeFixes\Suppression\CSharpSuppressionCodeFixProvider.cs (2)
158var attributes = new SeparatedSyntaxList<AttributeSyntax>() 212if (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)
33context.LeftToken.GetAncestor<AttributeSyntax>() != null;
CSharpAddExplicitCastCodeFixProvider.cs (1)
89&& attributeArgumentList.Parent is AttributeSyntax attributeNode)
CSharpDeclarationComputer.cs (1)
338foreach (var attribute in attributeList.Attributes)
CSharpQualifyMemberAccessDiagnosticAnalyzer.cs (1)
32if (node.GetAncestorOrThis<AttributeSyntax>() != null)
CSharpRemoveUnnecessaryAttributeSuppressionsDiagnosticAnalyzer.cs (1)
23foreach (var attribute in attributeList.Attributes)
CSharpUseNameofInNullableAttributeDiagnosticAnalyzer.cs (3)
55var attribute = (AttributeSyntax)context.Node; 113private static bool MatchesParameterOnContainer(AttributeSyntax attribute, string stringValue)
EditAndContinue\SyntaxComparer.cs (3)
908distance = ComputeDistance((AttributeSyntax)leftNode, (AttributeSyntax)rightNode); 1490return ((AttributeSyntax)node).Name;
GenerateConstructor\CSharpGenerateConstructorService.cs (1)
126if (fullName.Parent is AttributeSyntax attribute)
GenerateConstructor\GenerateConstructorCodeFixProvider.cs (2)
59AttributeSyntax; 68case AttributeSyntax attributeNode:
MetadataAsSource\CSharpMetadataAsSourceService.cs (1)
134return annotatedChildren.Any(n => n.GetAncestorOrThis<AttributeSyntax>() == null);
QuickInfo\CSharpDiagnosticAnalyzerQuickInfoProvider.cs (1)
110Parent: AttributeSyntax
SignatureHelp\AttributeSignatureHelpProvider.cs (6)
46[NotNullWhen(true)] out AttributeSyntax? attribute) 63token.Parent.Parent is AttributeSyntax; 66private static bool IsArgumentListToken(AttributeSyntax expression, SyntaxToken token) 76if (!TryGetAttributeExpression(root, position, document.GetRequiredLanguageService<ISyntaxFactsService>(), triggerInfo.TriggerReason, cancellationToken, out var attribute)) 118if (TryGetAttributeExpression(root, position, syntaxFacts, SignatureHelpTriggerReason.InvokeSignatureHelpCommand, cancellationToken, out var expression) && 130AttributeSyntax attribute,
UseUtf8StringLiteralDiagnosticAnalyzer.cs (1)
82if (arrayCreationOperation.Syntax.Ancestors().OfType<AttributeSyntax>().Any())
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 (42)
Semantics\LambdaTests.cs (4)
3921var attributeSyntaxes = tree.GetRoot().DescendantNodes().OfType<AttributeSyntax>().ToImmutableArray(); 3928void verify(AttributeSyntax attributeSyntax, string expectedAttributeName) 3961var a = (IdentifierNameSyntax)tree.GetRoot().DescendantNodes().OfType<AttributeSyntax>().Single().Name; 3974a = (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(); 7266var attr = parseAttributeSyntax("[My(nameof(TParameter))]", parseOptions); 7277static AttributeSyntax parseAttributeSyntax(string source, CSharpParseOptions parseOptions) 7278=> SyntaxFactory.ParseCompilationUnit($@"class X {{ {source} void M() {{ }} }}", options: parseOptions).DescendantNodes().OfType<AttributeSyntax>().Single(); 7281static void VerifyTParameterSpeculation(SemanticModel parentModel, int localFuncPosition, AttributeSyntax attr1, bool found = true) 7418var attr = parseAttributeSyntax("[My(nameof(TParameter))]", TestOptions.Regular10); 7449static AttributeSyntax parseAttributeSyntax(string source, CSharpParseOptions parseOptions) 7450=> SyntaxFactory.ParseCompilationUnit($@"class X {{ {source} void M() {{ }} }}", options: parseOptions).DescendantNodes().OfType<AttributeSyntax>().Single(); 7492var attr = parseAttributeSyntax("[My(nameof(TParameter))]", parseOptions); 7502static AttributeSyntax parseAttributeSyntax(string source, CSharpParseOptions parseOptions) 7503=> SyntaxFactory.ParseCompilationUnit($@"class X {{ {source} void M() {{ }} }}", options: parseOptions).DescendantNodes().OfType<AttributeSyntax>().Single(); 8848var attr = parseAttributeSyntax("[My(nameof(parameter))]", parseOptions); 8858static AttributeSyntax parseAttributeSyntax(string source, CSharpParseOptions parseOptions) 8859=> SyntaxFactory.ParseCompilationUnit($@"class X {{ {source} void M() {{ }} }}", options: parseOptions).DescendantNodes().OfType<AttributeSyntax>().Single(); 8862static void VerifyParameterSpeculation(SemanticModel parentModel, int localFuncPosition, AttributeSyntax attr1, bool found = true) 9356var attr = parseAttributeSyntax("[My(nameof(parameter))]", TestOptions.Regular10); 9366static AttributeSyntax parseAttributeSyntax(string source, CSharpParseOptions parseOptions) 9367=> SyntaxFactory.ParseCompilationUnit($@"class X {{ {source} void M() {{ }} }}", options: parseOptions).DescendantNodes().OfType<AttributeSyntax>().Single(); 9674var attr = parseAttributeSyntax("[My(nameof(parameter))]", TestOptions.Regular10); 9684static AttributeSyntax parseAttributeSyntax(string source, CSharpParseOptions parseOptions) 9685=> 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)
950var invocation = nodes.OfType<AttributeSyntax>().ElementAt(1);
Semantics\OutVarTests.cs (1)
36312Assert.True(model.TryGetSpeculativeSemanticModel(method.Body.SpanStart + 1, method.DescendantNodes().OfType<AttributeSyntax>().Single(), out speculativeModel));
Semantics\PrimaryConstructorTests.cs (2)
6244var attrApplication = tree.GetRoot().DescendantNodes().OfType<AttributeSyntax>().Single();
Semantics\RecordTests.cs (2)
30375var attrApplication = tree.GetRoot().DescendantNodes().OfType<AttributeSyntax>().Single();
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)
4065var speculativeAttribute = SyntaxFactory.Attribute(SyntaxFactory.ParseName("A"), SyntaxFactory.ParseAttributeArgumentList("(o2)")); 4212var attributeUsage = root.DescendantNodes().OfType<AttributeSyntax>().ElementAt(1); 4213var newAttributeUsage = SyntaxFactory.Attribute(SyntaxFactory.ParseName("Attr"), SyntaxFactory.ParseAttributeArgumentList("(Constant)"));
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (6)
Generated\Syntax.Test.xml.Generated.cs (6)
10443=> SyntaxFactory.AttributeList(SyntaxFactory.Token(SyntaxKind.OpenBracketToken), default(AttributeTargetSpecifierSyntax), new SeparatedSyntaxList<AttributeSyntax>(), SyntaxFactory.Token(SyntaxKind.CloseBracketToken)); 10448private static AttributeSyntax GenerateAttribute() 12608var node = GenerateAttribute(); 12612var newNode = node.WithName(node.Name).WithArgumentList(node.ArgumentList); 17753var oldNode = GenerateAttribute(); 17769var oldNode = GenerateAttribute();
Microsoft.CodeAnalysis.CSharp.Test.Utilities (1)
CompilationTestUtils.cs (1)
245else if (node is AttributeSyntax attribute)
Microsoft.CodeAnalysis.CSharp.Workspaces (31)
AttributeArgumentSyntaxExtensions.cs (1)
36if (argumentList.Parent is not AttributeSyntax invocableExpression)
AttributeGenerator.cs (4)
52var attributeSyntax = TryGenerateAttribute(attribute, info); 62private static AttributeSyntax? TryGenerateAttribute(AttributeData attribute, CSharpCodeGenerationContextInfo info) 69var reusableSyntax = GetReuseableSyntaxNodeForAttribute<AttributeSyntax>(attribute, info);
CodeGeneration\CSharpSyntaxGenerator.cs (13)
977if (node is AttributeSyntax attr) 1112var attr = (AttributeSyntax)attributeDeclaration; 1160var attr = (AttributeSyntax)declaration; 1180var attr = (AttributeSyntax)declaration; 1903AttributeSyntax attribute => attribute.Name.ToString(), 1937AttributeSyntax attribute => ReplaceWithTrivia(declaration, attribute.Name, this.DottedName(name)), 2031var attr = (AttributeSyntax)declaration; 3012var attr = (AttributeSyntax)declaration;
CSharpSyntaxFacts.cs (1)
616=> ((AttributeSyntax)node).Name;
CSharpTypeInferenceService.TypeInferrer.cs (4)
148AttributeSyntax _ => InferTypeInAttribute(), 381if (argument.Parent.Parent is AttributeSyntax attribute) 543if (attributeArgumentList.Parent is AttributeSyntax attribute) 552private IEnumerable<TypeInferenceInfo> InferTypeInAttribute(AttributeSyntax attribute, int index, AttributeArgumentSyntax argumentOpt = null)
Rename\CSharpRenameRewriterLanguageService.cs (3)
201(node is AttributeSyntax || 1205var attributeSyntax = token.GetAncestor<AttributeSyntax>();
SemanticModelExtensions.cs (1)
139case AttributeSyntax attribute:
Simplification\CSharpSimplificationService.cs (1)
58if (node is AttributeSyntax or
Simplification\CSharpSimplificationService.Expander.cs (1)
585if (originalSimpleName.GetAncestor<AttributeSyntax>() != null)
SpeculationAnalyzer.cs (2)
32AttributeSyntax, 150semanticModel.TryGetSpeculativeSemanticModel(position, (AttributeSyntax)nodeToSpeculate, out speculativeModel);
Microsoft.CodeAnalysis.CSharp.Workspaces.UnitTests (2)
Formatting\FormattingElasticTriviaTests.cs (2)
58SyntaxFactory.SingletonSeparatedList<AttributeSyntax>( 80SyntaxFactory.SingletonSeparatedList<AttributeSyntax>(
Microsoft.VisualStudio.LanguageServices.CSharp (42)
CodeModel\CSharpCodeModelService.CodeModelEventCollector.cs (10)
75AttributeSyntax oldAttribute, 76AttributeSyntax newAttribute, 869foreach (var attribute in attributeList.Attributes) 874else if (node is AttributeSyntax attribute) 905foreach (var attribute in attributeList.Attributes) 910else if (node is AttributeSyntax attribute) 920private static void ChangeEventQueueForAttributes(AttributeSyntax attribute, SyntaxNode parent, CodeModelEventType eventType, CodeModelEventQueue eventQueue) 956foreach (var attribute in attributeList.Attributes) 961else if (node is AttributeSyntax attribute) 971private static void AddEventToEventQueueForAttributes(AttributeSyntax attribute, SyntaxNode parent, Action<SyntaxNode, SyntaxNode> enqueueAddOrRemoveEvent)
CodeModel\CSharpCodeModelService.cs (28)
295foreach (var attribute in attributeDeclaration.Attributes) 351if (parent is AttributeSyntax attribute) 779=> node is AttributeSyntax; 846return ((AttributeSyntax)node).Name.ToString(); 917return ((AttributeSyntax)node).WithName( 964var symbol = node is AttributeSyntax 1588foreach (AttributeSyntax attribute in GetAttributeNodes(parentNode)) 1607Debug.Assert(attributeNode is AttributeSyntax); 1609var attribute = (AttributeSyntax)attributeNode; 1641Debug.Assert(attributeNode is AttributeSyntax); 1643name = ((AttributeSyntax)attributeNode).Name.ToString(); 1646foreach (AttributeSyntax attribute in GetAttributeNodes(parentNode)) 1665var attribute = (AttributeSyntax)argument.Ancestors().First(n => n.Kind() == SyntaxKind.Attribute); 1673Debug.Assert(attributeNode is AttributeSyntax); 1681Debug.Assert(attributeNode is AttributeSyntax); 1712Debug.Assert(attributeNode is AttributeSyntax); 1714var attribute = (AttributeSyntax)attributeNode; 1726Debug.Assert(attributeNode is AttributeSyntax); 1728var attribute = (AttributeSyntax)attributeNode; 2792private static Document Delete(Document document, AttributeSyntax node) 2891SyntaxKind.Attribute => Delete(document, (AttributeSyntax)node), 3081var attribute = (AttributeSyntax)attributes[index]; 3325if (container is AttributeSyntax attribute)
CodeModel\CSharpCodeModelService.NodeLocator.cs (4)
41return GetStartPoint(text, (AttributeSyntax)node, part); 92return GetEndPoint(text, (AttributeSyntax)node, part); 243private static VirtualTreePoint GetStartPoint(SourceText text, AttributeSyntax node, EnvDTE.vsCMPart part) 818private static VirtualTreePoint GetEndPoint(SourceText text, AttributeSyntax node, EnvDTE.vsCMPart part)