@@ -21,6 +21,8 @@ namespace NHibernate.Proxy
21
21
{
22
22
internal static class ProxyBuilderHelper
23
23
{
24
+ private const BindingFlags ProxiableMethodsBindingFlags = BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Instance ;
25
+
24
26
private static readonly ConstructorInfo ObjectConstructor = typeof ( object ) . GetConstructor ( System . Type . EmptyTypes ) ;
25
27
private static readonly ConstructorInfo SecurityCriticalAttributeConstructor = typeof ( SecurityCriticalAttribute ) . GetConstructor ( System . Type . EmptyTypes ) ;
26
28
private static readonly ConstructorInfo IgnoresAccessChecksToAttributeConstructor = typeof ( IgnoresAccessChecksToAttribute ) . GetConstructor ( new [ ] { typeof ( string ) } ) ;
@@ -94,23 +96,20 @@ internal static void CallDefaultBaseConstructor(ILGenerator il, System.Type pare
94
96
95
97
internal static IEnumerable < MethodInfo > GetProxiableMethods ( System . Type type )
96
98
{
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 ( ) ) ;
101
100
}
102
101
103
102
internal static IEnumerable < MethodInfo > GetProxiableMethods ( System . Type type , IEnumerable < System . Type > interfaces )
104
103
{
105
104
if ( type . IsInterface || type == typeof ( object ) || type . GetInterfaces ( ) . Length == 0 )
106
105
{
107
106
return GetProxiableMethods ( type )
108
- . Concat ( interfaces . SelectMany ( i => i . GetMethods ( ) ) )
107
+ . Concat ( interfaces . SelectMany ( i => i . GetMethods ( ProxiableMethodsBindingFlags ) ) )
109
108
. Distinct ( ) ;
110
109
}
111
110
112
111
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 ) ) )
114
113
{
115
114
proxiableMethods . Add ( interfaceMethod ) ;
116
115
}
0 commit comments