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

[azure core] "@azure-tools/typespec-azure-core/property-name-conflict" throwing when renamed with @clientName #417

Open
iscai-msft opened this issue Mar 13, 2024 · 3 comments
Assignees
Labels
bug Something isn't working lib:tcgc Issues for @azure-tools/typespec-client-generator-core library

Comments

@iscai-msft
Copy link
Contributor

iscai-msft commented Mar 13, 2024

rule here: https://github.com/Azure/typespec-azure/blob/main/packages/typespec-azure-core/src/rules/property-naming.ts

@doc("An object containing more specific information about the error.")
model InnerError {
  @doc("One of a server-defined set of error codes.")
  code?: string;

  @doc("A human-readable representation of the error.")
  message?: string;

  #suppress "@azure-tools/typespec-azure-core/property-name-conflict" "Renamed with client name"
  @doc("Inner error.")
  @clientName("InnerErrorObject", "csharp")
  innererror?: InnerError;
}

Since @clientName is a tcgc decorator, and azure-core seems to be throwing this error for csharp, I think we should move this linter either into tcgc or typespec-csharp

@iscai-msft iscai-msft added the bug Something isn't working label Mar 13, 2024
@markcowl
Copy link
Member

markcowl commented Mar 19, 2024

@markcowl markcowl assigned markcowl and unassigned markcowl Mar 19, 2024
@markcowl markcowl added this to the [2024] May milestone Mar 19, 2024
@markcowl markcowl modified the milestones: [2024] May, [2024] June May 7, 2024
@markcowl markcowl modified the milestones: [2024] June, [2024] August Jun 17, 2024
@m-nash m-nash removed their assignment Jun 28, 2024
@m-nash
Copy link
Member

m-nash commented Jun 28, 2024

This issue doesn't appear to be related to dotnet only (unless I am missing something).

It sounds like the error comes from when someone uses @clientName to create a naming conflict?

For example

//main.tsp
model Foo {
}
model Bar {
}
//client.tsp
@@clientName(Bar, "Foo", "python");

This should be an error diagnostic in tcgc since you have created a "compilation issue". I don't think this has anything to do with moving the existing linter to tcgc either (although there might be independent merits for that).

I think its worth considering how tcgc should raise these compilation errors and whether or not they should raise all errors if there are any in the client.tsp regardless of scope so we don't get the situation where it works great in dotnet then all of a sudden when someone tries python it fails because the bad rename was scoped to only python.

I think tcgc should throw regardless of current scope if any renames create a conflict so that customers see the error immediately and fix as early as possible.

@timotheeguerin timotheeguerin added the lib:tcgc Issues for @azure-tools/typespec-client-generator-core library label Aug 12, 2024
@timotheeguerin
Copy link
Member

Should be simple to move this rule after this is setup #1208

@m-nash this rule is specifically for csharp where you cannot name a property the same as the model as it would conflict with the constructor name

@markcowl markcowl added this to the [2025] February milestone Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working lib:tcgc Issues for @azure-tools/typespec-client-generator-core library
Projects
None yet
Development

No branches or pull requests

5 participants