Open sandboxFocus

Interface IUnionFacet

Represents the structure of a union of C# 15: its authoring form, its cases and its Value property.

Namespace: Metalama.Framework.Code.Types
Assembly: Metalama.Framework.dll
Syntax
[CompileTime]
[InternalImplement]
public interface IUnionFacet : ITypeFacet
Remarks

The facet is reached through Union, as in type.Facets.Union?.Cases. It is null for a type that IsUnion reports as not being a union.

A union is not a kind of its own in the code model. The compiler reports a union declaration as a struct, and the attribute form keeps the kind of the class or the struct that carries the attribute, so IsUnion is the property that tells a union from an ordinary type and this facet is the structure behind it.

Properties

Name Description
Cases

Gets the cases of the union, in the order in which the creation members of the union declare them, which is the order of the union header for a union declaration.

UnionKind

Gets the authoring form of the union.

ValueProperty

Gets the Value property, which holds the value of the case that the union currently carries, or null when the union has no such property. The compiler synthesizes the property for a union declaration, and the language requires the attribute form to have one, so the value is null only for a union that the compiler reports as ill-formed, which the code model of a design-time session does see.

Extension Methods

See Also