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

Rescope empty client suppression #5624

Closed
JoshLove-msft opened this issue Jan 15, 2025 · 5 comments
Closed

Rescope empty client suppression #5624

JoshLove-msft opened this issue Jan 15, 2025 · 5 comments
Assignees
Labels
emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp

Comments

@JoshLove-msft
Copy link
Contributor

In #5218, we implemented logic to skip the generation of clients with no public methods. This has the side effect of preventing customers who customize all client methods from using the helper methods, fields, and properties that would be generated in the client. Since we were implementing this for a very specific known case involving ARM subclients, we should rescope the solution so that we apply it via the ArmVisitor in the Azure Plugin.

@live1206
Copy link
Contributor

Based on the e2e experiment in #5651, the user can implement an empty client in TypeSpec and MGC still generates it.
So, this is not a specific case for Azure plugin only, and then we should skip the empty client generation in MGC as a general behavior.

The criteria of an empty client:

  • There is no operation within InputClient
  • There is no methods in the corresponding sub-clients
  • There is no methods in the corresponding custom code

@JoshLove-msft
Copy link
Contributor Author

This can be closed in favor of an issue to TCGC requesting that namespaces with no operations and no subclients are filtered out. Interfaces without operations should still be included because in that case the customer is explicitly defining the interface, whereas for namespaces they may be defining a models-only namespace in which case a client is unnecessary.

@live1206
Copy link
Contributor

Azure/typespec-azure#2110

@live1206
Copy link
Contributor

From the doc of interface in TyepSpec.

Interfaces are useful for grouping and reusing operations.

@JoshLove-msft Could you help me understand why an empty interface without operation should be included?

@JoshLove-msft
Copy link
Contributor Author

@JoshLove-msft Could you help me understand why an empty interface without operation should be included?

This falls into the "garbage in, garbage out" bucket - the user is explicitly defining an empty interface. We should give them what they asked for.

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 a pull request may close this issue.

2 participants