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

dotnet emitter crashes and attempts to write a duplicate file name #5218

Open
xiangyan99 opened this issue Jan 10, 2025 · 7 comments
Open

dotnet emitter crashes and attempts to write a duplicate file name #5218

xiangyan99 opened this issue Jan 10, 2025 · 7 comments
Assignees
Labels
DPG .NET Pull requests that update .net code v3 Version 3 of AutoRest C# generator.

Comments

@xiangyan99
Copy link
Member

I created PR Azure/azure-rest-api-specs#31462 to migrate Search from swagger to tsp.

The tsp project can be found at https://github.com/Azure/azure-rest-api-specs/tree/search_tsp_preview/specification/search/Azure.Search.

The emitter crashes with error:

System.ArgumentException: An item with the same key has already been added. Key: KeywordTokenizer.cs

https://dev.azure.com/azure-sdk/internal/_build/results?buildId=4334521&view=logs&j=03afb3bb-7296-55ad-aa07-ceee610c73b2&t=0f320c29-1c90-5304-d2d3-c58a6bb76437&l=698

We need to identify the blockers for the search TSP migration, and this issue is preventing us from making further progress.

We would appreciate it if you could prioritize it, if possible.

Thank you!

@xiangyan99 xiangyan99 added the v3 Version 3 of AutoRest C# generator. label Jan 10, 2025
@ArthurMa1978 ArthurMa1978 added .NET Pull requests that update .net code DPG labels Jan 24, 2025
@chunyu3
Copy link
Member

chunyu3 commented Jan 24, 2025

Hello @xiangyan99
I successfully generated the SDK using your specification from https://github.com/Azure/azure-rest-api-specs/tree/search_tsp_preview/specification/search/Azure.Search.
I am unable to reproduce the issue you mentioned. Has it been resolved?

@xiangyan99
Copy link
Member Author

I think it still exists.

This was the latest run that was triggered 3 days ago.

And here is the log: https://dev.azure.com/azure-sdk/internal/_build/results?buildId=4496303&view=logs&j=03afb3bb-7296-55ad-aa07-ceee610c73b2&t=0f320c29-1c90-5304-d2d3-c58a6bb76437&l=606

@chunyu3
Copy link
Member

chunyu3 commented Jan 26, 2025

Hello @xiangyan99 In existing sdk code (azure-sdk-for-net/sdk/search/Azure.Search.Documents), there is customized code to rename model KeywordTokenizerV2 to KeywordTokenizer,
https://github.com/Azure/azure-sdk-for-net/blob/c7d7ab3eb72a88bd651bb1cba7e269f658f2b7e6/sdk/search/Azure.Search.Documents/src/Indexes/Models/KeywordTokenizer.cs#L9

Then in the typespec, you define another model KeywordTokenizer which cause the duplication.

To resolve this issue, you need to update the customized code.

@xiangyan99
Copy link
Member Author

Do you mean client.tsp?

I don't see I renamed KeywordTokenizerV2 to KeywordTokenizer in client.tsp?

Did I miss something?

@chunyu3
Copy link
Member

chunyu3 commented Feb 5, 2025

Do you mean client.tsp?

I don't see I renamed KeywordTokenizerV2 to KeywordTokenizer in client.tsp?

Did I miss something?

I mean the customized csharp source code in the azure-sdk-for-net. I passed the code link https://github.com/Azure/azure-sdk-for-net/blob/c7d7ab3eb72a88bd651bb1cba7e269f658f2b7e6/sdk/search/Azure.Search.Documents/src/Indexes/Models/KeywordTokenizer.cs#L9
dotnet will combine the customized source code together with auto-generated code (under src/Generated directory). In the customized source code which already has a model KeywordTokenizer which is renamed from KeywordTokenizerV2.

If you want to keep two models KeywordTokenizer and KeywordTokenizerV2, you can update the customized source code (https://github.com/Azure/azure-sdk-for-net/blob/c7d7ab3eb72a88bd651bb1cba7e269f658f2b7e6/sdk/search/Azure.Search.Documents/src/Indexes/Models/KeywordTokenizer.cs#L11)and don't rename KeywordTokenizerV2 to KeywordTokenizer.

But current azure-rest-api-specs ci pipeline does not honor the temporary changes in azure-sdk-for-net, the ci will always sync the latest commit of azure-sdk-for-net/main to generate code. therefore, the net-automation in azure-rest-api-specs cannot pass.

@xiangyan99

@xiangyan99
Copy link
Member Author

xiangyan99 commented Feb 5, 2025

I updated the code and removed KeywordTokenizer (KeywordTokenizerV2 is still there`).

But it still failed.

Any thoughts? @chunyu3

@chunyu3
Copy link
Member

chunyu3 commented Feb 7, 2025

I updated the code and removed KeywordTokenizer (KeywordTokenizerV2 is still there`).

But it still failed.

Any thoughts? @chunyu3

@xiangyan99

I updated the code and removed KeywordTokenizer (KeywordTokenizerV2 is still there`).
What's code do you updated, the typespec file or the customized code in azure-sdk-for-net?

But it still failed.
Do you mean the sdk-automation of the spec PR failed?

As I mentioned above, azure-rest-api-specs ci pipeline will sync the latest commit in azure/azure-sdk-for-net, and generate sdk based on it. Only when the changes of customized code is merged into azure-sdk-for-net, azure-rest-api-specs can see the changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DPG .NET Pull requests that update .net code v3 Version 3 of AutoRest C# generator.
Projects
None yet
Development

No branches or pull requests

3 participants