Skip to content

Commit

Permalink
Merge pull request #641 from stakx/callbase
Browse files Browse the repository at this point in the history
Don't ignore non-public interfaces unconditionally
  • Loading branch information
stakx committed Jul 13, 2018
2 parents 737a960 + 420d9e7 commit 2aa193a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion Source/Mock.Generic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions Source/ProxyFactories/CastleProxyFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/// <inheritdoc />
public override Type GetDelegateProxyInterface(Type delegateType, out MethodInfo delegateInterfaceMethod)
{
Expand Down
2 changes: 2 additions & 0 deletions Source/ProxyFactories/ProxyFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ internal abstract class ProxyFactory

public abstract bool IsMethodVisible(MethodInfo method, out string messageIfNotVisible);

public abstract bool IsTypeVisible(Type type);

/// <summary>
/// Gets an autogenerated interface with a method on it that matches the signature of the specified
/// <paramref name="delegateType"/>.
Expand Down

0 comments on commit 2aa193a

Please sign in to comment.