Currently C# does not natively support extended attributes. The Roslyn compiler has not yet integrated this functionality into its standard library.
In different C# versions, adding extended attributes has been discussed. However, due to concerns about its value and the need for a well-designed implementation, this feature has not yet been added.
Despite the lack of native support, there are some workarounds that provide limited functionality:
Recent updates indicate that extended attributes may be supported in the future. The topic of "extending everything" has been brought up, with a focus on properties and fields. However, this feature is still in the discussion and proposal stage and is not guaranteed to be included in an upcoming C# version.
According to the proposed syntax, extension properties will use similar syntax as extension methods:
<code>public extension MyPersonExtension extends Person : IEmployee { public decimal Salary { get; set; } }</code>
This syntax allows extending a specific type with additional properties. Note that extension properties cannot add private instance members, thus ensuring the integrity of the original class structure.
The syntax and implementation of extended properties may change as the functionality is further developed and refined.
The above is the detailed content of Does C# Support Extension Properties?. For more information, please follow other related articles on the PHP Chinese website!