-
-
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
Upgrade to Castle Core 4.3.0 #623
Comments
Yes, please upgrate. In my case it is not even working with Castle Core 4.3.0 I get an exception in "Moq.CastleProxyFactory.CreateProxy" when using CC 4.3.0, With CC 4.2.1 it was working. |
I've neglected Moq 4 a little during the last few weeks, a new release is long overdue. I'll try to make this happen during the next few days. |
It would be great if you could provide a short but complete code example that reproduces the issue you're having. That way, I could validate the upgraded version of Moq even better before I push it to NuGet. |
@zplan - I've just pushed Moq 4.8.3 to NuGet. It's configured to depend on Castle.Core 4.3.0. |
@stakx : Thanks for the release. Do you have any idea when you see this stack trace: System.ArgumentException: Constant does not match the defined type.. Update: |
@zplan: Please provide a code example. Either here or over in your issue at Castle.Core. I know the code in question that triggers the exception (I wrote it) but to understand why, I'd need to see what type you're trying to mock and what .nET runtime you're running on. |
@stakx : Thanks for your fast reply. It is not so easy to provide code to reproduce the issue but what I see when I debug into CastleCore is: Framework: .net461 I have an interface like:
Attributes: 454 } System.Reflection.Emit.MethodBuilder
to.SetConstant(defaultValue); |
@zplan, unfortunately, this is an absolutely essential step. There's nothing much I can do to help otherwise. |
@zplan, two simple questions:
|
@stakx : Thanks for your feedback. To 2: |
@zplan: awesome, thanks. Then I think I know what the problem is. I'm already working on a fix, you can follow progress over at the Castle.Core repo. A new release is being discussed currently. |
@stakx Great!!! Looking forward for the new release :) |
@zplan - It's pretty involved, but I'll try to summarise. Basically, in IL metadata, there are two mechanisms that can be used to record an optional parameter's default value.
System.Reflection and System.Reflection.Emit tries to hide that distinction from you, but does a pretty poor job. When you query Reflection also converts values automatically to the right target type, but only in some instances. In others, querying the default value will give you the value as recorded, and you can observe that it doesn't match the actual parameter type. So basically, Reflection is pretty broken in that regard. DynamicProxy tries hard to work around all the limitations in Reflection, which have been documented and even reported to the Mono & CLR team recently. What must be going wrong in your case is that there's a metadata entry of IL type If you want to know more, I'd like to direct you to this section of code—read on from there: |
Castle Core 4.3.0 has been published earlier today (see castleproject/Core#354 (comment)). Moq should upgrade its dependency because that'll enable:
in
parameter modifiers on .NET CoreThe text was updated successfully, but these errors were encountered: