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
Mock<T>.CallBase seems to be broken #640
Comments
Did you mean "upgrade to", or "upgrade from"? (If the former, please upgrade to the latest version, 4.8.3.) |
Sorry, I mixed up Castle.Core and Moq versions. We want 4.8.2, but I just reproduced this with 4.8.3. |
@fgreinacher - Thanks for providing a precise repro. I've been able to determine what's going on. The TL;DR version is that this is an old but bug that has only become noticeable after another old bug was fixed. I'm going to fix it. Read on if you're interested in the details. The problem you've noticed is the result of two aspects that have changed over time:
In other words, the code rewrite mentioned in (2) has uncovered an old shortcoming of (1). The fix required here is this: Instead of just looking at the interface's declared visibility, we should really be asking DynamicProxy, "Is this base interface visible to you?" If yes, let Moq see it; otherwise, exclude it. |
@fgreinacher - This should be fixed in the next version of Moq (4.9.0), which I have just published on NuGet. |
Thanks @stakx, I’ll test our real code with the new version on Monday. Thanks also for the detailed explanation! |
No worries. Please let me know whether 4.9.0 resolves your problem, or whether there are any remaining issues. |
@stakx Any way to get a „hotfix“ Release based on Moq 4.8.2 (something like 4.8.2.1)? We have to stick with Castle.Core 4.2.1 for process reasons and Moq 4.9 depends on a later Castle.Core version. |
@fgreinacher - I would really like to avoid doing such a hotfix release. If there were more Moq users with the same problem (not being able to upgrade to the latest Castle Core) I'd consider it, but if it's just you, you're perhaps better off working with a private fork of Moq where you downgrade Castle Core... or do some MSBuild fiddling where you replace the newer Castle Core version with the one you need. Is any of that feasible for you? |
Sure, that's fine. I forked from https://github.com/moq/moq4/releases/tag/v4.8.2 and backported your fix to https://github.com/fgreinacher/moq4/tree/v4.8.4 from which we'll build our private 4.8.4 👍 |
We are currently trying to upgrade to Moq 4.8.2 and we found several test failures around partial mocking of classes. Here is the repro:
I would expect that setting the
CallBase
property of the mock totrue
is the same as callingSetUp().CallBase
for every method. Is this assumption wrong or is this a regression?Update: Making the interface
public
fixes the problem (but that's no option for us)The text was updated successfully, but these errors were encountered: