You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Define what the generators do with a union or a closed class, through IsUnion and IsClosed #223
Use a C# 15 union or a closed class next to TypeKit's value objects, in a project woven by Metalama 2027 (C# 15 on net11.0), and get either a working value object or a clear diagnostic. Never one that compiles and does less than it appears to.
Two shapes have no defined answer today, because Metalama 2026.1 can't compile them in a woven project (decision 120):
A value object that wraps a union or a closed type:readonly partial record struct PetId : IValue<Pet>; where Pet is a union. The generated JSON goes through GeneratedJsonPlan<T>, and System.Text.Json has union support (net11.0: Option/Result refusal and value-object JSON under System.Text.Json's union support #213). A union has no IParsable, no IComparable and no type converter of its own.
A union or a closed class that claims a TypeKit contract, for example a union declared with IValue<int> or IClosedSet<TSelf>, if C# 15 lets a union declare interfaces at all.
What you'd like
Metalama 2027.0's INamedType.IsUnion, IsClosed and IUnionFacet (release notes, "Unions" and "Closed classes") let the fabric and the aspects tell these shapes apart. That's the code model's answer, not a name.
For each shape, decide: generated and tested (the JSON byte for byte as the wrapped union's), or refused with a CMTK diagnostic that names the shape. A new diagnostic ships at Warning, since a minor never adds an Error (decision 34).
Rows for unions and closed types join the generated-type axes, on the net11.0 test run.
Does it change something that compiles or works today?
No. Neither shape compiles in a woven project before 2.4.0, which moves to Metalama 2027.0 (decision 129). That is why this is 2.4.0 work: the release that makes them compile defines what they do.
Activity