diff --git a/src/Java.Interop/Java.Interop/JniRuntime.JniValueManager.cs b/src/Java.Interop/Java.Interop/JniRuntime.JniValueManager.cs index 8c4b27c28..6e7b4a7ea 100644 --- a/src/Java.Interop/Java.Interop/JniRuntime.JniValueManager.cs +++ b/src/Java.Interop/Java.Interop/JniRuntime.JniValueManager.cs @@ -527,6 +527,20 @@ public JniValueMarshaler GetValueMarshaler (Type type) if (typeof (IJavaPeerable).GetTypeInfo ().IsAssignableFrom (info)) { return JavaPeerableValueMarshaler.Instance; } + + JniValueMarshalerAttribute ifaceAttribute = null; + foreach (var iface in info.ImplementedInterfaces) { + marshalerAttr = iface.GetTypeInfo ().GetCustomAttribute (); + if (marshalerAttr != null) { + if (ifaceAttribute != null) + throw new NotSupportedException ($"There is more than one interface with custom marshaler for type {type}."); + + ifaceAttribute = marshalerAttr; + } + } + if (ifaceAttribute != null) + return (JniValueMarshaler) Activator.CreateInstance (ifaceAttribute.MarshalerType); + return GetValueMarshalerCore (type); }