microsoft / microsoft/typespec

[http-client-csharp] Do we still need the long client name after we have the namespace changes?

Open
#6,338 3 comments 0 reactions 0 assignees View on GitHub
emitter:client:csharp
Dominant language
Java
Stars
5.9k
Forks
394
Avg merge
1d 23h
Merged PRs (30d)
104

Description

Previously, we are prepending parent client's name to a subclient (code [here](https://github.com/microsoft/typespec/blob/ea3fe84507adc33a19d81897a194cda6b4639a6e/packages/http-client-csharp/emitter/src/lib/client-model-builder.ts#L123)) to do something like this:

1. The root client will keep its original name from TCGC
2. First level subclient will keep its original name from TCGC
3. Second level and deeper subclient will prepend all its parents' name until the root client's name (exclusive) to its original name

For example, if we have 4 client
```
namespace Service;

namespace Foo {
namespace Bar {
namespace Qux {
}
}
}
```
We would have the following the client:
1. Root client: `ServiceClient`
2. First level sub-client: `Foo`
3. Second level sub-client: `FooBar`
4. Third level sub-client: `FooBarQux`

In the azure generator, this makes sense because everything was in the same namespace (the global root namespace from the configuration), therefore for those deeper level of subclient, we must prepend its parents' name to make sure they would never collide with each other. For instance, we could have a `Bar` from `Service.Foo.Bar` and from `Service.Foo2.Bar`.

But in our current design, those subclients would be generated into their own namespace, therefore even if we have two `Bar`s, they would not in the same namespace.
In this way, do we still need this naming rule?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.