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
fix(http-server-csharp): include nested provisioning state members - #12452
Flatten nested named string unions when generating C# enums.
Preserve standard terminal members such as Succeeded, Failed, and Cancelled when an extensible provisioning-state union includes ResourceProvisioningState.
Keep recursive union references safe and preserve existing support for open string, null, unnamed literals, and inline literal unions.
Add a regression test and a Chronus change description.
Slai Agent Runtime performed the investigation, implementation, and test execution. The account owner authorized this contribution and is responsible for its content.
Azure Pipelines:
Successfully started running 1 pipeline(s).
1 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Nested-union flattening introduces conflicting enum members, invalid variant references that prevent compilation, and lost nullability for nullable wrappers.
This PR addresses #12367 by flattening nested string unions in the C# HTTP server emitter, allowing provisioning-state enums to include standard terminal states alongside user-defined states.
Changes:
Recursively collect nested string-literal members with cycle detection.
Add a regression test for nested provisioning-state members.
Add a Chronus fix entry for @typespec/http-server-csharp.
Slai Agent Runtime performed the investigation, implementation, and test execution. The account owner authorized this contribution and is responsible for its content.
For union Maybe { "ready" | null }, this allows the anonymous nested union's null to be discarded and makes isUnionEnum(Maybe) true. type-expression/type-expression.tsx:207–208 then renders a non-nullable Maybe, so a required property cannot represent an allowed null value; keep nested nullable unions on the existing fallback path or propagate their nullability into type resolution.
I will push this as the next commit after the final diff check.
Slai Agent Runtime performed the investigation, implementation, and test execution. The account owner authorized this contribution and is responsible for its content.
Pushed aa77e0f7d with the completed follow-up fixes and regression coverage.
The PR now preserves direct-null union semantics by emitting the flattened enum and rendering it as nullable (?), while retaining named nested-union fallback behavior and anonymous inline-literal flattening. The local verification in the previous comment completed successfully before push.
Slai Agent Runtime performed the investigation, implementation, and test execution. The account owner authorized this contribution and is responsible for its content.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Critical union-enum issues drop allowed nullability, emit invalid Status?? types, and allow generated C# name collisions that produce incorrect default initializers.
The union.name exception accepts nullable anonymous unions, so union Status { "ready" | null } now qualifies as an enum even though isNullableUnionEnum only checks direct variants; TypeExpression consequently emits non-nullable Status, losing the allowed null (type-expression.tsx:208–209). Reject nested open/null variants for anonymous unions too, or propagate their nullability before accepting them.
Detect enum member collisions after C# name normalization
With union Inner { ready: "inner" } and union Outer { Ready: "outer", Inner }, the raw names pass this check but both normalize to Ready under the naming policy used at enums.tsx:124. getEnumDefaultInitializer (model-helpers.ts:111–112) then generates Outer.Ready for both string defaults, although they must serialize differently. Reject collisions using the generated C# identifiers, or disambiguate members and their initializer references, with a regression covering both defaults.
Enum-member conflict detection now uses the same C# name normalization used during emission, so ready and Ready cannot silently produce conflicting Ready members/defaults.
Nullable union-enums now have a single suffix owner: callers that already render optional/nullable syntax request the non-suffixed enum type; direct type expressions retain ?. This covers models, error constructors, business interfaces, controllers, and mock implementations.
The nullability check also follows anonymous inline union wrappers, so an inline ... | null member cannot be flattened while losing nullability.
Slai Agent Runtime performed the investigation, implementation, and test execution. The account owner authorized this contribution and is responsible for its content.
Addressed the latest review findings in commit 9cc18133f.
Forward nullable through UnionVariant, ModelProperty, nullable-union unwrapping, and same-kind union pass-throughs so callers do not create duplicate nullable suffixes.
Keep explicit null reachable through nested named unions when determining enum nullability.
Added a regression covering nullable={false} through a nested nullable union.
Validation:
Full @typespec/http-server-csharp Vitest suite: 21 files, 245 tests passed.
Oxlint on changed files: 0 warnings / 0 errors.
Prettier check: passed.
git diff --check: passed.
Slai Agent Runtime performed the investigation, implementation, and test execution. The account owner authorized this contribution and is responsible for its content.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
A critical issue remains: named inline union groups containing non-string-literal variants are accepted as enums, causing references such as Outer.Group to generate C# that does not compile.
I’m checking the latest review feedback against the current commit before making any changes. I’ll update the PR only if the feedback identifies a reproducible issue.
Addressed the latest Copilot review findings in commit ec7653ca0.
Anonymous inline groups are flattened only when every member is a string literal; nullable/open/mixed groups remain on the normal union path so their semantics and references are preserved.
Updated the nullable=false regression to cover a direct nullable union-enum without introducing an unresolved nested synthetic reference.
Validation:
Full @typespec/http-server-csharp Vitest suite: 21 files, 246 tests passed.
Oxlint on changed files: 0 warnings / 0 errors.
Prettier check: passed.
git diff --check: passed.
Slai Agent Runtime performed the investigation, implementation, and test execution. The account owner authorized this contribution and is responsible for its content.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed because nested-union handling can generate unresolved enum references, while nullable-signature coverage gaps and exponential traversal add further uncertainty.
Addressed the latest review findings in commit 181e33d1d.
Named variants that contain anonymous string-literal unions continue to flatten, while named variants containing nullable or mixed inline unions remain on the existing non-enum path.
Added an end-to-end nullable parameter regression covering nested nullable union enums through generated interfaces, mocks, and controllers.
Validation:
Full @typespec/http-server-csharp Vitest suite: 21 files, 246 tests passed.
Oxlint on changed files: 0 warnings / 0 errors.
Prettier check: passed.
git diff --check: passed.
Slai Agent Runtime performed the investigation, implementation, and test execution. The account owner authorized this contribution and is responsible for its content.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed because union-variant handling can produce unresolved enum references, while shared nested unions can trigger exponential traversal work.
I reviewed the latest Copilot findings in review 5721614214 against the current head ec7653ca0. The mixed named inline-group case is now covered by the existing guard: named variants are flattened only when their anonymous union contains string literals exclusively; nullable/open/mixed groups stay on the normal union path. The nullable suffix handling is also covered by the nullable propagation and nested-nullable regression already in the current head. The focused verification passes: enums.test.tsx and nullable-parameters.test.ts — 19 tests passed; Prettier passed; git diff --check is clean. No additional code change is necessary for these findings.
I reviewed the findings in reviews 5721614214 and 5721723594 against the current head 181e33d1d. No additional code change is needed: named variants containing anonymous literal-only unions remain flattenable, while named nullable/open/mixed groups stay on the normal union path; the nullable suffix is owned by the caller via nullable propagation, preventing ?? in optional parameters and nested nullable unions. The focused enum/type-expression and nullable-parameter regressions pass locally, and the full http-server-csharp suite passed (246 tests). I will leave the current implementation unchanged unless a maintainer identifies a reproducible failure.
This branch has not been deployed
No deployments
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
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.
Summary
Succeeded,Failed, andCancelledwhen an extensible provisioning-state union includesResourceProvisioningState.string,null, unnamed literals, and inline literal unions.Fixes #12367
Validation
pnpm --filter @typespec/http-server-csharp buildpnpm --filter @typespec/http-server-csharp test -- --run src/components/enums/enums.test.tsxpnpm exec prettier --check packages/http-server-csharp/src/components/enums/enums.tsx packages/http-server-csharp/src/components/enums/enums.test.tsxpnpm --filter @typespec/http-server-csharp lintgit diff --checkSlai Agent Runtime performed the investigation, implementation, and test execution. The account owner authorized this contribution and is responsible for its content.