Skip to content

Commit fcb5d45

Browse files
committed
Add test
Context: dotnet#4660 Add a unit test for Issue dotnet#4660. It's very cute. :-) We sort the Java-to-managed type name table, so it can be binary searched to find the Managed type. Additionally, the "preferred" managed type is the *first* type in `monodis --typedef` output; the first type that we encounter when going through all types in an assembly. Brenden's cute way of provoking the bug is to add a new *generic* type which will come *before* the "normally preferred" (and correct!) type. Thus, even if/when binary search returns the first entry, that'll still be the *wrong entry*, because that'll be a generic type! Very cute.
1 parent b0369af commit fcb5d45

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

tests/CodeGen-Binding/Xamarin.Android.JcwGen-Tests/BindingTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ namespace Xamarin.Android.JcwGenTests {
1212
[TestFixture]
1313
public class BindingTests {
1414

15+
[Test]
16+
public void TestTimingCreateTimingIsCorrectType ()
17+
{
18+
var t = Com.Xamarin.Android.Timing.CreateTiming ();
19+
Assert.IsTrue (t is Com.Xamarin.Android.Timing);
20+
}
21+
1522
[Test]
1623
public void TestResourceId ()
1724
{

tests/CodeGen-Binding/Xamarin.Android.McwGen-Tests/Timing.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88

99
namespace Com.Xamarin.Android {
1010

11+
// Provoke https://github.com/xamarin/xamarin-android/issues/4660
12+
// We need this type to appear *before* `Timing` in `monodis --typedef` output
13+
[Register ("com/xamarin/android/Timing", DoNotGenerateAcw = true)]
14+
public partial class Timinf<T> : Timing {
15+
}
16+
1117
public partial class Timing {
1218

1319
static IntPtr jonp_id_VirtualVoidMethod;

tests/CodeGen-Binding/Xamarin.Android.McwGen-Tests/java/com/xamarin/android/Timing.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
public class Timing {
66

7+
public static Timing createTiming () {
8+
return new Timing ();
9+
}
10+
711
public static void StaticVoidMethod ()
812
{
913
}

0 commit comments

Comments
 (0)