Make the C# declaration components authorable - #11598
Make the C# declaration components authorable#11598Timothee Guerin (timotheeguerin) wants to merge 3 commits into
Conversation
Adds handling for Tuple, StringTemplate, EnumMember, ModelProperty, UnionVariant, template parameters and the full Intrinsic set. An unsupported type now reports a diagnostic and falls back to `object` instead of throwing. Also fixes the C# components reporting a TypeScript diagnostic for unsupported scalars, and corrects the C# expressions emitted for the `null` and `never` intrinsics. Adds an `isCSharpValueType` util.
…al_ComponentOverrides The `declaration` descriptor existed but nothing dispatched to it, so an emitter could override how a type is referenced but not how it is declared. The C# `ClassDeclaration`, `Property` and `EnumDeclaration` now render through the override point.
ClassDeclaration takes an explicit property list and extra members, Property takes the full Alloy property prop set plus name/csharpType overrides, EnumDeclaration takes an explicit member list and jsonAttributes, and JsonConverter takes doc, access modifiers, extra members and an explicit csharpType.
commit: |
|
All changed packages have been documented.
Show changes
|
|
You can try these changes here
|
The C# declaration components rendered exactly one shape and dropped anything the caller passed.
ClassDeclarationalways emitted every property of the model and nothing else,Propertyaccepted three props out of the ~15 Alloy supports,EnumDeclarationalways derived its members from the type, andJsonConverterhad a fixed body with no way to document it or change its visibility. An emitter that needed a constructor in the class, or a filtered property list, or a differently-named property, had to fork the component.They now take props:
ClassDeclaration— explicitpropertieslist, extra members aschildren.Property— the full Alloy property prop set, plusnameandcsharpTypeoverrides.EnumDeclaration— explicitmemberslist and ajsonAttributesprop.JsonConverter—doc, access modifiers, extra members, an explicitcsharpType, and areadReturnsoverride.Caller-supplied props are spread last so they win over the framework defaults, and every prop is optional, so existing behavior is unchanged.
Part of a 7-PR stack moving
@typespec/http-server-csharponto the emitter framework. Stacked on #11597 — only the last commit is new here.