Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit 50cee72

Browse files
committed
mapper: Correct GetInterfaceType(Type,string)
In recent commits I had neglected to consider that some users of dbus-sharp will be subclassing MarshalByRefObject. This commit corrects that, adding a simple GetHierarchy function to return the type and its ancestors.
1 parent 7ac412e commit 50cee72

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/ExportObject.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public MethodCaller GetPropertyAllCall (string iface)
7070

7171
if (null == calls.All) {
7272
Type it = Mapper.GetInterfaceType (ObjectType, iface);
73-
calls.All = null == it ? null : TypeImplementer.GenGetAllCall (it);
73+
calls.All = TypeImplementer.GenGetAllCall (it);
7474
}
7575

7676
return calls.All;

src/Mapper.cs

+16-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,22 @@ public static string GetArgumentName (ICustomAttributeProvider attrProvider, str
3737

3838
public static Type GetInterfaceType(Type type, string iface)
3939
{
40-
return type.GetInterfaces ().FirstOrDefault (x => iface == GetInterfaceName (x));
40+
return type.GetInterfaces()
41+
.Concat(GetHierarchy(type))
42+
.FirstOrDefault (x => iface == GetInterfaceName (x));
43+
}
44+
45+
private static IEnumerable<Type> GetHierarchy(Type type)
46+
{
47+
if (IsPublic (type)) {
48+
yield return type;
49+
}
50+
51+
foreach (var super in GetHierarchy (type.BaseType)) {
52+
if (IsPublic (type)) {
53+
yield return super;
54+
}
55+
}
4156
}
4257

4358
public static IEnumerable<PropertyInfo> GetPublicProperties (Type type)

0 commit comments

Comments
 (0)