From 3bc4dfde9f88c803628439aa98c593557cc355db Mon Sep 17 00:00:00 2001 From: Manuel de la Pena Date: Thu, 11 May 2023 13:23:28 -0400 Subject: [PATCH 1/5] [CI] Do not set statuses for artefacts not longer generated or signed. (#18257) --- .../sign-and-notarized/upload-azure.yml | 37 ------------------- 1 file changed, 37 deletions(-) diff --git a/tools/devops/automation/templates/sign-and-notarized/upload-azure.yml b/tools/devops/automation/templates/sign-and-notarized/upload-azure.yml index db22f46f8f..f1bc646383 100644 --- a/tools/devops/automation/templates/sign-and-notarized/upload-azure.yml +++ b/tools/devops/automation/templates/sign-and-notarized/upload-azure.yml @@ -222,22 +222,6 @@ steps: TargetUrl = "$pkgsVirtualUrl/notarized/$macPkg" ; Error = "Notarized xamarin.mac pkg not found." ; ShouldExist = $notarizedShouldExist; - }, - @{ - Path = "$pkgsPath\\bundle.zip" ; - Context = "bundle.zip" ; - Description = "bundle.zip" ; - TargetUrl = "$pkgsVirtualUrl/bundle.zip" ; - Error = "bundle.zip not found." ; - ShouldExist = $true; - }, - @{ - Path = "$pkgsPath\msbuild.zip" ; - Context = "msbuild.zip" ; - Description = "msbuild.zip" ; - TargetUrl = "$pkgsVirtualUrl/msbuild.zip" ; - Error = "msbuild.zip not found." ; - ShouldExist = $true; } ) @@ -248,27 +232,6 @@ steps: $statuses.SetStatus("error", $info.Error, $info.Context) } } - if ($Env:ENABLE_DOTNET -eq "True" -and $Env:SkipNugets -ne "True") { - $nugets = Get-ChildItem -Path $pkgsPath -Filter *.nupkg -File -Name - Write-Host $nugets - Write-Host "nuget count is $($nugets.Count)" - - if ($nugets.Count -gt 0) { - Write-Host "Setting status to success." - $statuses.SetStatus("success", "Nugets built.", "$(Build.DefinitionName) (Nugets built)", "$pkgsVirtualUrl/$n") - Write-Host "Publishing result is $Env:NUGETS_PUBLISHED" - if ($Env:NUGETS_PUBLISHED -ne "Failed") { - $statuses.SetStatus("success", "Nugets published.", "$(Build.DefinitionName) (Nugets published)", "$pkgsVirtualUrl/$n") - } else { - $statuses.SetStatus("error", "Error when publishing nugets.", "$(Build.DefinitionName) (Nugets published)", "$pkgsVirtualUrl/$n") - } - } else { - Write-Host "Setting nuget status to failure." - $statuses.SetStatus("error", "No nugets were built.", "$(Build.DefinitionName) (Nugets built)", "$pkgsVirtualUrl/$n") - $statuses.SetStatus("error", "No nugets were published.", "$(Build.DefinitionName) (Nugets published)", "$pkgsVirtualUrl/$n") - } - } - $msi = Get-ChildItem -Path $pkgsPath -Filter *.msi -File -Name From d06209a917133475e409bb5a1f2de04533c7dc9a Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Fri, 12 May 2023 07:37:36 +0200 Subject: [PATCH 2/5] [Foundation] Bind two overloads to create NSUrl instances from file paths. (#18265) --- src/foundation.cs | 8 ++++++++ .../api-annotations-dotnet/common-Foundation.ignore | 2 -- tests/xtro-sharpie/common-Foundation.ignore | 2 -- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/foundation.cs b/src/foundation.cs index 93efd9922d..10d72dbf33 100644 --- a/src/foundation.cs +++ b/src/foundation.cs @@ -7157,12 +7157,20 @@ namespace Foundation { [Export ("fileURLWithPath:isDirectory:relativeToURL:")] NSUrl CreateFileUrl (string path, bool isDir, [NullAllowed] NSUrl relativeToUrl); + [Static] + [Export ("fileURLWithPath:isDirectory:")] + NSUrl CreateFileUrl (string path, bool isDir); + [iOS (9, 0), Mac (10, 11)] [MacCatalyst (13, 1)] [Static] [Export ("fileURLWithPath:relativeToURL:")] NSUrl CreateFileUrl (string path, [NullAllowed] NSUrl relativeToUrl); + [Static] + [Export ("fileURLWithPath:")] + NSUrl CreateFileUrl (string path); + [iOS (9, 0), Mac (10, 11)] [MacCatalyst (13, 1)] [Static] diff --git a/tests/xtro-sharpie/api-annotations-dotnet/common-Foundation.ignore b/tests/xtro-sharpie/api-annotations-dotnet/common-Foundation.ignore index 6ed2e688ae..6335ff0dd7 100644 --- a/tests/xtro-sharpie/api-annotations-dotnet/common-Foundation.ignore +++ b/tests/xtro-sharpie/api-annotations-dotnet/common-Foundation.ignore @@ -363,8 +363,6 @@ !missing-selector! +NSTimer::scheduledTimerWithTimeInterval:invocation:repeats: not bound !missing-selector! +NSTimer::timerWithTimeInterval:invocation:repeats: not bound !missing-selector! +NSTimeZone::setAbbreviationDictionary: not bound -!missing-selector! +NSURL::fileURLWithPath: not bound -!missing-selector! +NSURL::fileURLWithPath:isDirectory: not bound !missing-selector! +NSURL::resourceValuesForKeys:fromBookmarkData: not bound !missing-selector! +NSURLProtocol::canInitWithTask: not bound !missing-selector! +NSURLQueryItem::queryItemWithName:value: not bound diff --git a/tests/xtro-sharpie/common-Foundation.ignore b/tests/xtro-sharpie/common-Foundation.ignore index 6f5552a8dd..b27cba360d 100644 --- a/tests/xtro-sharpie/common-Foundation.ignore +++ b/tests/xtro-sharpie/common-Foundation.ignore @@ -372,8 +372,6 @@ !missing-selector! +NSTimer::scheduledTimerWithTimeInterval:invocation:repeats: not bound !missing-selector! +NSTimer::timerWithTimeInterval:invocation:repeats: not bound !missing-selector! +NSTimeZone::setAbbreviationDictionary: not bound -!missing-selector! +NSURL::fileURLWithPath: not bound -!missing-selector! +NSURL::fileURLWithPath:isDirectory: not bound !missing-selector! +NSURL::resourceValuesForKeys:fromBookmarkData: not bound !missing-selector! +NSURLProtocol::canInitWithTask: not bound !missing-selector! +NSURLQueryItem::queryItemWithName:value: not bound From 1cb598e624dfab270138b6d4a2a6ea6f779ae916 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Fri, 12 May 2023 07:41:17 +0200 Subject: [PATCH 3/5] [monotouch-test] Adjust ImageCaptioningTest.GetCaption to don't care if we get an error or not. (#18267) This check is passing a remote url to an API that wants a url to a local file (file:// url), and this is supposed to fail (it's not a network hiccup if it fails). However, sometimes it doesn't fail... for unknown reasons. So instead change the test's expectations so that it passes whether using a remote url fails with an error or not. --- .../monotouch-test/MediaAccessibility/ImageCaptioningTest.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/monotouch-test/MediaAccessibility/ImageCaptioningTest.cs b/tests/monotouch-test/MediaAccessibility/ImageCaptioningTest.cs index d8f4695b54..c23a11d874 100644 --- a/tests/monotouch-test/MediaAccessibility/ImageCaptioningTest.cs +++ b/tests/monotouch-test/MediaAccessibility/ImageCaptioningTest.cs @@ -32,10 +32,7 @@ namespace MonoTouchFixtures.MediaAccessibility { using (NSUrl url = new NSUrl (NetworkResources.MicrosoftUrl)) { var s = MAImageCaptioning.GetCaption (url, out var e); Assert.Null (s, "remote / return value"); - if (e is not null && e.Description.Contains ("Invalid url:")) { - TestRuntime.IgnoreInCI ($"Ignore this failure when network is down: {e}"); // could not connect to the network, fail and add a nice reason - } - Assert.Null (e, "remote / no error"); // weird should be an "image on disk" + Assert.That (e, Is.Null.Or.Not.Null, "remote / error"); // sometimes we get an error, and sometimes we don't 🤷‍♂️ } string file = Path.Combine (NSBundle.MainBundle.ResourcePath, "basn3p08.png"); file = file.Replace (" ", "%20"); From eb526a098e2b81bb42b5be52991bbcf3a54229d7 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Fri, 12 May 2023 07:41:49 +0200 Subject: [PATCH 4/5] [bgen] Fix a few nullability warnings. (#18264) Also make nullability warnings errors, so we don't add any more nullability issues. Fixes: src/bgen/Filters.cs(215,9): warning CS8602: Dereference of a possibly null reference. src/bgen/Filters.cs(242,23): warning CS8604: Possible null reference argument for parameter 'str' in 'string StringExtensions.Capitalize(string str)'. src/bgen/BindingTouch.cs(528,29): warning CS8604: Possible null reference argument for parameter 'item' in 'bool List.Contains(string item)'. --- src/bgen/BindingTouch.cs | 7 +++++++ src/bgen/Filters.cs | 4 ++-- src/bgen/bgen.csproj | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/bgen/BindingTouch.cs b/src/bgen/BindingTouch.cs index f9ca3b97b3..21212d8b39 100644 --- a/src/bgen/BindingTouch.cs +++ b/src/bgen/BindingTouch.cs @@ -525,6 +525,13 @@ public class BindingTouch : IDisposable { typeManager ??= new (this, api, universe.CoreAssembly, baselib); foreach (var linkWith in AttributeManager.GetCustomAttributes (api)) { +#if NET + if (string.IsNullOrEmpty (linkWith.LibraryName)) +#else + if (linkWith.LibraryName is null || string.IsNullOrEmpty (linkWith.LibraryName)) +#endif + continue; + if (!linkwith.Contains (linkWith.LibraryName)) { Console.Error.WriteLine ("Missing native library {0}, please use `--link-with' to specify the path to this library.", linkWith.LibraryName); return 1; diff --git a/src/bgen/Filters.cs b/src/bgen/Filters.cs index ae3630a6f4..6ab93ecbdf 100644 --- a/src/bgen/Filters.cs +++ b/src/bgen/Filters.cs @@ -211,7 +211,7 @@ public partial class Generator { if (export is null) throw new BindingException (1074, true, type.Name, p.Name); - var sel = export.Selector; + var sel = export.Selector!; if (sel.StartsWith ("input", StringComparison.Ordinal)) name = sel; else @@ -237,7 +237,7 @@ public partial class Generator { if (export is null) return; - var selector = export.Selector; + var selector = export.Selector!; if (setter) selector = "set" + selector.Capitalize () + ":"; diff --git a/src/bgen/bgen.csproj b/src/bgen/bgen.csproj index 8689db4f6f..0365c6a3c5 100644 --- a/src/bgen/bgen.csproj +++ b/src/bgen/bgen.csproj @@ -5,6 +5,7 @@ net$(BundledNETCoreAppTargetFrameworkVersion) Exe DEBUG;BGENERATOR;NET_4_0;NO_AUTHENTICODE;STATIC;NO_SYMBOL_WRITER;NET + Nullable From feebcfaa0783733a8d58ae8b2047fb67c1a147b4 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Fri, 12 May 2023 08:16:48 +0200 Subject: [PATCH 5/5] [src] Use NSLog instead of Console.WriteLine in tracing statements. (#18258) Use NSLog instead of Console.WriteLine for tracing, because this makes it easier to trace what happens during a test run: * NUnit will capture anything written to Console.Out/Console.Error during a test run. * Nothing will be printed if the process crashes during a test run. * NSLog statements will be printed as they are executed, which makes it much better for figuring out what happened just before a crash when running unit tests. --- src/ObjCRuntime/Class.cs | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/ObjCRuntime/Class.cs b/src/ObjCRuntime/Class.cs index 40742d0be3..a0b50b7df1 100644 --- a/src/ObjCRuntime/Class.cs +++ b/src/ObjCRuntime/Class.cs @@ -265,7 +265,7 @@ namespace ObjCRuntime { var rv = class_map.handle; is_custom_type = (class_map.flags & Runtime.MTTypeFlags.CustomType) == Runtime.MTTypeFlags.CustomType; #if LOG_TYPELOAD - Console.WriteLine ($"FindClass ({type.FullName}, {is_custom_type}): 0x{rv.ToString ("x")} = {Marshal.PtrToStringAuto (class_getName (rv))}."); + Runtime.NSLog ($"FindClass ({type.FullName}, {is_custom_type}): 0x{rv.ToString ("x")} = {Marshal.PtrToStringAuto (class_getName (rv))}."); #endif return rv; } @@ -347,11 +347,15 @@ namespace ObjCRuntime { { var map = Runtime.options->RegistrationMap; +#if LOG_TYPELOAD + Runtime.NSLog ($"FindType (0x{@class:X} = {Marshal.PtrToStringAuto (class_getName (@class))})"); +#endif + is_custom_type = false; if (map is null) { #if LOG_TYPELOAD - Console.WriteLine ($"FindType (0x{@class:X} = {Marshal.PtrToStringAuto (class_getName (@class))}) => found no map."); + Runtime.NSLog ($"FindType (0x{@class:X} = {Marshal.PtrToStringAuto (class_getName (@class))}) => found no map."); #endif return null; } @@ -360,23 +364,30 @@ namespace ObjCRuntime { var mapIndex = FindMapIndex (map->map, 0, map->map_count - 1, @class); if (mapIndex == -1) { #if LOG_TYPELOAD - Console.WriteLine ($"FindType (0x{@class:X} = {Marshal.PtrToStringAuto (class_getName (@class))}) => found no type."); + Runtime.NSLog ($"FindType (0x{@class:X} = {Marshal.PtrToStringAuto (class_getName (@class))}) => found no type."); #endif return null; } +#if LOG_TYPELOAD + Runtime.NSLog ($"FindType (0x{@class:X} = {Marshal.PtrToStringAuto (class_getName (@class))}) => found index {mapIndex}."); +#endif is_custom_type = (map->map [mapIndex].flags & Runtime.MTTypeFlags.CustomType) == Runtime.MTTypeFlags.CustomType; var type = class_to_type [mapIndex]; - if (type is not null) + if (type is not null) { +#if LOG_TYPELOAD + Runtime.NSLog ($"FindType (0x{@class:X} = {Marshal.PtrToStringAuto (class_getName (@class))}) => found type {type.FullName} for map index {mapIndex}."); +#endif return type; + } // Resolve the map entry we found to a managed type var type_reference = map->map [mapIndex].type_reference; type = ResolveTypeTokenReference (type_reference); #if LOG_TYPELOAD - Console.WriteLine ($"FindType (0x{@class:X} = {Marshal.PtrToStringAuto (class_getName (@class))}) => {type?.FullName}; is custom: {is_custom_type} (token reference: 0x{type_reference:X})."); + Runtime.NSLog ($"FindType (0x{@class:X} = {Marshal.PtrToStringAuto (class_getName (@class))}) => {type?.FullName}; is custom: {is_custom_type} (token reference: 0x{type_reference:X})."); #endif class_to_type [mapIndex] = type; @@ -394,7 +405,7 @@ namespace ObjCRuntime { var token = entry.token; #if LOG_TYPELOAD - Console.WriteLine ($"ResolveFullTokenReference (0x{token_reference:X}) assembly name: {assembly_name} module token: 0x{module_token:X} token: 0x{token:X}."); + Runtime.NSLog ($"ResolveFullTokenReference (0x{token_reference:X}) assembly name: {assembly_name} module token: 0x{module_token:X} token: 0x{token:X}."); #endif var assembly = ResolveAssembly (assembly_name); @@ -435,7 +446,7 @@ namespace ObjCRuntime { uint token = (token_reference >> 8) + implicit_token_type; #if LOG_TYPELOAD - Console.WriteLine ($"ResolveTokenReference (0x{token_reference:X}) assembly index: {assembly_index} token: 0x{token:X}."); + Runtime.NSLog ($"ResolveTokenReference (0x{token_reference:X}) assembly index: {assembly_index} token: 0x{token:X}."); #endif var assembly_name = map->assemblies [(int) assembly_index].name; @@ -453,13 +464,13 @@ namespace ObjCRuntime { case 0x02000000: // TypeDef var type = module.ResolveType ((int) token); #if LOG_TYPELOAD - Console.WriteLine ($"ResolveToken (0x{token:X}) => Type: {type.FullName}"); + Runtime.NSLog ($"ResolveToken (0x{token:X}) => Type: {type.FullName}"); #endif return type; case 0x06000000: // Method var method = module.ResolveMethod ((int) token); #if LOG_TYPELOAD - Console.WriteLine ($"ResolveToken (0x{token:X}) => Method: {method?.DeclaringType?.FullName}.{method.Name}"); + Runtime.NSLog ($"ResolveToken (0x{token:X}) => Method: {method?.DeclaringType?.FullName}.{method?.Name}"); #endif return method; default: @@ -474,7 +485,7 @@ namespace ObjCRuntime { continue; #if LOG_TYPELOAD - Console.WriteLine ($"ResolveModule (\"{assembly.FullName}\", 0x{token:X}): {mod.Name}."); + Runtime.NSLog ($"ResolveModule (\"{assembly.FullName}\", 0x{token:X}): {mod.Name}."); #endif return mod; } @@ -548,7 +559,7 @@ namespace ObjCRuntime { continue; #if LOG_TYPELOAD - Console.WriteLine ($"TryResolveAssembly (0x{assembly_name:X}): {asm.FullName}."); + Runtime.NSLog ($"TryResolveAssembly (0x{assembly_name:X}): {asm.FullName}."); #endif assembly = asm; return true;