-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Attributes recognized by the compiler in binaries #43110
Labels
dotnet-csharp/svc
in-pr
This issue will be closed (fixed) by an active pull request.
lang-reference/subsvc
📌 seQUESTered
Identifies that an issue has been imported into Quest.
Comments
BillWagner
added a commit
to BillWagner/docs
that referenced
this issue
Jan 24, 2025
Add a list of attributes that are written by the compiler that shouldn't be added in users' source code.
BillWagner
added a commit
to BillWagner/docs
that referenced
this issue
Jan 27, 2025
Add a list of attributes that are written by the compiler that shouldn't be added in users' source code.
BillWagner
added a commit
to BillWagner/docs
that referenced
this issue
Jan 27, 2025
Add a list of attributes that are written by the compiler that shouldn't be added in users' source code.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
dotnet-csharp/svc
in-pr
This issue will be closed (fixed) by an active pull request.
lang-reference/subsvc
📌 seQUESTered
Identifies that an issue has been imported into Quest.
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 decimal
fields since the runtime does not supportdecimal
values 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
fixed
struct fields.IsByRefLikeAttribute - Encodes a
ref
struct.IsReadOnlyAttribute - Indicates whether a parameter is
in
(versusreadonly ref
or[In] ref
).IsUnmanagedAttribute - Encodes an
unmanaged
constraint on a type parameter.NativeIntegerAttribute - Encodes
nint
/nuint
when runtime doesn't supportnative int
. Always generated, not in BCL: Add NativeIntegerAttribute runtime#38683.NullableAttribute, NullableContextAttribute, NullablePublicOnlyAttribute - Encode nullability annotations.
ParamArrayAttribute - Encodes
params
on array parameters.ParamCollectionAttribute - Encodes
params
on 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
required
on a member. Part of the required members language feature.RequiresLocationAttribute - Encodes whether a parameter is
readonly ref
(versusin
or[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
@BillWagner
Metadata
Related Issues
Associated WorkItem - 350763
The text was updated successfully, but these errors were encountered: