-
Notifications
You must be signed in to change notification settings - Fork 259
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
Castle.DynamicProxy.ProxyGenerationException when creating mock. #585
Comments
Thanks for the brilliantly crafted scenario! @stakx Hey! If you have time these days, could you please take a look? It looks like a pure Castle issue, as we pass interfaces just as is (like Moq I believe). If you don’t have time - it’s totally OK, we could also investigate it ourselves. Thanks! |
@zvirja, thanks for the ping, I'll take a look and report what I find. |
We've fixed the root cause for this problem in DynamicProxy. Thank you all for bringing this to our attention! |
@compact-github could you tell what was wrong when you tried to install NSubstitute.Analyzers? |
Sure. Using Nuget Package manager I installed NSubstitute.Analyzers.CSharp package in version 1.0.10.
So I installed Microsoft.CodeAnalysis package in version 1.3.1. This installed also 18 additional packages.
I tried update Microsoft.CodeAnalysis to most recent version 3.2.1. Nothing changed, so I updated rest of the packages installed with Microsoft.CodeAnalyzers. Sorry for the delayed answer, but during weekend I was out of internet. |
@compact-github you most likely use Visual Studio version which is not compatible with the analyzers. Can you check if your Visual Studio falls into supported version range listed in docs? |
@tpodolak Yes, you are right. Visual Studio 2015 Express is not supported. Even Visual Studio 2015 is not supported. For me is not a problem. For noncommercial activity I can download more recent community version. In the company we have few full version Visual Studio licenses. I'm not full time c# developer so currently I don't have any and use old express version. |
Closing this due to inactivity. |
When creating mock using Substitute.For method got exception :
Castle.DynamicProxy.ProxyGenerationException: Duplicate element: Castle.DynamicProxy.Generators.MetaMethod.
To Reproduce
Create two identical interfaces with one identical method in two namespaces.
Inherit one of the interfaces and define the same method.
sample setup:
Try create mock using Substitute.For method like that:
firstNamespace.BaseObject1 mock = Substitute.For<firstNamespace.BaseObject1, SecondNamespace.BaseFolder1>();
At first attempt please use exactly the same name for namespaces and interfaces. Even small change eg. FirstNamespace instead of firstNamespace magically fixes this issue.
Expected behaviour
Allow creating mock for provided scenario.
Environment:
Additional context
Sample VS project reproducing the issue is attached here:
NSubstituteIssue.zip
Stack trace from exception:
The text was updated successfully, but these errors were encountered: