Skip to content

Commit 9c58968

Browse files
committed
Exclude non-proxyable interface methods
Two changes need to be made to `InterfaceMembersCollector`: 1. `AcceptMethod` needs to be called with `onlyVirtuals: true`, so that it will filter out non-overridable methods during pre-screening. 2. For such filtered-out methods, it needs to return `null` in order to avoid `MinimalisticMethodGenerator` (which would mark the method it creates as an override). These changes have been copied from `ClassMembersCollector`. Note that the two classes are now almost identical.
1 parent 0fc266e commit 9c58968

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Castle.Core/DynamicProxy/Contributors/InterfaceMembersCollector.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,13 @@ protected override MetaMethod GetMethodToGenerate(MethodInfo method, IProxyGener
3333
return null;
3434
}
3535

36-
var proxyable = AcceptMethod(method, false, hook);
36+
var proxyable = AcceptMethod(method, true, hook);
37+
if (!proxyable && !method.IsAbstract)
38+
{
39+
// we don't need to do anything
40+
return null;
41+
}
42+
3743
return new MetaMethod(method, method, isStandalone, proxyable, false);
3844
}
3945
}

0 commit comments

Comments
 (0)