More attributes recognized by the compiler (misc page?) #43109
Labels
doc-enhancement
Improve the current content [org][type][category]
dotnet-csharp/svc
lang-reference/subsvc
Pri2
Type of issue
Missing information
Description
These seem to match the theme of the existing misc page. They are attributes which are permitted in source and which provide access to specific compiler features or behaviors. (As opposed to #42850, which is more specifically about access to IL flags.)
DeprecatedAttribute - Windows.Foundation.Metadata's take on ObsoleteAttribute
EnumeratorCancellationAttribute - part of the async enumerators language feature
ExperimentalAttribute - Windows.Foundation.Metadata's take which predated the one in System.Diagnostics.CodeAnalysis
CollectionBuilderAttribute - part of the collection expressions language feature
IndexerNameAttribute - enables C# authors to control the metadata name of an indexer, which would otherwise be
Item
. This attribute is not emitted into the binary; instead, the indexer's metadata name is set, and DefaultMemberAttribute is emitted on the containing type. By emitting DefaultMemberAttribute, the named indexer is still recognized downstream as being the default indexer despite not necessarily having the nameItem
.InlineArrayAttribute - part of the inline arrays language feature. Enables indexing and implicit casts to spans.
InterceptsLocationAttribute - part of the interceptors compiler feature
SetsRequiredMembersAttribute - part of the required members language feature
UnmanagedCallersOnlyAttribute - part of the function pointers language feature, required for
delegate* unmanaged<void> someFuncPointer = &SomeMethod;
IUnknownConstantAttribute, IDispatchConstantAttribute - together with
[Optional]
on a parameter with no default value specified, tells the compiler whether to passnew UnknownWrapper(null)
ornew DispatchWrapper(null)
rather than passingnull
. (Ref: https://github.com/dotnet/roslyn/blob/v4.2.0/src/Compilers/CSharp/Portable/Binder/Binder_Invocation.cs#L1182-L1192)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
The text was updated successfully, but these errors were encountered: