Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't ignore non-public interfaces unconditionally #641

Merged
merged 2 commits into from
Jul 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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