1010using System . Collections ;
1111using System . Security . Policy ;
1212using System . Text ;
13+ using MonoDroid . Generation . Utilities ;
1314
1415namespace MonoDroid . Generation {
1516
@@ -798,24 +799,24 @@ GenBase GetBaseGen (CodeGenerationOptions opt)
798799
799800 bool enum_updated ;
800801
801- public virtual void UpdateEnums ( CodeGenerationOptions opt )
802+ public virtual void UpdateEnums ( CodeGenerationOptions opt , AncestorDescendantCache cache )
802803 {
803804 if ( enum_updated || ! IsGeneratable )
804805 return ;
805806 enum_updated = true ;
806807 var baseGen = GetBaseGen ( opt ) ;
807808 if ( baseGen != null )
808- baseGen . UpdateEnums ( opt ) ;
809+ baseGen . UpdateEnums ( opt , cache ) ;
809810
810811 foreach ( Method m in methods ) {
811- AutoDetectEnumifiedOverrideParameters ( m , opt ) ;
812- AutoDetectEnumifiedOverrideReturn ( m , opt ) ;
812+ AutoDetectEnumifiedOverrideParameters ( m , cache ) ;
813+ AutoDetectEnumifiedOverrideReturn ( m , cache ) ;
813814 }
814815 foreach ( Property p in Properties )
815- AutoDetectEnumifiedOverrideProperties ( p , opt ) ;
816+ AutoDetectEnumifiedOverrideProperties ( p , cache ) ;
816817 UpdateEnumsInInterfaceImplementation ( ) ;
817818 foreach ( var ngen in NestedTypes )
818- ngen . UpdateEnums ( opt ) ;
819+ ngen . UpdateEnums ( opt , cache ) ;
819820 }
820821
821822 public virtual void UpdateEnumsInInterfaceImplementation ( )
@@ -951,11 +952,11 @@ static IEnumerable<Method> GetAllMethods (GenBase t)
951952 return t . Methods . Concat ( t . Properties . Select ( p => p . Getter ) ) . Concat ( t . Properties . Select ( p => p . Setter ) . Where ( m => m != null ) ) ;
952953 }
953954
954- static string [ ] AutoDetectEnumifiedOverrideParameters ( MethodBase method , CodeGenerationOptions opt )
955+ static string [ ] AutoDetectEnumifiedOverrideParameters ( MethodBase method , AncestorDescendantCache cache )
955956 {
956957 if ( method . Parameters . All ( p => p . Type != "int" ) )
957958 return null ;
958- var classes = method . DeclaringType . Ancestors ( ) . Concat ( method . DeclaringType . Descendants ( opt . Gens ) ) ;
959+ var classes = cache . GetAncestorsAndDescendants ( method . DeclaringType ) ;
959960 classes = classes . Concat ( classes . SelectMany ( x => x . GetAllImplementedInterfaces ( ) ) ) ;
960961 foreach ( var t in classes ) {
961962 foreach ( var candidate in GetAllMethods ( t ) . Where ( m => m . Name == method . Name
@@ -982,11 +983,11 @@ static string [] AutoDetectEnumifiedOverrideParameters (MethodBase method, CodeG
982983 return null ;
983984 }
984985
985- static string AutoDetectEnumifiedOverrideReturn ( Method method , CodeGenerationOptions opt )
986+ static string AutoDetectEnumifiedOverrideReturn ( Method method , AncestorDescendantCache cache )
986987 {
987988 if ( method . RetVal . FullName != "int" )
988989 return null ;
989- var classes = method . DeclaringType . Ancestors ( ) . Concat ( method . DeclaringType . Descendants ( opt . Gens ) ) ;
990+ var classes = cache . GetAncestorsAndDescendants ( method . DeclaringType ) ;
990991 classes = classes . Concat ( classes . SelectMany ( x => x . GetAllImplementedInterfaces ( ) ) ) ;
991992 foreach ( var t in classes ) {
992993 foreach ( var candidate in GetAllMethods ( t ) . Where ( m => m . Name == method . Name && m . Parameters . Count == method . Parameters . Count ) ) {
@@ -999,11 +1000,11 @@ static string AutoDetectEnumifiedOverrideReturn (Method method, CodeGenerationOp
9991000 return null ;
10001001 }
10011002
1002- void AutoDetectEnumifiedOverrideProperties ( Property prop , CodeGenerationOptions opt )
1003+ void AutoDetectEnumifiedOverrideProperties ( Property prop , AncestorDescendantCache cache )
10031004 {
10041005 if ( prop . Type != "int" )
10051006 return ;
1006- var classes = prop . Getter . DeclaringType . Ancestors ( ) . Concat ( prop . Getter . DeclaringType . Descendants ( opt . Gens ) ) ;
1007+ var classes = cache . GetAncestorsAndDescendants ( prop . Getter . DeclaringType ) ;
10071008 classes = classes . Concat ( classes . SelectMany ( x => x . GetAllImplementedInterfaces ( ) ) ) ;
10081009 foreach ( var t in classes ) {
10091010 foreach ( var candidate in t . Properties . Where ( p => p . Name == prop . Name ) ) {
0 commit comments