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

[Java] Move (most of) the name mangling logic to the Refiner #3265

Merged
merged 9 commits into from
Sep 21, 2023

Conversation

andreaTP
Copy link
Contributor

@andreaTP andreaTP commented Sep 7, 2023

Sharing to receive early feedback on the direction (cc. @baywet).

I started with Java(instead of Python where we experienced more issues) as I felt more comfortable with it, but I believe that this effort should be extended to all of the languages.

You can check the results by running:

  • on the main branch: dotnet publish ./src/kiota/kiota.csproj -c Release -p:PublishSingleFile=true -p:PublishReadyToRun=true -o ./publish
  • on this PR branch I'm testing with commands like: (cd src/kiota && dotnet build) && ./it/compare-generation.ps1 -descriptionUrl "oas::petstore" -language java
  • use more complex specs by testing against the rest ...

@andreaTP
Copy link
Contributor Author

andreaTP commented Sep 7, 2023

I feel good about the direction and the diff is confirming some improvements, but I haven't verified yet that everything is consistent ...

Copy link
Member

@baywet baywet left a comment

Choose a reason for hiding this comment

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

Thanks for starting this

it/compare-generation.ps1 Outdated Show resolved Hide resolved
it/compare-generation.ps1 Outdated Show resolved Hide resolved
src/Kiota.Builder/Refiners/JavaRefiner.cs Outdated Show resolved Hide resolved
@andreaTP andreaTP force-pushed the java-name-mangling-in-refiner branch from b140c28 to 64b0bd6 Compare September 11, 2023 14:24
@andreaTP andreaTP marked this pull request as ready for review September 11, 2023 14:24
@andreaTP andreaTP requested a review from a team as a code owner September 11, 2023 14:24
@andreaTP andreaTP changed the title [WIP - Java] Move all of the name mangling logic to the Refiner [Java] Move (most of) the name mangling logic to the Refiner Sep 11, 2023
@andreaTP
Copy link
Contributor Author

@baywet and @andrueastman this should be ready for review now 🙂 .

@baywet
Copy link
Member

baywet commented Sep 12, 2023

@andreaTP a couple of integration tests for Java are failing, can you look into it before we review please?

@baywet baywet marked this pull request as draft September 12, 2023 12:06
@andreaTP
Copy link
Contributor Author

The failures looks legit, I probably missed something in the Error classes, I'll have a look 👍

@andreaTP andreaTP force-pushed the java-name-mangling-in-refiner branch from 6fecca4 to d3c02ce Compare September 12, 2023 13:54
@andreaTP andreaTP marked this pull request as ready for review September 12, 2023 13:54
@andreaTP
Copy link
Contributor Author

Ready for review now 👍 happy that the IT tests have detected this last detail 🙂 .

for my future self, the incantation to run all the integration tests for one language:

yq -e '.jobs.integration.strategy.matrix.description[]' .github/workflows/integration-tests.yml | xargs -I{} ./it/generate-code.ps1 -descriptionUrl '{}' -language java && ./it/exec-cmd.ps1 -descriptionUrl '{}' -language java

@andreaTP andreaTP force-pushed the java-name-mangling-in-refiner branch from 93879ad to 9042405 Compare September 20, 2023 10:14
@andreaTP
Copy link
Contributor Author

ready for the next review round 👍

Copy link
Member

@baywet baywet left a comment

Choose a reason for hiding this comment

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

Thanks for this great contribution!
Will you be doing the same for other languages?
@andrueastman for final review and merge

@andreaTP
Copy link
Contributor Author

Will you be doing the same for other languages?

I started this with the intention to get some traction on the subject and ... help 🙂
If no one is picking it up, I can try to go through it, but it's going to take time ...
We also need to properly review new developments to avoid regressions (would it be possible to automate? a source Generator can probably do it ...).

@baywet
Copy link
Member

baywet commented Sep 20, 2023

We should be able to provide help in validating the changes.
Help in implementing those will be harder, the top priority is to get more languages to a stable maturity level at this point.
I'm curious about the idea of source generators, can you expand?

@andreaTP
Copy link
Contributor Author

We should be able to provide help in validating the changes.

This is already super valuable help!

Help in implementing those will be harder, the top priority is to get more languages to a stable maturity level at this point.

I would argue that removing a design issue in the implementation is pretty important to be confident about the maturity level, as, in this case, it's excluding a lot of subtle bugs that are hard to find, hard to debug, and, ultimately, hard to solve (workarounds are very likely to introduce regressions).
But this is on you to prioritize 🙂 ❤️

At my own peace, I'll try to catch up with the other languages 🙂

I'm curious about the idea of source generators, can you expand?

Coming from Scala we are amused to solve all of the problems with macros ...
In the docs we have:

A generator can analyze your source code and emit the code it needs to "wire up" your app.

This means that a Source Generator can analyze the source code and look up for usages of i.e. StringExtensions in the Writer package, and either:

  • fail loudly
  • invalidate the build by emitting invalid code

@baywet
Copy link
Member

baywet commented Sep 20, 2023

Did you mean a code analyzer instead by any chance?

@andreaTP
Copy link
Contributor Author

That's correct, I wasn't aware of code analyzers, the same can likely be done inside a Source Generator, but the analyzer should suffice.

@baywet
Copy link
Member

baywet commented Sep 20, 2023

Added a note in #2842

Copy link
Member

@andrueastman andrueastman left a comment

Choose a reason for hiding this comment

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

Looks great @andreaTP

@andrueastman andrueastman merged commit e87482a into microsoft:main Sep 21, 2023
166 of 167 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants