-
Notifications
You must be signed in to change notification settings - Fork 480
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
Parser.ParseArguments(factory, args) requires parameterless constructor #70
Comments
Comment by nemec I can't speak to the reasoning behind the decision, since I didn't write the code, but they both look like oversights to me. If you want to submit a pull request, I'll merge it. |
Comment by Virtlink I can fix the first by removing the |
Comment by JeanSebTr I had the same problem and another fix was necessary (https://github.com/Emergensys/commandline/commit/813766d255b6ad75031655482b8e117fdaec0dc7) to use a factory for a type without parameter less constructor. I'll check to clean that up and make a pull request (I've also added factory support to multi verb https://github.com/Emergensys/commandline/commit/2ebe156199f8bad3c0155c8c415e3363949941ff), but I'm a bit lost in the functional style. |
Comment by CreepyGnome Doing some digging into the code and unit tests it looks like it is safe to remove the where statement from the ParseArguments that takes a factory Func and it should not be added to the ParseArguments that takes only the args. Basically all the ParseArguments should not have a where statement on them. Explanation of why I think this: If anyone disagrees and thinks it is not safe to remove the one where statement mentioned above let me know, otherwise I will submit a pull request for this issue. |
* Remove constraint on T for ParseArguments with factory * Make it possible to use factory for classes without public empty constructor * Allow types with explicitly defined interface implementations * Add test for #70 * Make sure explicit interface implementations can be parsed * Add test to make sure parser can detect explicit interface implementations
* Remove constraint on T for ParseArguments with factory * Make it possible to use factory for classes without public empty constructor * Allow types with explicitly defined interface implementations * Add test for #70 * Make sure explicit interface implementations can be parsed * Add test to make sure parser can detect explicit interface implementations
Issue by Virtlink
Sunday Apr 24, 2016 at 11:12 GMT
Originally opened as gsscoder/commandline#310
The
Parser.ParseArguments()
overloads with a factory function has this signature:If I provide my own factory function, why does
T
need to have a public parameterless constructor (new()
)?And on the other hand, why doesn't the non-factory overload of
ParseArguments
not require a public parameterless constructor? This will cause a runtime-exception whenT
doesn't have a public parameterless constructor.The text was updated successfully, but these errors were encountered: