Azure / typespec-azure

About TypeSpec Azure Libraries
https://azure.github.io/typespec-azure/
MIT License
8 stars 28 forks source link

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

Open iscai-msft opened 3 months ago

iscai-msft commented 3 months ago

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

markcowl commented 3 months ago
m-nash commented 1 week ago

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.