diff --git a/CHANGELOG.md b/CHANGELOG.md index dbad1a682..5a7cc57f8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,9 @@ The format is loosely based on [Keep a Changelog](http://keepachangelog.com/en/1 * Update package reference to `Castle.Core` (DynamicProxy) from version 4.3.0 to 4.3.1 (@stakx, #635) * Floating point values are formatted with higher precision (satisfying round-tripping) in diagnostic messages (@stakx, #637) +#### Fixed + +* `CallBase` disregarded for some base methods from non-public interfaces (@stakx, #641) #### Obsoleted diff --git a/Source/Mock.Generic.cs b/Source/Mock.Generic.cs index 84b185cc0..ea681def8 100644 --- a/Source/Mock.Generic.cs +++ b/Source/Mock.Generic.cs @@ -69,7 +69,7 @@ static Mock() inheritedInterfaces = typeof(T) .GetInterfaces() - .Where(i => { var it = i.GetTypeInfo(); return it.IsPublic || it.IsNestedPublic && !it.IsImport; }) + .Where(i => ProxyFactory.Instance.IsTypeVisible(i) && !i.GetTypeInfo().IsImport) .ToArray(); serialNumberCounter = 0; diff --git a/Source/ProxyFactories/CastleProxyFactory.cs b/Source/ProxyFactories/CastleProxyFactory.cs index 9eb9e8131..5d0d72bb8 100644 --- a/Source/ProxyFactories/CastleProxyFactory.cs +++ b/Source/ProxyFactories/CastleProxyFactory.cs @@ -122,6 +122,11 @@ public override bool IsMethodVisible(MethodInfo method, out string messageIfNotV return ProxyUtil.IsAccessible(method, out messageIfNotVisible); } + public override bool IsTypeVisible(Type type) + { + return ProxyUtil.IsAccessible(type); + } + /// public override Type GetDelegateProxyInterface(Type delegateType, out MethodInfo delegateInterfaceMethod) { diff --git a/Source/ProxyFactories/ProxyFactory.cs b/Source/ProxyFactories/ProxyFactory.cs index 9b1148da9..71c81c39a 100644 --- a/Source/ProxyFactories/ProxyFactory.cs +++ b/Source/ProxyFactories/ProxyFactory.cs @@ -54,6 +54,8 @@ internal abstract class ProxyFactory public abstract bool IsMethodVisible(MethodInfo method, out string messageIfNotVisible); + public abstract bool IsTypeVisible(Type type); + /// /// Gets an autogenerated interface with a method on it that matches the signature of the specified /// .