Make the C# TypeExpression handle every type kind - #11596
Draft
Timothee Guerin (timotheeguerin) wants to merge 1 commit into
Draft
Make the C# TypeExpression handle every type kind#11596Timothee Guerin (timotheeguerin) wants to merge 1 commit into
Timothee Guerin (timotheeguerin) wants to merge 1 commit 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.
commit: |
Contributor
|
All changed packages have been documented.
Show changes
|
|
You can try these changes here
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The C#
TypeExpressionthrew a hardErrorfor anything it did not recognise — tuples, string templates, enum members, template parameters and most of the intrinsics. An emitter hitting one of those got a crash with no source location instead of a diagnostic, so@typespec/http-server-csharphad to wrap every call site intry/catch.Those kinds are now handled, and a genuinely unsupported type reports a diagnostic against the offending type and falls back to
object, so compilation continues and the user gets a pointer to the spec that caused it.Two smaller bugs fixed along the way:
typescript-unsupported-scalar) from the C# components.nullandneverintrinsics emittednullandnever, neither of which is a C# type. They now emitobjectandvoid.Also adds an
isCSharpValueTypeutil, since deciding whether a TypeSpec type maps to a C# struct is something every C# emitter needs and every C# emitter was reimplementing.First of a 7-PR stack that moves
@typespec/http-server-csharponto the emitter framework instead of its private forks. Nothing depends on this one; it can merge on its own.