99
1010using Xamarin . Android . Binder ;
1111using Xamarin . Android . Tools ;
12+ using System . Diagnostics ;
1213
1314namespace MonoDroid . Generation {
1415#if HAVE_CECIL
@@ -106,6 +107,10 @@ public bool IsConstSugar {
106107 }
107108 }
108109
110+ public override bool IsInterface {
111+ get { return true ; }
112+ }
113+
109114 public bool IsListener {
110115 // If there is a property it cannot generate valid implementor, so reject this at least so far.
111116 get { return Name . EndsWith ( "Listener" ) && Properties . Count == 0 && Interfaces . Count == 0 ; }
@@ -197,11 +202,13 @@ protected override bool OnValidate (CodeGenerationOptions opt, GenericParameterD
197202
198203 void GenMethods ( StreamWriter sw , string indent , CodeGenerationOptions opt )
199204 {
200- foreach ( Method m in Methods . Where ( m => ! m . IsStatic ) ) {
205+ foreach ( Method m in Methods . Where ( m => ! m . IsStatic && ! m . IsInterfaceDefaultMethod ) ) {
201206 if ( m . Name == Name || ContainsProperty ( m . Name , true ) )
202207 m . Name = "Invoke" + m . Name ;
203208 opt . CodeGenerator . WriteMethodDeclaration ( m , sw , indent , opt , this , AssemblyQualifiedName + "Invoker" ) ;
204209 }
210+ foreach ( Method m in Methods . Where ( m => m . IsInterfaceDefaultMethod ) )
211+ opt . CodeGenerator . WriteMethod ( m , sw , indent , opt , this , true ) ;
205212 }
206213
207214 void GenExtensionMethods ( StreamWriter sw , string indent , CodeGenerationOptions opt )
@@ -214,8 +221,9 @@ void GenExtensionMethods (StreamWriter sw, string indent, CodeGenerationOptions
214221
215222 void GenProperties ( StreamWriter sw , string indent , CodeGenerationOptions opt )
216223 {
217- foreach ( Property prop in Properties . Where ( p => ! p . Getter . IsStatic ) )
224+ foreach ( Property prop in Properties . Where ( p => ! p . Getter . IsStatic && ! p . Getter . IsInterfaceDefaultMethod ) )
218225 prop . GenerateDeclaration ( sw , indent , opt , this , AssemblyQualifiedName + "Invoker" ) ;
226+ base . GenerateImplementedProperties ( sw , indent , false , opt ) ;
219227 }
220228
221229 void GenerateInvoker ( StreamWriter sw , string indent , CodeGenerationOptions opt )
@@ -256,14 +264,14 @@ void GenerateInvoker (StreamWriter sw, string indent, CodeGenerationOptions opt)
256264 sw . WriteLine ( ) ;
257265
258266 HashSet < string > members = new HashSet < string > ( ) ;
259- GenerateInvoker ( sw , Properties . Where ( p => ! p . Getter . IsStatic ) , indent + "\t " , opt , members ) ;
260- GenerateInvoker ( sw , Methods . Where ( m => ! m . IsStatic ) , indent + "\t " , opt , members ) ;
267+ GenerateInvoker ( sw , Properties . Where ( p => ! p . Getter . IsStatic && ! p . Getter . IsInterfaceDefaultMethod ) , indent + "\t " , opt , members ) ;
268+ GenerateInvoker ( sw , Methods . Where ( m => ! m . IsStatic && ! m . IsInterfaceDefaultMethod ) , indent + "\t " , opt , members ) ;
261269 if ( FullName == "Java.Lang.ICharSequence" )
262270 GenCharSequenceEnumerator ( sw , indent + "\t " , opt ) ;
263271
264272 foreach ( InterfaceGen iface in GetAllDerivedInterfaces ( ) ) {
265- GenerateInvoker ( sw , iface . Properties . Where ( p => ! p . Getter . IsStatic ) , indent + "\t " , opt , members ) ;
266- GenerateInvoker ( sw , iface . Methods . Where ( m => ! m . IsStatic && ! IsCovariantMethod ( m ) && ! ( iface . FullName . StartsWith ( "Java.Lang.ICharSequence" ) && m . Name . EndsWith ( "Formatted" ) ) ) , indent + "\t " , opt , members ) ;
273+ GenerateInvoker ( sw , iface . Properties . Where ( p => ! p . Getter . IsStatic && ! p . Getter . IsInterfaceDefaultMethod ) , indent + "\t " , opt , members ) ;
274+ GenerateInvoker ( sw , iface . Methods . Where ( m => ! m . IsStatic && ! m . IsInterfaceDefaultMethod && ! IsCovariantMethod ( m ) && ! ( iface . FullName . StartsWith ( "Java.Lang.ICharSequence" ) && m . Name . EndsWith ( "Formatted" ) ) ) , indent + "\t " , opt , members ) ;
267275 if ( iface . FullName == "Java.Lang.ICharSequence" )
268276 GenCharSequenceEnumerator ( sw , indent + "\t " , opt ) ;
269277 }
0 commit comments