Skip to content

Commit e0622ee

Browse files
committed
[generator] Fix nested type visibility and findability. (#102)
AndroidSupportComponents/percent/source has some build issues that PercentFrameLayout.LayoutParams generates wrong constructors that take java.lang.Object as an argument. For example, for this: https://developer.android.com/reference/android/support/percent/PercentFrameLayout.LayoutParams.html#PercentFrameLayout.LayoutParams(android.view.ViewGroup.LayoutParams) And they resulted in build errors (which was rather fortunate; it could be worse that the method is successfully generated with java.lang.Object while the actual type isn't...) Where are those weird java.lang.Object from? Surprisingly(?), it was not about failed type resolution, but this: 8dac926e It hides nonpublic types up to java.lang.Object. Why does it happen? Isn't android.view.ViewGroup.LayoutParams public? It is. However, it was not treated as "public" - when it was loaded via managed ACWs(!). Why? We were checking: TypeDescription.IsPublic whereas it should also check TypeDescription.IsNestedPublic ... that's why it blew up to java.lang.Object which is (non-nested type). Type iteration should also check GenBase.NestedTypes to load types from DLLs. Hence another loader change.
1 parent b4e151e commit e0622ee

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

tools/generator/GenBaseSupport.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public override GenericParameterDefinitionList TypeParameters {
148148
}
149149

150150
public override string Visibility {
151-
get { return t.IsPublic ? "public" : "protected internal"; }
151+
get { return t.IsPublic || t.IsNestedPublic ? "public" : "protected internal"; }
152152
}
153153
}
154154
#endif

tools/generator/JavaApiDllLoaderExtensions.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
#if GENERATOR
22
using System;
3+
using System.Collections.Generic;
34
using System.Linq;
45
using MonoDroid.Generation;
56

67
namespace Xamarin.Android.Tools.ApiXmlAdjuster
78
{
89
public static class JavaApiDllLoaderExtensions
910
{
10-
public static void LoadReferences (this JavaApi api, GenBase [] gens)
11+
public static void LoadReferences (this JavaApi api, IEnumerable<GenBase> gens)
1112
{
1213
JavaPackage pkg = null;
1314
foreach (var gen in gens.Where (_ => _.IsAcw)) {
@@ -27,6 +28,7 @@ public static void LoadReferences (this JavaApi api, GenBase [] gens)
2728
}
2829
else
2930
throw new InvalidOperationException ();
31+
api.LoadReferences (gen.NestedTypes);
3032
}
3133
}
3234

0 commit comments

Comments
 (0)