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
Once we enable the tsp namespace feature, we get tons of occurrence of this case:
one of the segment of the namespace collides with one of the existing type name, such as in cadl-ranch case http/client/naming, we have a type Client.Naming.UnionEnum.ClientExtensibleEnum and another client Client.Naming.UnionEnum
Here is a case that one namespace segment collides with a type's name. Spec here: Azure/typespec-azure@111e0b9/packages/azure-http-specs/specs/client/naming/main.tsp#L197
We get this before - but when this happens before, we rename the namespace, see this cadl ranch project:
Well after a few more investigations, this comes from a fact that might be a design flaw:
In tsp, namespace might become a client in the generated library, and client is a type - therefore this is a 100% percent-triggered scenario, when we have a typespec file which uses a namespace as a client (defines operations inside it), and defines models under it, such as this case: https://github.com/Azure/typespec-azure/blob/111e0b9603c0b2b28415cbecd8d9669945f8b4c7/packages/azure-http-specs/specs/client/naming/main.tsp#L197
In the above case, the namespace itself becomes a type, therefore we have a type: UnionEnum, and in the meantime, the model/enum defined inside this namespace will have the namespace XXX.UnionEnum. Therefore bam! we now have namespace colliding with type names.
../C:/Users/dapzhang/Documents/Workspaces/typespec/packages/http-client-csharp/node_modules/@azure-tools/azure-http-specs/specs/client/naming/main.tsp:195:11 - warning @typespec/http-client-csharp/general-warning: bad namespace Client.Naming.UnionEnum for client UnionEnum, please use @clientNamespace to specify a different namespace or @clientName to specify a different name for the client
> 195 | namespace UnionEnum {
| ^^^^^^^^^
Once we enable the tsp namespace feature, we get tons of occurrence of this case:
one of the segment of the namespace collides with one of the existing type name, such as in cadl-ranch case
http/client/naming
, we have a typeClient.Naming.UnionEnum.ClientExtensibleEnum
and another clientClient.Naming.UnionEnum
Here is a case that one namespace segment collides with a type's name. Spec here: Azure/typespec-azure@111e0b9/packages/azure-http-specs/specs/client/naming/main.tsp#L197
We get this before - but when this happens before, we rename the namespace, see this cadl ranch project:
typespec/packages/http-client-csharp/generator/TestProjects/CadlRanch/http/type/array/src/Generated/ArrayClient.cs
Line 8 in 2fd4d33
in this case, the namespace segment collides with BCL type names, therefore we renamed them.
Now the new change uncovers more occurrence of this issue, we need to find a solution to avoid the generated code to fail to compile.
The text was updated successfully, but these errors were encountered: