Skip to content

Commit 32bca42

Browse files
committed
Testing…
Context: dotnet/java-interop#929 See if dotnet/java-interop#929 + type forwarders fixes the build failure originally observed: 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' [C:\a\_work\1\a\TestRelease\12-07_04.08.15\temp\LibraryProjectZipWithLint\BindingsProject\BindingsProject.csproj]
1 parent a736c53 commit 32bca42

File tree

6 files changed

+33
-5
lines changed

6 files changed

+33
-5
lines changed

.gitmodules

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
branch = main
1313
[submodule "external/Java.Interop"]
1414
path = external/Java.Interop
15-
url = https://github.com/xamarin/java.interop.git
16-
branch = main
15+
url = https://github.com/jonpryor/java.interop.git
16+
branch = jonp-JavaTypeParametersAttribute-only-in-net6
1717
[submodule "external/lz4"]
1818
path = external/lz4
1919
url = https://github.com/lz4/lz4.git

build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/CheckApiCompatibility.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,14 @@ public sealed class CheckApiCompatibility : Task
6161
[Required]
6262
public string ApiCompatibilityPath { get; set; }
6363

64+
// In case API diffs vary between e.g. Classic MonoAndroid & .NET 6+
65+
public string TargetFramework { get; set; }
66+
6467
// This Build tasks validates that changes are not breaking Api
6568
public override bool Execute ()
6669
{
6770
Log.LogMessage (MessageImportance.High, $"CheckApiCompatibility for ApiLevel: {ApiLevel}");
71+
Log.LogWarning ($"# jonp: TargetFramework={TargetFramework}");
6872

6973
// Check to see if Api has a previous Api defined.
7074
if (!api_versions.TryGetValue (ApiLevel, out string previousApiLevel)) {
@@ -173,8 +177,14 @@ void ValidateApiCompat (string contractPath, bool validateAgainstReference)
173177

174178

175179
// Verify if there is a file with acceptable issues.
176-
var acceptableIssuesFile = new FileInfo (Path.Combine (ApiCompatibilityPath, $"acceptable-breakages-{ (validateAgainstReference ? "vReference" : ApiLevel) }.txt"));
177-
if (acceptableIssuesFile.Exists) {
180+
var acceptableIssuesFiles = new[]{
181+
Path.Combine (ApiCompatibilityPath, $"acceptable-breakages-{ (validateAgainstReference ? "vReference" : ApiLevel) }-{TargetFramework}.txt"),
182+
Path.Combine (ApiCompatibilityPath, $"acceptable-breakages-{ (validateAgainstReference ? "vReference" : ApiLevel) }.txt"),
183+
};
184+
var acceptableIssuesFile = acceptableIssuesFiles.Select (p => new FileInfo (p))
185+
.Where (v => v.Exists)
186+
.FirstOrDefault ();
187+
if (acceptableIssuesFile != null) {
178188
genApiProcess.StartInfo.Arguments += $"--baseline \"{acceptableIssuesFile.FullName}\" --validate-baseline ";
179189
}
180190

src/Mono.Android/Java.Interop/JavaTypeParametersAttribute.cs

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

3+
#if NET
4+
using System.Runtime.CompilerServices;
5+
6+
[assembly: TypeForwardedTo (typeof (Java.Interop.JavaTypeParametersAttribute))]
7+
8+
#else // !NET
9+
310
namespace Java.Interop
411
{
512
public class JavaTypeParametersAttribute : Attribute
@@ -13,3 +20,4 @@ public JavaTypeParametersAttribute (string [] typeParameters)
1320
}
1421
}
1522

23+
#endif // !NET

src/Mono.Android/Mono.Android.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@
263263
LastStableApiLevel="$(AndroidLatestStableFrameworkVersion)"
264264
TargetImplementationPath="$(OutputPath)"
265265
ApiCompatibilityPath="$(ApiCompatibilityDir)"
266+
TargetFramework="$(TargetFramework)"
266267
/>
267268
<Touch
268269
Files="$(IntermediateOutputPath)CheckApiCompatibility.stamp"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Compat issues with assembly Mono.Android:
2+
CannotRemoveAttribute : Attribute 'Android.Runtime.RegisterAttribute' exists on 'Android.Bluetooth.BluetoothDevice.ConnectGatt(Android.Content.Context, System.Boolean, Android.Bluetooth.BluetoothGattCallback, Android.Bluetooth.BluetoothTransports, Android.Bluetooth.LE.ScanSettingsPhy)' in the contract but not the implementation.
3+
CannotRemoveAttribute : Attribute 'Android.Runtime.RegisterAttribute' exists on 'Android.Bluetooth.BluetoothDevice.ConnectGatt(Android.Content.Context, System.Boolean, Android.Bluetooth.BluetoothGattCallback, Android.Bluetooth.BluetoothTransports, Android.Bluetooth.LE.ScanSettingsPhy, Android.OS.Handler)' in the contract but not the implementation.
4+
CannotRemoveAttribute : Attribute 'Android.Runtime.RegisterAttribute' exists on 'Android.Bluetooth.LE.AdvertisingSetParameters.Builder.SetPrimaryPhy(Android.Bluetooth.LE.ScanSettingsPhy)' in the contract but not the implementation.
5+
CannotRemoveAttribute : Attribute 'Android.Runtime.RegisterAttribute' exists on 'Android.Bluetooth.LE.AdvertisingSetParameters.Builder.SetSecondaryPhy(Android.Bluetooth.LE.ScanSettingsPhy)' in the contract but not the implementation.
6+
CannotChangeAttribute : Attribute 'System.AttributeUsageAttribute' on 'Android.Runtime.IntDefAttribute' changed from '[AttributeUsageAttribute(2272, AllowMultiple=true)]' in the contract to '[AttributeUsageAttribute(2528, AllowMultiple=true)]' in the implementation.
7+
CannotChangeAttribute : Attribute 'System.AttributeUsageAttribute' on 'Android.Runtime.StringDefAttribute' changed from '[AttributeUsageAttribute(2272, AllowMultiple=true)]' in the contract to '[AttributeUsageAttribute(2528, AllowMultiple=true)]' in the implementation.
8+
CannotSealType : Type 'Java.Interop.JavaTypeParametersAttribute' is actually (has the sealed modifier) sealed in the implementation but not sealed in the contract.
9+
MembersMustExist : Member 'public void Java.Interop.JavaTypeParametersAttribute.TypeParameters.set(System.String[])' does not exist in the implementation but it does exist in the contract.

0 commit comments

Comments
 (0)