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
Generic method with differently named generic arguments to parent throws KeyNotFoundException #106
Comments
For more info on change, why test failed and how to avoid it again see: castleproject/Core#106
Hey @HelloKitty Is this still an issue or was that MOQ specific? |
Also, if it's not and it's still an issue, can you elaborate on when the issue occurs. Posting a failing test would help. |
Based on other non-Castle GitHub issues others have linked here the problem is as the test below highlights, the interface and implementation generic arguments must have the same name otherwise DynamicProxy breaks: public interface ITest
{
void Hi<T>();
}
public class Test : ITest
{
public void Hi<T2>()
{
}
}
[Test]
public void GenericMethodDifferentlyNamedGenericArguments()
{
generator.CreateClassProxy(typeof(Test), new[] { typeof(ITest) }, new DoNothingInterceptor());
} Failure:
|
Since this is a long standing defect and has a workaround, I'm removing it from the v4.0 milestone. |
Issue: Throws KeyNotFoundException in https://github.com/castleproject/Core/blob/master/src/Castle.Core/DynamicProxy/Generators/Emitters/AbstractTypeEmitter.cs at method public Type[] GetGenericArgumentsFor(MethodInfo genericMethod)
Conditions: When Type name of generic type doesn't match the name of the Type in an interface.
Workaround: Change any generic Type names to match the name on the source interface.
This happens in Mono and .Net. If a generic method's generic Type name mismatches with its implemented name then this throws in Moq.
Original issues incorrectly posted on Moq's GitHub: here
The text was updated successfully, but these errors were encountered: