1010using Mono . Cecil ;
1111using Java . Interop . Tools . Cecil ;
1212using Android . Runtime ;
13- #if ! GENERATOR
1413using Java . Interop . Tools . JavaCallableWrappers ;
15- #endif // !GENERATOR
1614#endif // HAVE_CECIL
1715
18- namespace Java . Interop . Tools . TypeNameMappings {
16+ namespace Java . Interop . Tools . TypeNameMappings
17+ {
1918
19+ #if HAVE_CECIL
20+ public
21+ #endif
2022 enum PackageNamingPolicy {
2123 LowercaseHash ,
2224 Lowercase ,
2325 LowercaseWithAssemblyName ,
2426 }
2527
26- public class JniTypeName
28+ #if HAVE_CECIL
29+ public
30+ #endif
31+ class JniTypeName
2732 {
2833 public string Type { get ; internal set ; }
2934 public bool IsKeyword { get ; internal set ; }
3035 }
3136
37+ #if HAVE_CECIL
38+ public
39+ #endif
3240 static class JavaNativeTypeManager {
3341
3442 public static PackageNamingPolicy PackageNamingPolicy { get ; set ; }
@@ -143,7 +151,7 @@ public static string ToJniName (Type type)
143151 "java/lang/Object" ;
144152 }
145153
146- public static string ToJniName ( Type type , ExportParameterKind exportKind )
154+ static string ToJniName ( Type type , ExportParameterKind exportKind )
147155 {
148156 if ( type == null )
149157 throw new ArgumentNullException ( "type" ) ;
@@ -159,12 +167,8 @@ public static string ToJniName (Type type, ExportParameterKind exportKind)
159167 return GetSpecialExportJniType ( type . FullName , exportKind ) ;
160168
161169 return ToJniName ( type , t => t . DeclaringType , t => t . Name , GetPackageName , t => {
162- #if ! GEN_JAVA_STUBS && ! GENERATOR && ! JAVADOC_TO_MDOC
163170 return ToJniNameFromAttributes ( t ) ;
164- #else
165- return null ;
166- #endif
167- } ) ;
171+ } , _ => false ) ;
168172 }
169173
170174 public static string ToJniName ( string jniType , int rank )
@@ -255,7 +259,6 @@ static string GetSpecialExportJniType (string typeName, ExportParameterKind expo
255259 return null ;
256260 }
257261
258- #if ! GEN_JAVA_STUBS && ! JAVADOC_TO_MDOC
259262 // Keep in sync with ToJniNameFromAttributes(TypeDefinition)
260263 public static string ToJniNameFromAttributes ( Type type )
261264 {
@@ -347,7 +350,7 @@ static string GetJniTypeName<TR,TD> (TR typeRef, ExportParameterKind exportKind,
347350 return rank == 0 && pJniName . Length > 1 ? "L" + pJniName + ";" : ToJniName ( pJniName , rank ) ;
348351 }
349352
350- public static ExportParameterKind GetExportKind ( System . Reflection . ICustomAttributeProvider p )
353+ static ExportParameterKind GetExportKind ( System . Reflection . ICustomAttributeProvider p )
351354 {
352355 foreach ( ExportParameterAttribute a in p . GetCustomAttributes ( typeof ( ExportParameterAttribute ) , false ) )
353356 return a . Kind ;
@@ -370,7 +373,7 @@ public static string GetJniTypeName (Type typeRef)
370373 return GetJniTypeName ( typeRef , ExportParameterKind . Unspecified ) ;
371374 }
372375
373- public static string GetJniTypeName ( Type typeRef , ExportParameterKind exportKind )
376+ internal static string GetJniTypeName ( Type typeRef , ExportParameterKind exportKind )
374377 {
375378 return GetJniTypeName < Type , Type > ( typeRef , exportKind , t => t , t => {
376379 Type etype ;
@@ -385,7 +388,6 @@ static string ToJniNameWhichShouldReplaceExistingToJniName (Type type, ExportPar
385388 var ret = ToJniNameFromAttributes ( type ) ;
386389 return ret ?? ToJniName ( type , exportKind ) ;
387390 }
388- #endif
389391
390392#if HAVE_CECIL
391393
@@ -401,12 +403,12 @@ internal static ExportParameterAttribute ToExportParameterAttribute (CustomAttri
401403 return new ExportParameterAttribute ( ( ExportParameterKind ) attr . ConstructorArguments [ 0 ] . Value ) ;
402404 }
403405
404- internal static bool IsApplication ( TypeDefinition type )
406+ public static bool IsApplication ( TypeDefinition type )
405407 {
406408 return type . GetBaseTypes ( ) . Any ( b => b . FullName == "Android.App.Application" ) ;
407409 }
408410
409- internal static bool IsInstrumentation ( TypeDefinition type )
411+ public static bool IsInstrumentation ( TypeDefinition type )
410412 {
411413 return type . GetBaseTypes ( ) . Any ( b => b . FullName == "Android.App.Instrumentation" ) ;
412414 }
@@ -430,7 +432,7 @@ public static string GetJniTypeName (TypeReference typeRef)
430432 return GetJniTypeName ( typeRef , ExportParameterKind . Unspecified ) ;
431433 }
432434
433- public static string GetJniTypeName ( TypeReference typeRef , ExportParameterKind exportKind )
435+ internal static string GetJniTypeName ( TypeReference typeRef , ExportParameterKind exportKind )
434436 {
435437 return GetJniTypeName < TypeReference , TypeDefinition > ( typeRef , exportKind , t => t . Resolve ( ) , t => {
436438 TypeReference etype ;
@@ -441,7 +443,7 @@ public static string GetJniTypeName (TypeReference typeRef, ExportParameterKind
441443
442444 public static string ToCompatJniName ( Mono . Cecil . TypeDefinition type )
443445 {
444- return ToJniName ( type , t => t . DeclaringType , t => t . Name , ToCompatPackageName , ToJniNameFromAttributes ) ;
446+ return ToJniName ( type , t => t . DeclaringType , t => t . Name , ToCompatPackageName , ToJniNameFromAttributes , t => IsNonStaticInnerClass ( t as TypeDefinition ) ) ;
445447 }
446448
447449 static string ToCompatPackageName ( Mono . Cecil . TypeDefinition type )
@@ -456,7 +458,7 @@ public static string ToJniName (Mono.Cecil.TypeDefinition type)
456458 "java/lang/Object" ;
457459 }
458460
459- public static string ToJniName ( TypeDefinition type , ExportParameterKind exportKind )
461+ static string ToJniName ( TypeDefinition type , ExportParameterKind exportKind )
460462 {
461463 if ( type == null )
462464 throw new ArgumentNullException ( "type" ) ;
@@ -471,7 +473,7 @@ public static string ToJniName (TypeDefinition type, ExportParameterKind exportK
471473 return GetSpecialExportJniType ( type . FullName , exportKind ) ;
472474 }
473475
474- return ToJniName ( type , t => t . DeclaringType , t => t . Name , GetPackageName , ToJniNameFromAttributes ) ;
476+ return ToJniName ( type , t => t . DeclaringType , t => t . Name , GetPackageName , ToJniNameFromAttributes , t => IsNonStaticInnerClass ( t as TypeDefinition ) ) ;
475477 }
476478
477479 static string ToJniNameFromAttributes ( TypeDefinition type )
@@ -562,7 +564,7 @@ public static string GetPackageName (TypeDefinition type)
562564 }
563565#endif
564566
565- static string ToJniName < T > ( T type , Func < T , T > decl , Func < T , string > name , Func < T , string > ns , Func < T , string > overrideName )
567+ static string ToJniName < T > ( T type , Func < T , T > decl , Func < T , string > name , Func < T , string > ns , Func < T , string > overrideName , Func < T , bool > shouldUpdateName )
566568 where T : class
567569 {
568570 var nameParts = new List < string > ( ) ;
@@ -576,12 +578,9 @@ static string ToJniName<T> (T type, Func<T, T> decl, Func<T, string> name, Func<
576578 break ;
577579 }
578580 var n = name ( declType ) . Replace ( '`' , '_' ) ;
579- #if HAVE_CECIL
580- var td = declType as TypeDefinition ;
581- if ( IsNonStaticInnerClass ( td ) ) {
581+ if ( shouldUpdateName ( declType ) ) {
582582 n = "$" + name ( decl ( declType ) ) + "_" + n ;
583583 }
584- #endif
585584 nameParts . Add ( n ) ;
586585 }
587586
0 commit comments