Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Align the client type shape from TCGC in our emitter #6179

Merged
merged 33 commits into from
Mar 26, 2025

Conversation

ArcturusZhang
Copy link
Member

@ArcturusZhang ArcturusZhang commented Feb 27, 2025

Fixes #5924
Going forward to the ultimate goal of "only keep minimum code in our emitter, which should only parse and spit out the data from TCGC", this PR removes a few unnecessary code in our emitter, and align the structure of client in our emitter with the client from TCGC.

Client initialization stuff has not been started therefore I still keep the property parameters on the client type to keep maximum compatibility and minimum the code change. I think the parameters could be gone once our client initialization work item was done.

Operation stuff is also not changed, because the way TCGC represent operations/methods is different from ours. I also keep that part as a future work to align.

About client names:
Before, we did client name calculations in the emitter, to assign verbose name to subclients, such as:

namespace Service;

namespace Foo {
	op one(): void;
	
	namespace Bar {
		op two(): void;
		
		namespace Qux {
			op three(): void;
		}
	}
}

We will have 4 clients. The hierarchy looks like this:

ServiceClient
- Foo
	- Bar
		- Qux

As a subclient, for instance, their full name could be ServiceClient.Foo.Bar in this case.
Those second level (or deeper) subclients have a chance to have name collisions because we would put them in the same namespace previously, and we could have another subclient like ServiceClient.Foo2.Bar.

Therefore previously we are making name changes to them automatically for those 2nd-level or deeper subclients by prepending all their parents' name to it.

Now in this PR, it is not the goal here that we change that rule - this PR just wants them all to unchange - therefore I put this logic at the place that we have serialized the whole namespace to keep things in parity.

@microsoft-github-policy-service microsoft-github-policy-service bot added the emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp label Feb 27, 2025
@azure-sdk
Copy link
Collaborator

API change check

API changes are not detected in this pull request.

@ArcturusZhang ArcturusZhang marked this pull request as ready for review March 3, 2025 08:43
Copy link
Contributor

No changes needing a change description found.

@ArcturusZhang ArcturusZhang added this pull request to the merge queue Mar 26, 2025
Merged via the queue into microsoft:main with commit d52dd14 Mar 26, 2025
21 checks passed
@ArcturusZhang ArcturusZhang deleted the align-tcgc-client-models branch March 26, 2025 01:21
mario-guerra pushed a commit that referenced this pull request Apr 2, 2025
Fixes #5924
Going forward to the ultimate goal of "only keep minimum code in our
emitter, which should only parse and spit out the data from TCGC", this
PR removes a few unnecessary code in our emitter, and align the
structure of client in our emitter with the client from TCGC.

Client initialization stuff has not been started therefore I still keep
the property `parameters` on the client type to keep maximum
compatibility and minimum the code change. I think the `parameters`
could be gone once our client initialization work item was done.

Operation stuff is also not changed, because the way TCGC represent
operations/methods is different from ours. I also keep that part as a
future work to align.

About client names:
Before, we did client name calculations in the emitter, to assign
verbose name to subclients, such as:
```
namespace Service;

namespace Foo {
	op one(): void;
	
	namespace Bar {
		op two(): void;
		
		namespace Qux {
			op three(): void;
		}
	}
}
```
We will have 4 clients. The hierarchy looks like this:
```
ServiceClient
- Foo
	- Bar
		- Qux
```
As a subclient, for instance, their full name could be
`ServiceClient.Foo.Bar` in this case.
Those second level (or deeper) subclients have a chance to have name
collisions because we would put them in the same namespace previously,
and we could have another subclient like `ServiceClient.Foo2.Bar`.

Therefore previously we are making name changes to them automatically
for those 2nd-level or deeper subclients by prepending all their
parents' name to it.

Now in this PR, it is not the goal here that we change that rule - this
PR just wants them all to unchange - therefore I put this logic at the
place that we have serialized the whole namespace to keep things in
parity.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[http-client-csharp] Adopt TCGC changes on client hierarchy
4 participants