-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Closed
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-System.Runtime.CompilerServices
Milestone
Description
Rationale and Usage
For upcoming C# features captured in document here, the C# compiler needs a way to annotate metadata as read-only. The proposal is to add a new attribute to System.Runtime.CompilerServices namespace similar toInAttribuate and OutAttribute, named IsReadOnlyAttribue. Example usages:
- For read-only reference parameters.
- For return types that are read-only references.
- On read-only structs.
Proposed API
// .NET Core:
// System.Runtime (reference assembly)
// System.Private.CoreLib (implementation)
// .NET Framework 4.7++
// mscorlib
// .NET Standard 2.0++
// netstandard
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.All, Inherited = false)]
public sealed class IsReadOnlyAttribue: Attribute
{
public IsReadOnlyAttribue();
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-System.Runtime.CompilerServices