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
Rework command result logic #632
Comments
Why do TypeReaders implement IResult? If we want to improve the general use-case for result types we have to ask how they are currently used and what (real!) use-cases we could imagine / foresee in the future, I think changing from struct to class is pretty straightforward in terms of "should we or should we not". |
TypeReaders use IResult because they are returned as part of ExecuteAsync, which returns an IResult. As for returning a TypeReaderResult, it's often nice to be able to see why an overload failed to parse. (e.g. passing an invalid channel in ChannelTypeReader) If users return null, I believe it would be best to let them handle it since I want to modify result types to not take other IResults to clean up our code a bit, so we won't be doing any processing of IResults except in ExecuteAsync. I agree with caching return types too, but instead of caching them in their type reader, we should instead provide a static property on the default type readers for successful results. |
I believe there was talk about this before, but perhaps allow for commands to return |
Yes, this was being handled in #466 but I believe the general consensus from Volt/Fox was that it wasn't really important or necessary. If you'd like to convince them otherwise, feel free to give a solid use case for the feature. |
Good luck, we've been encouraging users to do a lot of things, to very little avail. Switching result types to classes now would cause PEBKAC user reports until we get analyzers shipped with the lib itself.
Another reason why I feel we shouldn't do this just yet. At the very least, this one could be solved if the C# Language team manages to implement their "nullable reference types" static analysis sooner rather than later. |
This actually isn't that hard: for results that need no arguments, we can provide static members (e.g.
I'm currently leaning on a "treat null returns as an unknown error" approach because it makes our code easier, and I haven't really seen any reason why I shouldn't do it this way. |
After a small experiment, this can work, even with polymorphism in the mix. The hard part at that point is needing to tell users to supply their own static member if they were to sub-class an existing result type.
Okay, that's fair. |
I'll use this issue to track the status of result logic in commands. Please discuss changes that you would like to be made here.
The text was updated successfully, but these errors were encountered: