Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support calling default interface methods #1633

Open
thomaslevesque opened this issue Sep 29, 2019 · 1 comment

Comments

@thomaslevesque
Copy link
Member

commented Sep 29, 2019

C# 8 introduced the "default interface methods" feature, i.e. interface methods with a default implementation (this feature works only on .NET Core 3).

Currently it's not possible with FakeItEasy to make a fake that calls the default implementation. Using CallsBaseMethods doesn't work, because Castle.Core doesn't support this feature yet (castleproject/Core#447).

We should support default interface methods in FakeItEasy.

API options:

  • Reuse CallsBaseMethods() to call the default interface methods, in addition to what it currently does.
  • Introduce a new CallsDefaultImplementation() to cover that scenario. (Maybe use a more explicit name; "default implementation" could be misleading)

Implementation options:

  • Wait for Castle.Core to support it
  • Do it ourselves. Default interface methods are methods whose declaring type is an interface and have IsAbstract == false. We need to call them non-virtually (otherwise it would cause infinite recursion). POC implementation here.
@blairconrad

This comment has been minimized.

Copy link
Member

commented Oct 1, 2019

It might be a good idea to have a separate option from CallsBaseMethods, as it gives users additional flexibility.

Alternatively, if we end up thinking that we should default to using the default interface methods, we could add FakesDefaultInterfaceMethods or similar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.