Skip to content

Bump to dotnet/java-interop/main@6bc87e8b #9761

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 7, 2025
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 @@ -67,6 +67,9 @@ public sealed class CheckApiCompatibility : Task
// In case API diffs vary between e.g. Classic MonoAndroid & .NET 6+
public string TargetFramework { get; set; }

// What's missing from acceptableIssuesFile?
public string LinesToAdd { get; set; }

// This Build tasks validates that changes are not breaking Api
public override bool Execute ()
{
Expand Down Expand Up @@ -260,6 +263,7 @@ void dataReceived (object sender, DataReceivedEventArgs args)
}

LogError ($"CheckApiCompatibility found nonacceptable Api breakages for ApiLevel: {ApiLevel}.{Environment.NewLine}{string.Join (Environment.NewLine, lines)}");
ReportMissingLines (acceptableIssuesFile.FullName, lines);

var missingItems = CodeGenDiff.GenerateMissingItems (CodeGenPath, contractAssembly.FullName, implementationAssembly.FullName);
if (missingItems.Any ()) {
Expand All @@ -285,6 +289,21 @@ void dataReceived (object sender, DataReceivedEventArgs args)
}
}

void ReportMissingLines (string acceptableIssuesFile, List<string> lines)
{
if (string.IsNullOrWhiteSpace (LinesToAdd)) {
return;
}
var known = new HashSet<string> (File.ReadAllLines (acceptableIssuesFile), StringComparer.Ordinal);
using var writer = File.CreateText (LinesToAdd);
foreach (var line in lines) {
if (known.Contains (line)) {
continue;
}
writer.WriteLine (line);
}
}

void LogError (string errorMessage)
{
if (!string.IsNullOrWhiteSpace (compatApiCommand)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ protected override async Task<bool> Execute (Context context)
var dotnetPath = Configurables.Paths.DotNetPreviewPath;
dotnetPath = dotnetPath.TrimEnd (new char [] { Path.DirectorySeparatorChar });

if (!await InstallDotNetAsync (context, dotnetPath, BuildToolVersion)) {
if (!await InstallDotNetAsync (context, dotnetPath, BuildToolVersion, useCachedInstallScript: true) &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a better way of doing this? Can we not get the hash or crc32 of the file we want to download and compare it to the cached version?

using curl -I https://raw.githubusercontent.com/dotnet/install-scripts/refs/heads/main/src/dotnet-install.sh

We get an etag field we might be able to use to compare.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eg etag: "b2ba8c3f17e539ba16047ec26d7eb3cb58841bdc40aa0a27aab055feab567d1b"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could store the etag locally and compare it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. Unfortunately the curl -I https://builds.dotnet.microsoft.com/dotnet/scripts/v1/dotnet-install.sh does't return an etag :(

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh it does etag: 0x8DD34C45DC46329 but its different

!await InstallDotNetAsync (context, dotnetPath, BuildToolVersion, useCachedInstallScript: false)) {
Log.ErrorLine ($"Installation of dotnet SDK '{BuildToolVersion}' failed.");
return false;
}
Expand Down Expand Up @@ -77,17 +78,18 @@ protected override async Task<bool> Execute (Context context)
return true;
}

async Task<bool> DownloadDotNetInstallScript (Context context, string dotnetScriptPath, Uri dotnetScriptUrl)
async Task<bool> DownloadDotNetInstallScript (Context context, string dotnetScriptPath, Uri dotnetScriptUrl, bool useCachedInstallScript)
{
string tempDotnetScriptPath = dotnetScriptPath + "-tmp";
Utilities.DeleteFile (tempDotnetScriptPath);

Log.StatusLine ("Downloading dotnet-install script...");

if (File.Exists (dotnetScriptPath)) {
if (useCachedInstallScript && File.Exists (dotnetScriptPath)) {
Log.WarningLine ($"Using cached installation script found in '{dotnetScriptPath}'");
return true;
}
Utilities.DeleteFile (dotnetScriptPath);

Log.StatusLine ($" {context.Characters.Link} {dotnetScriptUrl}", ConsoleColor.White);
await Utilities.Download (dotnetScriptUrl, tempDotnetScriptPath, DownloadStatus.Empty);
Expand Down Expand Up @@ -173,7 +175,7 @@ string[] GetInstallationScriptArgs (string version, string dotnetPath, string do
return args.ToArray ();
}

async Task<bool> InstallDotNetAsync (Context context, string dotnetPath, string version, bool runtimeOnly = false)
async Task<bool> InstallDotNetAsync (Context context, string dotnetPath, string version, bool useCachedInstallScript, bool runtimeOnly = false)
{
string cacheDir = context.Properties.GetRequiredValue (KnownProperties.AndroidToolchainCacheDirectory);

Expand All @@ -183,7 +185,7 @@ async Task<bool> InstallDotNetAsync (Context context, string dotnetPath, string
Uri dotnetScriptUrl = Configurables.Urls.DotNetInstallScript;
string scriptFileName = Path.GetFileName (dotnetScriptUrl.LocalPath);
string cachedDotnetScriptPath = Path.Combine (cacheDir, scriptFileName);
if (!await DownloadDotNetInstallScript (context, cachedDotnetScriptPath, dotnetScriptUrl)) {
if (!await DownloadDotNetInstallScript (context, cachedDotnetScriptPath, dotnetScriptUrl, useCachedInstallScript)) {
return false;
}

Expand Down
1 change: 1 addition & 0 deletions src/Mono.Android/Mono.Android.targets
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@
TargetImplementationPath="$(OutputPath)"
ApiCompatibilityPath="$(ApiCompatibilityDir)"
TargetFramework="$(TargetFramework)"
LinesToAdd="$(MSBuildThisFileDirectory)ApiCompatLinesToAdd.txt"
/>
<Touch
Files="$(IntermediateOutputPath)CheckApiCompatibility.stamp"
Expand Down
Loading