-
-
Notifications
You must be signed in to change notification settings - Fork 798
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
WindsorContainer UsingFactoryMethod broken on upgrade to 4.8.0+ #608
Comments
This might be related to #551, which the changelog entry for 4.8.0 only mentions indirectly (emphasis added):
PR #551 changed the way how Moq creates DynamicProxy proxy objects for interface types. Moq used DynamicProxy's Apart from that, your issue appears to be one with Castle—the error message clearly isn't coming from Moq. I am not familiar with the Castle APIs that you are using. I suggest you do either of the following:
|
Oh btw. I think you can approximate what previous versions of Moq did by changing your code to this: .UsingFactoryMethod(() => new Mock<object>().As<ILogger>().Object)) This might make your code work with Moq 4.8.x, if it worked previously with Moq 4.7.x. |
I suspect you're probably right about the issue being related to #551 - the exception being thrown does sound closely tied to I'll discuss with my team whether we settle on one of the workarounds (your suggestion works, thank you), stick with 4.7.145, or give 5 a test - will keep an eye out for that either way. Thanks! |
Hi,
I'm in the process of updating Nuget packages in our solution and have come across a problem updating to newer versions of Moq (4.8.0+). For background, we were running on 4.7.99 and jumped to 4.8.2, but I've narrowed the issue down to the move from 4.7.145 -> 4.8.0.
Code such as the following:
Generates the exception:
I've dug into the Castle and Moq source as much as I can, but it's a bit beyond me without spending significantly more time on it. The exception is being thrown in
Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.ApplyCommissionConcerns
.There are a couple of ways I can work around the issue - change the registration to
.Instance(new Mock<ILogger>().Object)
for example, or use theUsingFactoryMethod
overload and settingmanagedExternally
to true, but the first potentially causes slightly different behaviour to our 'real' code, and I don't fully understand the impact of the second - plus it means finding and remembering to do this everywhere we want to use a Mock object in this way.I'm not entirely sure which change caused this behaviour - I thought at first it was related to #476 but the issue doesn't exist in v4.8.0-rc1, so #550 seems like a more likely candidate.
The text was updated successfully, but these errors were encountered: