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

[csharp] massively improve csharp templates code #16990

Closed

Conversation

filipe-silva
Copy link
Contributor

@filipe-silva filipe-silva commented Nov 5, 2023

Improved apiclient.mus to keep it dry, sharing a single exec with Action<> delegate.
Improved api.mus to keep it dry, used chain constructors, kept RequestOptions in a single method, set configuration POCO with alias directive and moved fqn types to using directive for cleaner code.
Removed 'this' from variables/props that are redundant.
Fixed incompatible framework, System.Web, used on .NET 6.0 and above.

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh ./bin/configs/*.yaml
    ./bin/utils/export_docs_generators.sh
    
    (For Windows users, please run the script in Git BASH)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • File the PR against the correct branch: master (upcoming 7.1.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@mandrean @shibayan @Blackclaws @lucamazzanti @iBicha

improved apiclient.mus to keep it dry, sharing a single exec with Action<> delegate.
improved api.mus to keep it dry, used chain constructors, kept RequestOptions in a single method, set configuration with alias directive
moved fqn types to using directive for cleaner code
removed 'this' from variables/props that are redundant
@filipe-silva
Copy link
Contributor Author

Added issue #16989 according to contributing readme.

@filipe-silva filipe-silva marked this pull request as ready for review November 5, 2023 12:34
@wing328
Copy link
Member

wing328 commented Nov 6, 2023

thanks for the PR.

can you please update the tests (java unit tests) as well?

[ERROR] Failures: 
[ERROR]   CSharpClientDeepObjectTest.deepObject:70 expected:<2> but was:<1>
[ERROR] Tests run: 1997, Failures: 1, Errors: 0, Skipped: 0
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0:test (default-test) on project openapi-generator: There are test failures.
[ERROR] 
[ERROR] Please refer to /home/circleci/OpenAPITools/openapi-generator/modules/openapi-generator/target/surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.

ref: https://circleci.com/gh/OpenAPITools/openapi-generator/81692

@filipe-silva
Copy link
Contributor Author

thanks for the PR.

can you please update the tests (java unit tests) as well?

[ERROR] Failures: 
[ERROR]   CSharpClientDeepObjectTest.deepObject:70 expected:<2> but was:<1>
[ERROR] Tests run: 1997, Failures: 1, Errors: 0, Skipped: 0
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0:test (default-test) on project openapi-generator: There are test failures.
[ERROR] 
[ERROR] Please refer to /home/circleci/OpenAPITools/openapi-generator/modules/openapi-generator/target/surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.

ref: https://circleci.com/gh/OpenAPITools/openapi-generator/81692

Sure, I can give a go, which IDE do you use?
I currently only have VSCode, but I don't use it for JAVA

Improve api.mustache template without more DRY methods
@filipe-silva
Copy link
Contributor Author

thanks for the PR.

can you please update the tests (java unit tests) as well?

[ERROR] Failures: 
[ERROR]   CSharpClientDeepObjectTest.deepObject:70 expected:<2> but was:<1>
[ERROR] Tests run: 1997, Failures: 1, Errors: 0, Skipped: 0
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.0.0:test (default-test) on project openapi-generator: There are test failures.
[ERROR] 
[ERROR] Please refer to /home/circleci/OpenAPITools/openapi-generator/modules/openapi-generator/target/surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.

ref: https://circleci.com/gh/OpenAPITools/openapi-generator/81692

All done, test now run OK

imagem

@wing328
Copy link
Member

wing328 commented Nov 9, 2023

Thanks for the PR but your commit (as shown in the Commits tab) is not linked to your Github account, which means this PR won't count as your contribution in https://github.com/OpenAPITools/openapi-generator/graphs/contributors.

Let me know if you need help fixing it.

Ref: https://github.com/OpenAPITools/openapi-generator/wiki/FAQ#how-can-i-update-commits-that-are-not-linked-to-my-github-account

@wing328 wing328 added Client: C-Sharp Enhancement: Code Cleanup General refactoring, removal of deprecated things, commenting, etc. labels Nov 9, 2023
@wing328 wing328 added this to the 7.1.0 milestone Nov 9, 2023
@filipe-silva
Copy link
Contributor Author

filipe-silva commented Nov 11, 2023

Thanks for the PR but your commit (as shown in the Commits tab) is not linked to your Github account, which means this PR won't count as your contribution in https://github.com/OpenAPITools/openapi-generator/graphs/contributors.

Let me know if you need help fixing it.

Ref: https://github.com/OpenAPITools/openapi-generator/wiki/FAQ#how-can-i-update-commits-that-are-not-linked-to-my-github-account

Thanks for the heads up, I think it's working. I just added a secondary email.

Btw the failing check is on the samples, it simply says:
UNCOMMITTED CHANGES ERROR
There are uncommitted changes in working tree after execution of 'bin/generate-samples.sh'

Should I run that sh locally and commit the result? Or is it something else?

@wing328 wing328 modified the milestones: 7.1.0, 7.2.0 Nov 13, 2023
@wing328
Copy link
Member

wing328 commented Nov 16, 2023

can you please update the samples when you've time?

https://github.com/OpenAPITools/openapi-generator/actions/runs/6799047830/job/18529721203?pr=16990

update: done via b510aff

@wing328
Copy link
Member

wing328 commented Nov 16, 2023

i've merged the latest master into your branch and filed #17097.

Some CI tests (C# related) failed. Can you please take a look when you've time?

…napi-generator into charp-templates

# Conflicts:
#	samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt-useSourceGeneration/src/UseSourceGeneration/Model/FormatTest.cs
#	samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0-nrt/src/Org.OpenAPITools/Model/FormatTest.cs
#	samples/client/petstore/csharp/OpenAPIClient-generichost-net6.0/src/Org.OpenAPITools/Model/FormatTest.cs
#	samples/client/petstore/csharp/OpenAPIClient-generichost-netstandard2.0/src/Org.OpenAPITools/Model/FormatTest.cs
@filipe-silva
Copy link
Contributor Author

i've merged the latest master into your branch and filed #17097.

Some CI tests (C# related) failed. Can you please take a look when you've time?

Hi, I've regenerated the samples and everything seems to be ok, can you resolve the conflicts?

@wing328
Copy link
Member

wing328 commented Dec 1, 2023

, can you resolve the conflicts?

please merge latest master into your branch and regenerate the samples to resolve the merge conflicts

i'll try to put other c# related PRs on hold for the time being.

@wing328 wing328 removed this from the 7.2.0 milestone Dec 22, 2023
@filipe-silva
Copy link
Contributor Author

, can you resolve the conflicts?

please merge latest master into your branch and regenerate the samples to resolve the merge conflicts

i'll try to put other c# related PRs on hold for the time being.

Hi, terribly sorry, it completely slipped my mind, because of the holidays starting.

I did the pull and merge, there are no conflitcs as of now.

@wing328
Copy link
Member

wing328 commented Jan 28, 2024

@wing328
Copy link
Member

wing328 commented Feb 28, 2024

your last commit includes changes to lots of files not originally included in this PR (likely the rebase wasn't done correctly)

can you please PM me via Slack so that I can help you out?

https://join.slack.com/t/openapi-generator/shared_invite/zt-12jxxd7p2-XUeQM~4pzsU9x~eGLQqX2g

@filipe-silva
Copy link
Contributor Author

your last commit includes changes to lots of files not originally included in this PR (likely the rebase wasn't done correctly)

can you please PM me via Slack so that I can help you out?

https://join.slack.com/t/openapi-generator/shared_invite/zt-12jxxd7p2-XUeQM~4pzsU9x~eGLQqX2g

Hi (after a lot of time, sorry) so the rebase was getting pretty difficult at the time.
I choose another approach. I've done a new branch, up to date with master and redid my changes.
I'll be closing this PR and opening a new one, since i did a new branch.

@filipe-silva filipe-silva deleted the charp-templates branch July 20, 2024 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client: C-Sharp Enhancement: Code Cleanup General refactoring, removal of deprecated things, commenting, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants