-
Notifications
You must be signed in to change notification settings - Fork 243
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
[http-client-csharp] spector case http/client/naming
cannot compile
#5653
Comments
TypeSpec itself allows us to define a model with the same name under a namespace, such as:
We have checks on those clientName decorators to ensure within the same namespace, we do not have models with the same name. Should we do a check in the emitter and report another diagnostic on this, and then automatically rename the model? Or we should ignore it and fix on its spec? |
I'm curious how this can work for other typed languages, e.g. Java. If a customer is explicitly trying to name the model and the client as the same thing, I don't think we should try to rename one of them. We should let the compilation fail. But don't we end up suffixing all clients with "Client"? Or is this because it is a subclient? |
in this case, it is a sub-client, therefore we did not append any suffix. |
So based on our principal, it is fine that we generate code that cannot compile - the ground rule is that we have to generate something, it may be fine if in some edge cases it cannot compile. Diagnostics should always be reported when such cases happen. In the namespace PR, considering it already contains so many changes (1000+ files changed with their namespaces), I would temporarily remove this case in the namespace PR to make sure everything is working properly. |
We should assert that the model/client with the same names are generated. |
We can make the project build by adding |
This spector has a sub-client
ClientModel
and a modelClientModel
under the same namespace: https://github.com/Azure/typespec-azure/blob/20444c9531da7b8b1bba8932d29269e96cacb270/packages/azure-http-specs/specs/client/naming/main.tsp#L147-L164In our generated code, now we just generated a client type
ClientModel
, and a model typeClientModel
.This will never compile because they both have a parameterless constructor. And on the other hand, even if this could compile, this will never work.
This issue will not happen on main branch. The code on main branch also have one client
ClientModel
and one modelClientModel
but they are defined in different namespaces therefore it is actually fine.But with the "honor tsp namespace" feature, they are now defined in the same namespace, and we now have a trouble.
The text was updated successfully, but these errors were encountered: