Typed attributes
Describe how tools should treat a declaration, using typed metadata.
Declare metadata as a type
Sn has an attribute declaration form. Attribute construction and arguments are evaluated at compile time. The compiler can validate the attribute's fields and application site rather than treating every metadata annotation as an unchecked string.
Control where an attribute is legal
AttributeUsage specifies targets, repetition, inheritance, and retention. Repeated target-policy declarations must agree; conflicting or invalid policies are diagnosed.
Choose retention
AttributeRetention.Runtime retains the frozen application when reflection is enabled. CompileTimeOnly omits the runtime record while preserving compile-time semantic metadata and effects.
Query the typed value
Reflection exposes direct and effective inherited attribute queries, including typed AttributesOf<A>() and FirstAttribute<A>() forms. Runtime-retained values are immutable frozen views.
Use the declaration as the source of metadata
Engine and application tools can use attributes for editor presentation, serialization policy, and other domain-specific behavior. The attribute describes the policy; the consuming tool implements it. Applying an annotation does not automatically create a serializer or engine feature.