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.

Remove generic class constraint on ICommandBus.Invoke

See original GitHub issue

Currently the ICommandBus.Invoke<T>() method has a generic constraint requiring T to be a class. This seems to be only to help simplify the casting of the return value as the method’s return is:

   return result as T;

This limits the usefulness as, for performance reasons, many return values are struct results.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jeremydmillercommented, Nov 22, 2019

Just like you said, was only because of the casting mechanics. I’m getting this right now.

0reactions
jeremydmillercommented, Mar 25, 2020

I don’t know why it would have Mark, and there is a test for using structs as messages. If it is, I’m happy to take a PR

Read more comments on GitHub >

github_iconTop Results From Across the Web

is it safe to remove a generic type constraint?
Adding and removing generic constraints is allways a breaking change as you´re adding/removing methods from the API that are used within ...
Read more >
Constraints on type parameters - C# Programming Guide
The constraint enables the generic class to use the Employee.Name property. The constraint specifies that all items of type T are guaranteed to ......
Read more >
[Proposal] C# generic constraint (where TSelf : ...
Having access to TSelf to constrain generic method parameters is a scenario I've wished for a few times - this can sometimes be...
Read more >
Generics: in, out, where
First, generic types in Java are invariant, meaning that List<String> is not a subtype of List<Object> . If List were not invariant, ...
Read more >
Overloading and generic constraints - Jon Skeet's coding blog
Broadly speaking, this defines the process for choosing which method to invoke as: Find a set of candidate methods; Remove methods which ...
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