Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Data/Transaction/Interceptor
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv27343/src/Spring/Spring.Data/Transaction/Interceptor
Modified Files:
AbstractFallbackTransactionAttributeSource.cs
MethodMapTransactionAttributeSource.cs
Log Message:
ReflectionUtils.getMostSpecificMethod() throws exception when handling Generic methods with the same parameter signature and different generic types
[SPRNET-722]
Index: MethodMapTransactionAttributeSource.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Data/Transaction/Interceptor/MethodMapTransactionAttributeSource.cs,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** MethodMapTransactionAttributeSource.cs 17 Sep 2007 19:16:05 -0000 1.10
--- MethodMapTransactionAttributeSource.cs 20 Sep 2007 12:31:01 -0000 1.11
***************
*** 28,31 ****
--- 28,32 ----
using Spring.Util;
using Spring.Core.TypeResolution;
+ using Spring.Core;
#endregion
***************
*** 239,252 ****
//Might have registered MethodInfo objects whose declaring type is the interface, so 'downcast'
//to the most specific method which is typically what is passed in as the first method argument.
! foreach (DictionaryEntry dictionaryEntry in _methodMap)
! {
! MethodInfo specificMethod =
! ReflectionUtils.GetMostSpecificMethod((MethodInfo) dictionaryEntry.Key, targetType);
! if (method == specificMethod)
{
! return (ITransactionAttribute) dictionaryEntry.Value;
}
! }
return (ITransactionAttribute)_methodMap[method];
}
--- 240,284 ----
//Might have registered MethodInfo objects whose declaring type is the interface, so 'downcast'
//to the most specific method which is typically what is passed in as the first method argument.
! foreach (DictionaryEntry dictionaryEntry in _methodMap)
! {
! MethodInfo currentMethod = (MethodInfo)dictionaryEntry.Key;
!
! MethodInfo specificMethod;
! if (targetType == null)
{
! specificMethod = currentMethod;
! }
! else
! {
! ComposedCriteria searchCriteria = new ComposedCriteria();
! searchCriteria.Add(new MethodNameMatchCriteria(currentMethod.Name));
! searchCriteria.Add(new MethodParametersCountCriteria(currentMethod.GetParameters().Length));
! #if NET_2_0
! searchCriteria.Add(new MethodGenericArgumentsCountCriteria(
! currentMethod.GetGenericArguments().Length));
! #endif
! searchCriteria.Add(new MethodParametersCriteria(ReflectionUtils.GetParameterTypes(currentMethod)));
!
! MemberInfo[] matchingMethods = targetType.FindMembers(
! MemberTypes.Method,
! BindingFlags.Instance | BindingFlags.Public,
! new MemberFilter(new CriteriaMemberFilter().FilterMemberByCriteria),
! searchCriteria);
!
! if (matchingMethods != null && matchingMethods.Length == 1)
! {
! specificMethod = matchingMethods[0] as MethodInfo;
! }
! else
! {
! specificMethod = currentMethod;
! }
}
! if (method == specificMethod)
! {
! return (ITransactionAttribute)dictionaryEntry.Value;
! }
! }
return (ITransactionAttribute)_methodMap[method];
}
Index: AbstractFallbackTransactionAttributeSource.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Data/Transaction/Interceptor/AbstractFallbackTransactionAttributeSource.cs,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** AbstractFallbackTransactionAttributeSource.cs 28 Jan 2007 20:12:33 -0000 1.7
--- AbstractFallbackTransactionAttributeSource.cs 20 Sep 2007 12:31:01 -0000 1.8
***************
*** 22,27 ****
--- 22,29 ----
using System.Collections;
using System.Reflection;
+
using Spring.Collections;
using Spring.Util;
+ using Spring.Core;
namespace Spring.Transaction.Interceptor
***************
*** 231,249 ****
}
! private ITransactionAttribute computeTransactionAttribute(MethodInfo method, Type targetType)
! {
! MethodInfo specificMethod = ReflectionUtils.GetMostSpecificMethod(method, targetType);
! ITransactionAttribute transactionAttribute = getTransactionAttribute(specificMethod);
! if (null != transactionAttribute)
! {
! return transactionAttribute;
! }
! else if (specificMethod != method)
! {
! transactionAttribute = getTransactionAttribute(method);
! }
! return null;
! }
private ITransactionAttribute getTransactionAttribute(MethodInfo methodInfo)
--- 233,281 ----
}
! private ITransactionAttribute computeTransactionAttribute(MethodInfo method, Type targetType)
! {
! MethodInfo specificMethod;
! if (targetType == null)
! {
! specificMethod = method;
! }
! else
! {
! ComposedCriteria searchCriteria = new ComposedCriteria();
! searchCriteria.Add(new MethodNameMatchCriteria(method.Name));
! searchCriteria.Add(new MethodParametersCountCriteria(method.GetParameters().Length));
! #if NET_2_0
! searchCriteria.Add(new MethodGenericArgumentsCountCriteria(
! method.GetGenericArguments().Length));
! #endif
! searchCriteria.Add(new MethodParametersCriteria(ReflectionUtils.GetParameterTypes(method)));
! MemberInfo[] matchingMethods = targetType.FindMembers(
! MemberTypes.Method,
! BindingFlags.Instance | BindingFlags.Public,
! new MemberFilter(new CriteriaMemberFilter().FilterMemberByCriteria),
! searchCriteria);
!
! if (matchingMethods != null && matchingMethods.Length == 1)
! {
! specificMethod = matchingMethods[0] as MethodInfo;
! }
! else
! {
! specificMethod = method;
! }
! }
!
! ITransactionAttribute transactionAttribute = getTransactionAttribute(specificMethod);
! if (null != transactionAttribute)
! {
! return transactionAttribute;
! }
! else if (specificMethod != method)
! {
! transactionAttribute = getTransactionAttribute(method);
! }
! return null;
! }
private ITransactionAttribute getTransactionAttribute(MethodInfo methodInfo)
|