Skip to content

Commit 942df52

Browse files
committed
[Java.Interop] JavaTypeParametersAttribute only in net6
Context: dotnet/android#6549 When attempting to bump xamarin-android to use bc5bcf4, the build failed because bc5bcf4 added a "duplicate" type `Java.Interop.JavaTypeParametersAttribute`: error CS0433: The type 'JavaTypeParametersAttribute' exists in both 'Java.Interop, Version=0.1.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065' and 'Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'. The plan was to use type forwarders for this type from `Mono.Android.dll` to `Java.Interop.dll`, but in retrospect this sounds like a potential "forward-incompatible ABI break" (e56a8c8) as assemblies built against the newer `Mono.Android.dll` (with type forwarders) won't be usable on previous Xamarin.Android SDKs. Make `JavaTypeParametersAttribute` conditional on `NET`, so that it's only included in .NET 6 builds. .NET SDK for Android will then use type forwarders, which won't be an issue as there's no previous .NET release to be forward compatible with. Update `tests/generator-Tests` so that `JavaTypeParametersAttribute` is once again provided for non-`JAVA_INTEROP1` builds.
1 parent bc5bcf4 commit 942df52

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/Java.Interop/Java.Interop/JavaTypeParametersAttribute.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using System;
22

3+
#if NET
4+
35
namespace Java.Interop
46
{
57
[AttributeUsage (AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Method,
@@ -14,3 +16,5 @@ public JavaTypeParametersAttribute (string [] typeParameters)
1416
public string [] TypeParameters { get; }
1517
}
1618
}
19+
20+
#endif // NET
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#if !JAVA_INTEROP
2+
3+
using System;
4+
5+
namespace Java.Interop
6+
{
7+
public class JavaTypeParametersAttribute : Attribute
8+
{
9+
public JavaTypeParametersAttribute (string [] typeParameters)
10+
{
11+
TypeParameters = typeParameters;
12+
}
13+
14+
public string [] TypeParameters { get; set; }
15+
}
16+
}
17+
18+
#endif // !JAVA_INTEROP

0 commit comments

Comments
 (0)