Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,14 @@ public sealed class CheckApiCompatibility : Task
[Required]
public string ApiCompatibilityPath { get; set; }

// In case API diffs vary between e.g. Classic MonoAndroid & .NET 6+
public string TargetFramework { get; set; }

// This Build tasks validates that changes are not breaking Api
public override bool Execute ()
{
Log.LogMessage (MessageImportance.High, $"CheckApiCompatibility for ApiLevel: {ApiLevel}");
Log.LogWarning ($"# jonp: TargetFramework={TargetFramework}");

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


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

Expand Down
2 changes: 2 additions & 0 deletions build-tools/automation/azure-pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ stages:
msbuildArguments: >-
/restore
/t:RunJavaInteropTests
/p:SkipJSUTests=true
/p:TestAssembly="bin\Test$(XA.Build.Configuration)\generator-Tests.dll;bin\Test$(XA.Build.Configuration)\Java.Interop.Tools.JavaCallableWrappers-Tests.dll;bin\Test$(XA.Build.Configuration)\logcat-parse-Tests.dll;bin\Test$(XA.Build.Configuration)\Xamarin.Android.Tools.ApiXmlAdjuster-Tests.dll;bin\Test$(XA.Build.Configuration)\Xamarin.Android.Tools.Bytecode-Tests.dll"
/bl:$(System.DefaultWorkingDirectory)\bin\Test$(XA.Build.Configuration)\msbuild-run-ji-tests.binlog
continueOnError: True
Expand Down Expand Up @@ -360,6 +361,7 @@ stages:
msbuildArguments: >-
/restore
/t:RunJavaInteropTests
/p:SkipJSUTests=true
/p:TestAssembly="bin\Test$(XA.Build.Configuration)\generator-Tests.dll;bin\Test$(XA.Build.Configuration)\Java.Interop.Tools.JavaCallableWrappers-Tests.dll;bin\Test$(XA.Build.Configuration)\logcat-parse-Tests.dll;bin\Test$(XA.Build.Configuration)\Xamarin.Android.Tools.ApiXmlAdjuster-Tests.dll;bin\Test$(XA.Build.Configuration)\Xamarin.Android.Tools.Bytecode-Tests.dll"
/bl:$(System.DefaultWorkingDirectory)\bin\Test$(XA.Build.Configuration)\dotnet-run-ji-tests.binlog
continueOnError: True
Expand Down
2 changes: 1 addition & 1 deletion external/Java.Interop
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
using System;

#if NET
using System.Runtime.CompilerServices;

[assembly: TypeForwardedTo (typeof (Java.Interop.JavaTypeParametersAttribute))]

#else // !NET

namespace Java.Interop
{
public class JavaTypeParametersAttribute : Attribute
Expand All @@ -13,3 +20,4 @@ public JavaTypeParametersAttribute (string [] typeParameters)
}
}

#endif // !NET
1 change: 1 addition & 0 deletions src/Mono.Android/Mono.Android.targets
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@
LastStableApiLevel="$(AndroidLatestStableFrameworkVersion)"
TargetImplementationPath="$(OutputPath)"
ApiCompatibilityPath="$(ApiCompatibilityDir)"
TargetFramework="$(TargetFramework)"
/>
<Touch
Files="$(IntermediateOutputPath)CheckApiCompatibility.stamp"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Compat issues with assembly Mono.Android:
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.
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.
CannotRemoveAttribute : Attribute 'Android.Runtime.RegisterAttribute' exists on 'Android.Bluetooth.LE.AdvertisingSetParameters.Builder.SetPrimaryPhy(Android.Bluetooth.LE.ScanSettingsPhy)' in the contract but not the implementation.
CannotRemoveAttribute : Attribute 'Android.Runtime.RegisterAttribute' exists on 'Android.Bluetooth.LE.AdvertisingSetParameters.Builder.SetSecondaryPhy(Android.Bluetooth.LE.ScanSettingsPhy)' in the contract but not the implementation.
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.
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.
CannotSealType : Type 'Java.Interop.JavaTypeParametersAttribute' is actually (has the sealed modifier) sealed in the implementation but not sealed in the contract.
MembersMustExist : Member 'public void Java.Interop.JavaTypeParametersAttribute.TypeParameters.set(System.String[])' does not exist in the implementation but it does exist in the contract.