Azure / typespec-azure

About TypeSpec Azure Libraries
https://azure.github.io/typespec-azure/
MIT License
8 stars 29 forks source link

Original name of a type (model or scalar) needs to be tracked in TCGC #1059

Open ArcturusZhang opened 2 weeks ago

ArcturusZhang commented 2 weeks ago

Now, we only keep the "library name" of a type as the name field in the TCGC's result. But we might need to keep the original name (we could call it tspName in parallel of tspNamespace which should be intuitive).

Imagine this scenario: we have a type in azure.core template, such as:

namespace Azure.Core;
model ResponseError {}

And when it is used in an RP's spec, a decorator could be added to it via client.tsp:

@@clientName(Azure.Core.ResponseError, "NewError", "csharp");

Now the model returned in TCGC for this ResponseError will be:

{
    kind: "model",
    name: "NewError",
    tspNamespace: "Azure.Core"
}

The generator now only knows that this model is defined in Azure.Core namespace, but it loses track of which model this is because of the name change.

Therefore we might need another field to track its original name for all types.