Prioritise typed overloads in commands
See original GitHub issueRight now our command system has an issue with multiple overloads:
[Command("a")]
public async Task OverloadedCommand(IUserMessage message, int argument)
[Command("a")]
public async Task OverloadCommand(IUserMessage message, string argument)
Since these overloads do not get prioritised based on what arguments were provided, the overload with the string parameter may get invoked instead of the overload with the integer parameter, but never the other way around.
One solution for this, as foxbot suggested, would be to add a ‘Priority’ attribute, to prioritise commands manually. Another solution would be to use the data provided by the type readers to choose the best overload to invoke.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Overload selection should prioritise specificity, where ...
Ideally, I the generic type should be suggested first so the user knows that any number can be accepted as a parameter, and...
Read more >C++ function overload priority [duplicate]
This happens because the compiler will prefer built-in conversions to user-defined conversions. The conversion from a pointer to a bool is ...
Read more >"Overload of commands?" :: RimWorld Общие обсуждения
The game has something like 15 different types of hauling job priorities, from hauling corpses (which is quite high) to merging stacks (quite...
Read more >UI Copy: UX Guidelines for Command Names and ...
Use just enough text to accurately describe the command and include no more than 2–4 words. Avoid overexplaining commands and remove articles (“ ......
Read more >[Chapter 25] 25.2 Overload Attacks - Litux
25.2 Overload Attacks. In an overload attack, a shared resource or service is overloaded with requests to such a point that it's unable...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Basically I’m thinking:
[Priority]
manuallystring
parameter the lowest priority (if that exists), which could at least take care of the simplest case (which is the example given)Also:
[Priority]
set and another doesn’t?[Priority]
value set?Right now I’m not sure how to implement the consideration for typed properties over untyped properties but implementing a PriorityAttribute should be fairly simple.