Open Han-msft opened 3 months ago
Looks like this is caused when we made up a name, we did not check for duplication, and now it duplicates and causes issues https://github.com/Azure/autorest.csharp/blob/187e6f8d3c6634019bcf4ce3db887626a4efa489/src/TypeSpec.Extension/Emitter.Csharp/src/lib/operation.ts#L128
This is because TCGC failed to give alias model a name. That alias model is used in a very complex way. See the bug I created on TCGC: https://github.com/Azure/typespec-azure/issues/918
After TCGC getAllModels adoption, at runtime our emitter should not go to the branch mentioned by dapeng above. You can look a few lines above, and you'll realize that we invoke loadBodyParameter()
will invoke TCGC to get the type. Ideally the return type should have a name.
@Han-msft I would suggest to not use alias
models. Try to define a normal model. I changed alias CreateCollectionOptions
to model CreateCollectionOptions
, and at least the same error doesn't appear.
@archerzz is there any way to keep properties under CreateCollectionOptions
to be spread as method input parameter? That's why we define it as alias.
@archerzz is there any way to keep properties under
CreateCollectionOptions
to be spread as method input parameter? That's why we define it as alias.
@Han-msft There is discussion to unify the behavior of parameter spreading. In the future, named model is also spread as method input parameters: https://github.com/Azure/typespec-azure/issues/612
The only uncertainty is when we will implement the change.
@Han-msft would you mind if you could try the latest generator again? The issue should have been resolved. Thanks.
@archerzz issue resolved after we switched to model for spread parameters.
Describe the issue or request Spec: https://github.com/Azure/azure-rest-api-specs/blob/be45b922eca7b7753e74e2074127f395223fa13e/specification/ai/Face/client.tsp
Exception: https://dev.azure.com/azure-sdk/internal/_build/results?buildId=3806374&view=logs&j=03afb3bb-7296-55ad-aa07-ceee610c73b2&t=0f320c29-1c90-5304-d2d3-c58a6bb76437&l=171