@@ -21,6 +21,8 @@ namespace NHibernate.Proxy
2121{
2222 internal static class ProxyBuilderHelper
2323 {
24+ private const BindingFlags ProxiableMethodsBindingFlags = BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Instance ;
25+
2426 private static readonly ConstructorInfo ObjectConstructor = typeof ( object ) . GetConstructor ( System . Type . EmptyTypes ) ;
2527 private static readonly ConstructorInfo SecurityCriticalAttributeConstructor = typeof ( SecurityCriticalAttribute ) . GetConstructor ( System . Type . EmptyTypes ) ;
2628 private static readonly ConstructorInfo IgnoresAccessChecksToAttributeConstructor = typeof ( IgnoresAccessChecksToAttribute ) . GetConstructor ( new [ ] { typeof ( string ) } ) ;
@@ -94,23 +96,20 @@ internal static void CallDefaultBaseConstructor(ILGenerator il, System.Type pare
9496
9597 internal static IEnumerable < MethodInfo > GetProxiableMethods ( System . Type type )
9698 {
97- const BindingFlags candidateMethodsBindingFlags =
98- BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Instance ;
99-
100- return type . GetMethods ( candidateMethodsBindingFlags ) . Where ( m => m . IsProxiable ( ) ) ;
99+ return type . GetMethods ( ProxiableMethodsBindingFlags ) . Where ( m => m . IsProxiable ( ) ) ;
101100 }
102101
103102 internal static IEnumerable < MethodInfo > GetProxiableMethods ( System . Type type , IEnumerable < System . Type > interfaces )
104103 {
105104 if ( type . IsInterface || type == typeof ( object ) || type . GetInterfaces ( ) . Length == 0 )
106105 {
107106 return GetProxiableMethods ( type )
108- . Concat ( interfaces . SelectMany ( i => i . GetMethods ( ) ) )
107+ . Concat ( interfaces . SelectMany ( i => i . GetMethods ( ProxiableMethodsBindingFlags ) ) )
109108 . Distinct ( ) ;
110109 }
111110
112111 var proxiableMethods = new HashSet < MethodInfo > ( GetProxiableMethods ( type ) , new MethodInfoComparer ( type ) ) ;
113- foreach ( var interfaceMethod in interfaces . SelectMany ( i => i . GetMethods ( ) ) )
112+ foreach ( var interfaceMethod in interfaces . SelectMany ( i => i . GetMethods ( ProxiableMethodsBindingFlags ) ) )
114113 {
115114 proxiableMethods . Add ( interfaceMethod ) ;
116115 }
0 commit comments