From f797a23fbde3bc13c3309401a1c2e843d1b72ba0 Mon Sep 17 00:00:00 2001 From: Jonathan Pobst Date: Tue, 5 Jan 2021 10:29:45 -0600 Subject: [PATCH] [generator] Ensure DIM from Cecil imported references get correctly marked. --- .../CecilApiImporter.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tools/generator/Java.Interop.Tools.Generator.Importers/CecilApiImporter.cs b/tools/generator/Java.Interop.Tools.Generator.Importers/CecilApiImporter.cs index 1cfa86492..d7df3baee 100644 --- a/tools/generator/Java.Interop.Tools.Generator.Importers/CecilApiImporter.cs +++ b/tools/generator/Java.Interop.Tools.Generator.Importers/CecilApiImporter.cs @@ -191,7 +191,7 @@ public static Method CreateMethod (GenBase declaringType, MethodDefinition m) IsAbstract = m.IsAbstract, IsAcw = reg_attr != null, IsFinal = m.IsFinal, - IsInterfaceDefaultMethod = GetJavaDefaultInterfaceMethodAttribute (m.CustomAttributes) != null, + IsInterfaceDefaultMethod = IsDefaultInterfaceMethod (declaringType, m), IsReturnEnumified = GetGeneratedEnumAttribute (m.MethodReturnType.CustomAttributes) != null, IsStatic = m.IsStatic, IsVirtual = m.IsVirtual, @@ -248,5 +248,16 @@ static string GetObsoleteComment (CustomAttribute attribute) => static CustomAttribute GetRegisterAttribute (Collection attributes) => attributes.FirstOrDefault (a => a.AttributeType.FullNameCorrected () == "Android.Runtime.RegisterAttribute"); + + static bool IsDefaultInterfaceMethod (GenBase declaringType, MethodDefinition method) + { + if (!(declaringType is InterfaceGen)) + return false; + + if (GetJavaDefaultInterfaceMethodAttribute (method.CustomAttributes) != null) + return true; + + return !method.IsAbstract && !method.IsStatic; + } } }