question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Prioritise typed overloads in commands

See original GitHub issue

Right 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:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Joe4evrcommented, Sep 1, 2016

Basically I’m thinking:

  • A user can specify a [Priority] manually
  • If lacking the attribute, the lib implicitly rates an overload with a string parameter the lowest priority (if that exists), which could at least take care of the simplest case (which is the example given)

Also:

  • What should happen if one overload has a [Priority] set and another doesn’t?
  • What should happen if multiple overloads have the same [Priority] value set?
0reactions
FiniteRealitycommented, Sep 15, 2016

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found