diff --git a/tools/generator/Java.Interop.Tools.Generator.Importers/XmlApiImporter.cs b/tools/generator/Java.Interop.Tools.Generator.Importers/XmlApiImporter.cs index cd248a514..376dc3c9b 100644 --- a/tools/generator/Java.Interop.Tools.Generator.Importers/XmlApiImporter.cs +++ b/tools/generator/Java.Interop.Tools.Generator.Importers/XmlApiImporter.cs @@ -331,6 +331,10 @@ public static InterfaceGen CreateInterface (XElement pkg, XElement elem, CodeGen !options.SupportNestedInterfaceTypes }; + if (elem.Attribute ("skipInvokerMethods")?.Value is string skip) + foreach (var m in skip.Split (new char [] { ',', ' ', '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries)) + iface.SkippedInvokerMethods.Add (m); + FillApiSince (iface, pkg, elem); SetLineInfo (iface, elem, options); diff --git a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/ClassGen.cs b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/ClassGen.cs index 2ab4257ea..fca4acf47 100644 --- a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/ClassGen.cs +++ b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/ClassGen.cs @@ -11,7 +11,6 @@ namespace MonoDroid.Generation public class ClassGen : GenBase { bool fill_explicit_implementation_started; - HashSet skipped_invoker_methods; public List Ctors { get; private set; } = new List (); @@ -356,8 +355,6 @@ public override void ResetValidation () base.ResetValidation (); } - public HashSet SkippedInvokerMethods => skipped_invoker_methods ??= new HashSet (); - public override string ToNative (CodeGenerationOptions opt, string varname, Dictionary mappings = null) { if (opt.CodeGenerationTarget == CodeGenerationTarget.JavaInterop1) { diff --git a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/GenBase.cs b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/GenBase.cs index 488604e94..778f814f5 100644 --- a/tools/generator/Java.Interop.Tools.Generator.ObjectModel/GenBase.cs +++ b/tools/generator/Java.Interop.Tools.Generator.ObjectModel/GenBase.cs @@ -17,6 +17,7 @@ public abstract class GenBase : IGeneratable, ApiVersionsSupport.IApiAvailabilit protected bool iface_validation_failed; protected GenBaseSupport support; protected bool validated = false; + HashSet skipped_invoker_methods; readonly List implemented_interfaces = new List (); readonly Dictionary jni_sig_hash = new Dictionary (); @@ -854,6 +855,8 @@ bool ReturnTypeMatches (Method m, Method mm) public bool ShouldGenerateAnnotationAttribute => IsAnnotation; + public HashSet SkippedInvokerMethods => skipped_invoker_methods ??= new HashSet (); + public void StripNonBindables (CodeGenerationOptions opt) { // Strip out default interface methods if not desired diff --git a/tools/generator/SourceWriters/InterfaceInvokerClass.cs b/tools/generator/SourceWriters/InterfaceInvokerClass.cs index d5a003c23..23233de4d 100644 --- a/tools/generator/SourceWriters/InterfaceInvokerClass.cs +++ b/tools/generator/SourceWriters/InterfaceInvokerClass.cs @@ -69,7 +69,7 @@ public InterfaceInvokerClass (InterfaceGen iface, CodeGenerationOptions opt, Cod Constructors.Add (new InterfaceInvokerConstructor (opt, iface, context)); - AddMemberInvokers (iface, new HashSet (), opt, context); + AddMemberInvokers (iface, new HashSet (), iface.SkippedInvokerMethods, opt, context); } static HashSet GetCompleteImplementedInterfaces (HashSet ifaces, InterfaceGen toplevel) @@ -81,15 +81,15 @@ static HashSet GetCompleteImplementedInterfaces (HashSet members, CodeGenerationOptions opt, CodeGeneratorContext context) + void AddMemberInvokers (InterfaceGen iface, HashSet members, HashSet skipInvokers, CodeGenerationOptions opt, CodeGeneratorContext context) { AddPropertyInvokers (iface, iface.Properties.Where (p => !p.Getter.IsStatic && !p.Getter.IsInterfaceDefaultMethod), members, opt, context); - AddMethodInvokers (iface, iface.Methods.Where (m => !m.IsStatic && !m.IsInterfaceDefaultMethod), members, opt, context); + AddMethodInvokers (iface, iface.Methods.Where (m => !m.IsStatic && !m.IsInterfaceDefaultMethod), members, skipInvokers, opt, context); AddCharSequenceEnumerators (iface); foreach (var i in iface.GetAllDerivedInterfaces ()) { AddPropertyInvokers (iface, i.Properties.Where (p => !p.Getter.IsStatic && !p.Getter.IsInterfaceDefaultMethod), members, opt, context); - AddMethodInvokers (iface, i.Methods.Where (m => !m.IsStatic && !m.IsInterfaceDefaultMethod && !iface.IsCovariantMethod (m) && !(i.FullName.StartsWith ("Java.Lang.ICharSequence", StringComparison.Ordinal) && m.Name.EndsWith ("Formatted", StringComparison.Ordinal))), members, opt, context); + AddMethodInvokers (iface, i.Methods.Where (m => !m.IsStatic && !m.IsInterfaceDefaultMethod && !iface.IsCovariantMethod (m) && !(i.FullName.StartsWith ("Java.Lang.ICharSequence", StringComparison.Ordinal) && m.Name.EndsWith ("Formatted", StringComparison.Ordinal))), members, skipInvokers, opt, context); AddCharSequenceEnumerators (i); } } @@ -113,10 +113,13 @@ void AddPropertyInvokers (InterfaceGen iface, IEnumerable properties, Properties.Add (new InterfaceInvokerProperty (iface, prop, opt, context)); } } - - void AddMethodInvokers (InterfaceGen iface, IEnumerable methods, HashSet members, CodeGenerationOptions opt, CodeGeneratorContext context) + + void AddMethodInvokers (InterfaceGen iface, IEnumerable methods, HashSet members, HashSet skipInvokers, CodeGenerationOptions opt, CodeGeneratorContext context) { foreach (var m in methods) { + if (skipInvokers.Contains ($"{m.DeclaringType.RawJniName}.{m.JavaName}{m.JniSignature}")) + continue; + var sig = m.GetSignature (); if (members.Contains (sig))