Skip to content

Commit e41315c

Browse files
committed
Exclude non-overridable methods from collection
`sealed` methods do not show up in interface mappings, so make sure `InterfaceMembersWithDefaultImplementationCollector` can deal with them anyway in case of interfaces that contain both `sealed` methods as well as overridable ones with a default implementation.
1 parent 982f5ff commit e41315c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,13 @@ public InterfaceMembersWithDefaultImplementationCollector(Type interfaceType, Ty
3838

3939
protected override MetaMethod GetMethodToGenerate(MethodInfo method, IProxyGenerationHook hook, bool isStandalone)
4040
{
41-
if (method.IsAbstract)
41+
if (method.IsAbstract || method.IsFinal || method.IsVirtual == false)
4242
{
43-
// This collector is only interested in methods with default implementations.
43+
// This collector is only interested in overridable methods with default implementations.
4444
// All other interface methods should be dealt with in other contributors.
45+
//
46+
// (Note this is the opposite check of that in `TypeUtil.HasAnyOverridableDefaultImplementations`,
47+
// which is the method used to filter out whole interfaces before this collector gets run for them.)
4548
return null;
4649
}
4750

0 commit comments

Comments
 (0)