[Mgmt] Fix nested flattened collection constructor arguments - #63266
Open
Wei Hu (live1206) wants to merge 2 commits into
Open
Wei Hu (live1206) wants to merge 2 commits into
Wei Hu (live1206) wants to merge 2 commits into
Conversation
|
Azure Pipelines: Successfully started running 2 pipeline(s). 11 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Wei Hu (live1206)
force-pushed
the
issue-63263-flattened-collection
branch
from
September 22, 2026 07:51
6e4ed04 to
911f55f
Compare
Wei Hu (live1206)
marked this pull request as ready for review
September 22, 2026 08:14
Wei Hu (live1206)
requested review from
Dapeng Zhang (ArcturusZhang),
JoshLove-msft,
Jorge Rangel (jorgerangel-msft) and
m-nash
as code owners
September 22, 2026 08:14
|
Azure Pipelines: Successfully started running 2 pipeline(s). 11 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The generator conversion is correctly scoped and the regenerated fixture verifies the previously incompatible constructor chain.
Review effort: Balanced
Findings: None
What changed in this PR
Fixes management generator constructor calls by materializing IEnumerable<T> as IList<T> when required by nested flattened models.
Changes:
- Consolidates flattened constructor argument conversion.
- Adds
.ToList()for incompatible collection interfaces. - Adds a TypeSpec regression fixture and regenerated outputs.
Package versioning and released-API compatibility checks are not applicable to this generator-only change.
| File | Description |
|---|---|
FlattenPropertyVisitor.cs |
Adds shared argument conversion and list materialization. |
nested-flattened-collection.tsp |
Defines the regression scenario. |
main.tsp |
Imports the new fixture. |
NestedFlattenedCollectionOperationsRestOperations.cs |
Generated REST operation. |
NestedFlattenedCollectionResource.Serialization.cs |
Generated resource serialization. |
NestedFlattenedCollectionResource.cs |
Generated collection wrapper. |
NestedFlattenedCollectionProperties.Serialization.cs |
Generated properties serialization. |
NestedFlattenedCollectionProperties.cs |
Generated nested properties model. |
NestedFlattenedCollectionItem.Serialization.cs |
Generated item serialization. |
NestedFlattenedCollectionItem.cs |
Generated collection item. |
NestedFlattenedCollectionContent.Serialization.cs |
Generated request serialization. |
NestedFlattenedCollectionContent.cs |
Demonstrates the corrected .ToList() call. |
AzureGeneratorMgmtTypeSpecTestsContext.cs |
Registers generated models. |
MgmtTypeSpecTestsModelFactory.cs |
Adds model factory methods. |
FooResource.cs |
Exposes generated regression operations. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
This branch has not been deployed
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.
Description
Fixes constructor generation for nested collection properties that pass through both explicit property flattening and automatic safe flattening. When an outer public constructor exposes
IEnumerable<T>but the nested constructor requiresIList<T>, the generator now materializes the argument with.ToList().The shared argument-building helper also consolidates the duplicated name-match and type-match conversion logic.
Adds an end-to-end TypeSpec regression fixture that reproduces the Cosmos DB constructor chain from #63263.
Fixes #63263
Validation
pwsh eng/packages/http-client-csharp-mgmt/eng/scripts/Generate.ps1 -filter Mgmt-TypeSpecdotnet test eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/test/Azure.Generator.Mgmt.Tests.csproj --filter FullyQualifiedName~FlattenPropertyVisitorTests --no-restore