Skip to content

Commit 1cd0361

Browse files
jonpryoratsushieno
authored andcommitted
[generator] Don't register invariant+excluded types (#177)
Context: dotnet/android#732 Commit d7dfa0b [broke][1] the `xamarin-android/tests/CodeGen-Binding/Xamarin.Android.McwGen-Tests` build, as it started treating `Android.Graphics.Color` as a normal type, instead of the special-cased behavior it should have: [1]: https://jenkins.mono-project.com/job/xamarin-android-pr-builder/1324/ error CS0452: The type 'Color' must be a reference type in order to use it as parameter 'T' in the generic type or method 'Object.GetObject<T>(IntPtr, JniHandleOwnership)' error CS1503: Argument 1: cannot convert from 'Android.Graphics.Color' to 'Android.Runtime.IJavaObject' The problem is that this code pattern: static int n_UseColors_I (IntPtr jnienv, IntPtr native__this, int native_p0) { global::Com.Xamarin.Android.Bxc4288 __this = global::Java.Lang.Object.GetObject<global::Com.Xamarin.Android.Bxc4288> (jnienv, native__this, JniHandleOwnership.DoNotTransfer); global::Android.Graphics.Color p0 = new global::Android.Graphics.Color (native_p0); return __this.UseColors (p0).ToArgb (); } became: static IntPtr n_UseColors_LAndroid_Graphics_Color_ (IntPtr jnienv, IntPtr native__this, IntPtr native_p0) { global::Com.Xamarin.Android.Bxc4288 __this = global::Java.Lang.Object.GetObject<global::Com.Xamarin.Android.Bxc4288> (jnienv, native__this, JniHandleOwnership.DoNotTransfer); global::Android.Graphics.Color p0 = global::Java.Lang.Object.GetObject<global::Android.Graphics.Color> (native_p0, JniHandleOwnership.DoNotTransfer); IntPtr __ret = JNIEnv.ToLocalJniHandle (__this.UseColors (p0)); return __ret; } The cause reason for this is that d7dfa0b updated `SymbolTable.AddType()` so that it no longer called `SymbolTable.ShouldAddType()`, which is what would prevent type registration of `Android.Graphics.Color`. Reintroduce the call to `ShouldAddType()` so that `Android.Graphics.Color` isn't registered.
1 parent 30e0151 commit 1cd0361

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

tools/generator/SymbolTable.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ static bool ShouldAddType (string key)
135135

136136
public static void AddType (string key, ISymbol symbol)
137137
{
138+
if (!ShouldAddType (key))
139+
return;
140+
138141
List<ISymbol> values;
139142
if (!symbols.TryGetValue (key, out values)) {
140143
symbols.Add (key, new List<ISymbol> { symbol });

0 commit comments

Comments
 (0)