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

Ignore CallBase for members of additional interfaces #583

Merged
merged 3 commits into from
Jan 25, 2018

Conversation

stakx
Copy link
Contributor

@stakx stakx commented Jan 25, 2018

This fixes #582. (See commit messages for details.)

`CallBase` currently tries to call the base method implementation even
for methods of additional interfaces (i. e. interfaces that were added
to the proxy using `.As<TInterface>()` that the base class does not
implement).
For explicitly implemented interfaces aka `.As<TInterface>()`, there
are actually two subcases to consider wrt to `CallBase`: Reimplemented
and additional interfaces. For the latter, the base class will never
have an implementation, we need to add a check for that.
@stakx stakx merged commit 60e9b18 into devlooped:master Jan 25, 2018
@stakx stakx deleted the callbase branch January 25, 2018 07:48
// Only call base method if it isn't an event accessor.
if (!method.LooksLikeEventAttach() && !method.LooksLikeEventDetach())

if (mock.InheritedInterfaces.Contains(declaringType))
{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to add a Debug.Assert(!method.IsAbstract) here someday.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NotImplementedException DynamicProxy2 error when CallBase = true while mocking interfaces again
1 participant