You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ExtensionsForMethodInfo.GetPropertyFromMethod(Type t) is throwing an exception when called on a property getter.
The method name is returned as "IGenericStateSetter`1[Boolean].get_Value", therefore the substring(0,3) does not equal "get", as expected. Since it's a property getter method.GetParameterTypes() returns an empty list, so the call to Last() throws an invalid operation exception.
I'm not trying to intercept the method, but I presume a check is being performed as to whether it should be intercepted or not.
I'm also using a Ninject.MockingKernel to create test mocks for any missing bindings. (The issue happens regardless of which mocking framework is used, I think they all use Castle.Proxies)
I don't believe there's any way to specify not to try intercepting an activation?
The problem occurs for all explicitly implemented properties In this case, the name does not start with get because it will look like Full.Name.Of.Interface.Type.get_Property.
interfaceIInterface{intProperty{get;}}classClass:IInterface{intIInterface.Property=>-6;// crashpublicintProperty=>-6;// no crash}classProgram{staticvoidMain(){vart=typeof(Class);foreach(varmethodint.GetMethods(BindingFlags.Public|BindingFlags.NonPublic|BindingFlags.Instance)){Console.WriteLine($"Name: '{method.Name}'");Console.WriteLine(method.GetPropertyFromMethod(t));}}}
My first guess would be look for the last dot in Name first, and only then check for get prefix. Also, the length<4 condition must be revisited.
ExtensionsForMethodInfo.GetPropertyFromMethod(Type t)
is throwing an exception when called on a property getter.The method name is returned as "IGenericStateSetter`1[Boolean].get_Value", therefore the
substring(0,3)
does not equal "get", as expected. Since it's a property gettermethod.GetParameterTypes()
returns an empty list, so the call toLast()
throws an invalid operation exception.I'm not trying to intercept the method, but I presume a check is being performed as to whether it should be intercepted or not.
I'm also using a Ninject.MockingKernel to create test mocks for any missing bindings. (The issue happens regardless of which mocking framework is used, I think they all use Castle.Proxies)
I don't believe there's any way to specify not to try intercepting an activation?
Stack trace:
The text was updated successfully, but these errors were encountered: