Skip to content

Proposal for adding System.Runtime.CompilerServices.IsReadOnlyAttribue #20847

@OmarTawfik

Description

@OmarTawfik

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:

  1. For read-only reference parameters.
  2. For return types that are read-only references.
  3. 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();
    }
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions