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.

Add generic overload for `IFakeOptionsBuilder<T>.Implements`

See original GitHub issue

Currently, to implement an additional interface on a fake, we have to write this:

A.Fake<IFoo>(o => o.Implements(typeof(IBar))

It would be more convenient to write it like this:

A.Fake<IFoo>(o => o.Implements<IBar>())

It’s a minor change, but it contributes to make the API more fluent IMO.

The only drawback is that this overload has to be added to the IFakeOptionsBuilder<T> interface, it can’t be an extension method. The reason is that the extension method would need to have 2 type parameters, and since it’s not possible to specify only one and let the compiler infer the other, we would have to specify both explicitly.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
blairconradcommented, May 25, 2016

@thomaslevesque, thanks very much for your work on this issue. Don’t bother looking for your name in the release notes. 🔑

This issue has been fixed in release 2.0.0.

0reactions
blairconradcommented, May 26, 2016

@thomaslevesque, I was wondering if you were going to catch that. I did feel bad that you didn’t make it onto the list, but I thought it would also look a little funny. That’s the price you pay for power, I guess.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Overloading generic methods
My suggestion to resolve that would be to define a generic interface ISaver<in T> with a non-generic method DoSave(T param) . Have the...
Read more >
TypeScript — Generics and overloads
To overcome this problem, we're gonna use generics. Using Generic types. In languages like C# and Java, one of the main tools in...
Read more >
1136 – Overloading a Generic Method
In the same way that you can overload a generic class, you can overload a generic method, defining multiple generic methods having the...
Read more >
Generic traits as an alternative to method overloading : r/rust
I think its a great technique and implementing it really helps understand how traits work. It definitely helped clean up my maths operations....
Read more >
proposal: spec: allow overloading generic functions strictly ...
This proposal suggests introducing support for function overloading with generic constraints in the Go programming language. The goal is to ...
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