Skip to content

[API Proposal]: ClosedAttribute #128161

Closed

Description

@RikkiGibson

Background and motivation

As part of supporting Closed class hierarchies feature, we need a new attribute that will be used by C# compiler to designate a closed type.

API Proposal

namespace System.Runtime.CompilerServices
{
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
    public sealed class ClosedAttribute : Attribute { }
}

Note: in the future, we may wish to add other type kinds, such as "interface" or "enum", as valid targets, as we design "closed" forms of these types. But our focus is on classes only for now. Also, the attribute is not allowed to be used explicitly in C#.

API Usage

public closed class Animal; // generates a type which has `[Closed]` attribute in metadata
public class Dog : Animal;
public class Cat : Animal;

Alternative Designs

No response

Risks

No response

Activity

  1. added
    api-suggestionEarly API idea and discussion, it is NOT ready for implementation
    on May 13, 2026
  2. dotnet-policy-service commented on May 13, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @dotnet/area-system-runtime-compilerservices
    See info in area-owners.md if you want to be subscribed.

  3. added
    blockingMarks issues that we want to fast track in order to unblock other important work
    api-ready-for-reviewAPI is ready for review, it is NOT ready for implementation
    and removed
    api-suggestionEarly API idea and discussion, it is NOT ready for implementation
    untriagedNew issue has not been triaged by the area owner
    on May 13, 2026
  4. bartonjs commented on May 26, 2026

    @bartonjs
    Member

    Video

    • Let's not waste a single-word attribute name on something no one is ever supposed to type.
      • IsClosedTypeAttribute
    namespace System.Runtime.CompilerServices
    {
        [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
        public sealed class IsClosedTypeAttribute : Attribute { }
    }
  5. added
    api-approvedAPI was approved in API review, it can be implemented
    and removed
    blockingMarks issues that we want to fast track in order to unblock other important work
    api-ready-for-reviewAPI is ready for review, it is NOT ready for implementation
    on May 26, 2026
  6. linked a pull request that will close this issueAdd IsClosedTypeAttribute #128599on May 26, 2026
  7. locked and limited conversation to collaborators on Jul 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions