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
Description
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
Reacted by Copilot
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
Activity
dotnet-policy-service commentedon May 13, 2026
Tagging subscribers to this area: @dotnet/area-system-runtime-compilerservices
See info in area-owners.md if you want to be subscribed.
bartonjs commentedon May 26, 2026
Video
IsClosedTypeAttribute