-
Notifications
You must be signed in to change notification settings - Fork 257
Format generated Go code to adhere to golang coding standards #6416
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution!
The first version is ready for review @baywet . There are still some minor issues which I was not able to fix as I did not find the code that generates the corresponding code. I will open an issue with the additional minor issues that need to be adressed |
@firefart thanks for the extended work on this. As for your question, have you looked here?
It seems to me that if both the suffix and the return type are null or empty, we should not add the space. |
@baywet thanks for the hint but this particular place it not the provblem. Added some checks, but the trailing spaces are still generated, so it must be elsewhere (but I suspect the same pattern) |
Thank you for the additional information. First, I'm not seeing the trailing space behaviour from the main branch.
Which breaks with the following conditional breakpoint. code.IsOfKind(CodeMethodKind.Setter) && code.Parent is CodeInterface Let me know if you have any additional comments or questions. |
@baywet thanks, that did the trick, the trailing whitespaces are now gone. I also tried to add an integration test to github actions to run go fmt ./... on the generated code and error out if there are formatted files. Could you please approve the github actions run so I can check if the test works? (running it locally is not really possible) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the continuous work on this one. One minor comment left
Co-authored-by: Vincent Biret <vincentbiret@hotmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for making the changes!
Head branch was pushed to by a user without write access
Head branch was pushed to by a user without write access
@baywet fixed the unit tests, so would appreciate a new approval for all the tests. PS: The used xunit version is really old, you should consider upgrading to |
@@ -635,7 +635,7 @@ public void WritesNullableVoidTypeForExecutor() | |||
}; | |||
writer.Write(method); | |||
var result = tw.ToString(); | |||
Assert.Contains(" error {", result); | |||
Assert.Contains("() {", result); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this change is correct, the request executor by definition makes the request, so might encounter a whole range of different errors which need to be reported back to the user. Even if the expected response doesn't have content.
Thanks for bringing this up. From reading the migration documentation, it seems there might be quite some work for this migration. If this is something you feel like you would like to submit a pull request for, I'd suggest starting a new issue. |
gentle reminder on this one @firefart |
@baywet sorry haven't found time yet to look into the tests, but hopefully by the end of the week to get this PR done |
Golang expects generated code to be properly
go fmt
'ed (see golang/go#73181 (comment)).This PR tries to implement the changes so the code will be compatible and
go fmt
will not change anything in the generated code.Changes:
Test:
To test we will create a test client. Next go to the golangtest directory, init a git repo, and run go fmt to see the differences
Ideally the
git diff
will show no changesStill to do