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

[http-client-csharp] the post processor should always keep customized code as root documents #5481

Conversation

ArcturusZhang
Copy link
Member

@ArcturusZhang ArcturusZhang commented Jan 3, 2025

Fixes #5441
Previously in our generator, we have two instances of GeneratedCodeWorkspace: one for the project that is being generated right now (the generated code project), one for the existing part of the generated library (the customized code project).
This leads to an issue that in the post processor, only the generated documents are passed into the post processor, therefore the post processor actually does not know about the existence of the customized files.

This is not very correct because the generated files must need those customized files to work properly therefore they should be in the same project.
This PR refactors this part to change the structure of GeneratedCodeWorkspace: now we only create one instance of GeneratedCodeWorkspace, and the project inside it will be initialized with shared files and all the customized files in it.

In this way, when we get to the post processor, it should be able to access all the necessary documents.

@microsoft-github-policy-service microsoft-github-policy-service bot added the emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp label Jan 3, 2025
@ArcturusZhang ArcturusZhang force-pushed the post-processor-should-always-keep-customized-types branch from c4a9678 to 668c68b Compare January 3, 2025 07:08
@azure-sdk
Copy link
Collaborator

API change check

API changes are not detected in this pull request.

@ArcturusZhang ArcturusZhang marked this pull request as ready for review January 6, 2025 06:49
…rp/src/PostProcessing/GeneratedCodeWorkspace.cs

Co-authored-by: Wei Hu <[email protected]>
Copy link
Contributor

@JoshLove-msft JoshLove-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a test?

@ArcturusZhang
Copy link
Member Author

Can we add a test?

I would love to but I did not really figured out a way that we could unit test this.
We do not really have any test cases for the post processor.
Since this is blocking something in the e2e demo case (we need this to enable a scenario about how to use the error model), I think maybe we could drop an issue here to track adding test cases for post processor in a near future.

@ArcturusZhang
Copy link
Member Author

@live1206 @JoshLove-msft I opened this issue to track adding test cases for post processor in case we forgot it in the future: #5569

@ArcturusZhang ArcturusZhang added this pull request to the merge queue Jan 13, 2025
Merged via the queue into microsoft:main with commit 27373e7 Jan 13, 2025
21 checks passed
@ArcturusZhang ArcturusZhang deleted the post-processor-should-always-keep-customized-types branch January 13, 2025 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[http-client-csharp] post processor is not treating the customization code as root node
4 participants