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-tools/typespec-csharp] Improve error message if generated property names conflict #5190

Open
mikeharder opened this issue Dec 3, 2024 · 0 comments
Assignees
Labels
Mgmt This issue is related to a management-plane library. v3 Version 3 of AutoRest C# generator.

Comments

@mikeharder
Copy link
Member

mikeharder commented Dec 3, 2024

A TypeSpec spec contained a model with two properties named fooTime and fooDate. When this model was passed to @azure-tools/typespec-csharp, it failed with this error, since the code generator tries to rename both properties to FooOn.

$ dotnet build /t:generatecode /p:localspecrepo=/foo

  NOTE: A path to a local spec was provided, will generate based off of local files...
...
  Compiling tsp using @azure-tools/typespec-csharp...
  Unhandled exception. System.ArgumentException: An item with the same key has already been added. Key: FooOn

This error message should be improved to:

  1. Identify the properties in the TypeSpec model causing the conflict
  2. Suggest how users can resolve the conflict. Is the only option to rename one of the properties, or could they use something like @@clientName?

We should also consider the following questions:

  1. Could this, or does this, impact the code generators for other languages?
  2. Should detecting conflicting properties fooDate/fooTime be moved upstream, into the TypeSpec Azure Linter, so spec authors get more immediate feedback?

Further details: https://teams.microsoft.com/l/message/19:[email protected]/1733189859118?tenantId=72f988bf-86f1-41af-91ab-2d7cd011db47&groupId=3e17dcb0-4257-4a30-b843-77f47f1d4121&parentMessageId=1733189859118&teamName=Azure%20SDK&channelName=Language%20-%20DotNet&createdTime=1733189859118

@mikeharder mikeharder added the v3 Version 3 of AutoRest C# generator. label Dec 3, 2024
@ArthurMa1978 ArthurMa1978 added the Mgmt This issue is related to a management-plane library. label Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Mgmt This issue is related to a management-plane library. v3 Version 3 of AutoRest C# generator.
Projects
None yet
Development

No branches or pull requests

3 participants