-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Description
Type of issue
Missing information
Description
As opposed to #43109, these attributes are generally disallowed in source. They affect the language meaning of compiled binaries, and thereby affect how the source code is compiled which references such binaries. This is of interest when using reflection or examining assemblies for purposes of understanding the language meaning of things in metadata.
It could also be interesting to list modreq and modopt types, which are not (usually) also attributes. They are part of the same theme as this page.
-
CompilerFeatureRequired - Prevents downlevel compilers from using metadata they can't safely understand.
-
DecimalConstantAttribute - Encodes
const decimalfields since the runtime does not supportdecimalvalues as constant values. -
DefaultMemberAttribute - Encodes indexers with IndexerNameAttribute. This is how the correct indexer is recognized as default when its name has been customized. Allowed in source.
-
DynamicAttribute - Encodes whether a type in a signature is
dynamic(versusobject). -
Microsoft.CodeAnalysis.EmbeddedAttribute- Types annotated with this attribute are ignored during lookup by the C# compiler. The compiler applies this to types that it generates as internal when compiling. This keeps the generated internal types from affecting other compilations when InternalsVisibleTo is used. Always generated, not in BCL. (References: Generate readonlyattribute if it does not exist roslyn#18715, React to attribute centralization roslyn#68697 (comment)) -
ExtensionAttribute - Encodes extension methods, and is also placed on their containing classes.
-
FixedBufferAttribute - Encodes
fixedstruct fields. -
IsByRefLikeAttribute - Encodes a
refstruct. -
IsReadOnlyAttribute - Indicates whether a parameter is
in(versusreadonly refor[In] ref). -
IsUnmanagedAttribute - Encodes an
unmanagedconstraint on a type parameter. -
NativeIntegerAttribute - Encodes
nint/nuintwhen runtime doesn't supportnative int. Always generated, not in BCL: Add NativeIntegerAttribute runtime#38683. -
NullableAttribute, NullableContextAttribute, NullablePublicOnlyAttribute - Encode nullability annotations.
-
ParamArrayAttribute - Encodes
paramson array parameters. -
ParamCollectionAttribute - Encodes
paramson non-array parameters. Part of the params collections language feature. -
RefSafetyRulesAttribute - Encodes a version that is required in order to understand ref safety annotations in the assembly. Part of the low-level struct improvements language feature.
-
RequiredMemberAttribute - Encodes
requiredon a member. Part of the required members language feature. -
RequiresLocationAttribute - Encodes whether a parameter is
readonly ref(versusinor[In] ref). -
TupleElementNamesAttribute - Encodes tuple element names used in signatures.
Page URL
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/attributes/general
Content source URL
https://github.com/dotnet/docs/blob/main/docs/csharp/language-reference/attributes/general.md
Document Version Independent Id
6a60a627-c59c-74de-ce5b-6f52e15e7668
Article author
Metadata
- ID: d415a929-c112-ab86-cf2e-13bf2ef64e1a
- Service: dotnet-csharp
- Sub-service: lang-reference