-
Notifications
You must be signed in to change notification settings - Fork 377
Add auto-generated header to GenApi output (user defined or automatic) #4649
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
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.
This should not be optional. All generated files should include this header.
Also, this should be part of the GenApi tool itself, as opposed to being a separate flag passed in.
|
I'm withdrawing my objection to the implementation change. It should be possible to set this command line option through the build targets. I maintain my objection to the rationale for the change. One case where this feature should not be used is for the situation described in the original post. If the tool is failing to generate the |
|
@sharwell : So you would suggest to change the tool itself to always add the autogenerated line at the top? For clients, that would even be less of a hassle then. |
|
@pgrawehr I see two options here:
Each option has advantages and disadvantages. Option 2 seems particularly safe and addresses the needs of most users without requiring other changes. |
|
Option 2 sounds ok for me. I'll try to provide something. |
|
Awesome! FWIW, historically this comment was generated with the following form: //------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// GenAPI Version: <Version>
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------The only part that the tools actually look for is the sequence |
|
Yea, I've seen this before - I've even seen it being translated to the user's language (I tend to have all tools, even compilers installed in german). So I might need to search for the matching resource. |
|
📝 Translating the strings will cause problems in two cases:
💭 This may have been one of the reasons why the long comment was dropped. Not sure about that though. |
|
That's also what I've observed before 👀 |
This enables the usage of the --header-file arg from client build scripts
9d4d095 to
eea8fdf
Compare
|
@sharwell Added code to always include a header in the file, unless the user specifies its own (and as long as it's C#) |
|
@sharwell Any further work required? It would be good if this could be merged soon, as dotnet/iot depends on this working (or all the StyleCop stuff we've done over there will get broken again because the builds can't be enabled to fully test the rules) |
|
@pgrawehr it looks fine to me, but I'm not a maintainer on this repository so someone else will need to do the final review and merge. |
|
I think this looks fine though ASP.NET Core wouldn't use this because we use |
|
Looking... |
ericstj
left a comment
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.
LGTM, if someone happens to be broken by this, they can always pass an empty header.
GenApi now adds
"// <autogenerated ... />"at the top of the generated file. Optionally, adding an user-defined header is supported as well. This will disable StyleCop (and other code analysis tools) from checking the generated file (which will usually fail).