Remove generic class constraint on ICommandBus.Invoke
See original GitHub issueCurrently 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:
- Created 4 years ago
- Comments:8 (5 by maintainers)
Top 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 >
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 Free
Top 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
Just like you said, was only because of the casting mechanics. I’m getting this right now.
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