diff --git a/.github/workflows/localization_branch_sync.yml b/.github/workflows/localization_branch_sync.yml index e33abd1127..89810d9b8e 100644 --- a/.github/workflows/localization_branch_sync.yml +++ b/.github/workflows/localization_branch_sync.yml @@ -24,7 +24,7 @@ jobs: branches: Localization soft_fail: true - - uses: peterjgrainger/action-create-branch@v2.4.0 + - uses: peterjgrainger/action-create-branch@v3.0.0 name: 'Create Localization Branch' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/dotnet/generate-workloadmanifest-targets.csharp b/dotnet/generate-workloadmanifest-targets.csharp index a1fb37d81a..8a66f3ce6a 100755 --- a/dotnet/generate-workloadmanifest-targets.csharp +++ b/dotnet/generate-workloadmanifest-targets.csharp @@ -66,8 +66,10 @@ using (var writer = new StreamWriter (outputPath)) { } var earliestSupportedTFV = supportedTFVs.Select (v => Version.Parse (v)).OrderBy (v => v).First (); + var latestSupportedTFV = supportedTFVs.Select (v => Version.Parse (v)).OrderBy (v => v).Last (); writer.WriteLine ($" "); writer.WriteLine ($" "); + writer.WriteLine ($" "); writer.WriteLine ($" "); writer.WriteLine (); writer.WriteLine ($" "); diff --git a/dotnet/targets/Xamarin.Shared.Sdk.targets b/dotnet/targets/Xamarin.Shared.Sdk.targets index 68ea86292a..ed6f88792f 100644 --- a/dotnet/targets/Xamarin.Shared.Sdk.targets +++ b/dotnet/targets/Xamarin.Shared.Sdk.targets @@ -1252,6 +1252,7 @@ Assemblies="@(_AssembliesToAOT)" AOTCompilerPath="$(_XamarinAOTCompiler)" InputDirectory="$(_AOTInputDirectory)" + MaxDegreeOfParallelism="$(AotCompileMaxDegreeOfParallelism)" MinimumOSVersion="$(_MinimumOSVersion)" OutputDirectory="$(_AOTOutputDirectory)\%(_AssembliesToAOT.Arch)" SdkDevPath="$(_SdkDevPath)" diff --git a/msbuild/Xamarin.Localization.MSBuild/MSBStrings.resx b/msbuild/Xamarin.Localization.MSBuild/MSBStrings.resx index 5276ab5d4d..a6ba9f8fe9 100644 --- a/msbuild/Xamarin.Localization.MSBuild/MSBStrings.resx +++ b/msbuild/Xamarin.Localization.MSBuild/MSBStrings.resx @@ -1545,4 +1545,13 @@ {0}: the path to a file + + + Unable to parse the value '{0}' for the property 'MaxDegreeOfParallelism'. Falling back to the default value (number of processors / 2). + + {0}: a developer-supplied property value. + MaxDegreeOfParallelism: name of the property (do not translate) + + + diff --git a/msbuild/Xamarin.MacDev.Tasks/Tasks/AOTCompile.cs b/msbuild/Xamarin.MacDev.Tasks/Tasks/AOTCompile.cs index e3d1d2064c..354f2d87ad 100644 --- a/msbuild/Xamarin.MacDev.Tasks/Tasks/AOTCompile.cs +++ b/msbuild/Xamarin.MacDev.Tasks/Tasks/AOTCompile.cs @@ -16,7 +16,7 @@ using Xamarin.Utils; #nullable enable namespace Xamarin.MacDev.Tasks { - public class AOTCompile : XamarinTask, ITaskCallback, ICancelableTask { + public class AOTCompile : XamarinParallelTask, ITaskCallback, ICancelableTask { public ITaskItem [] AotArguments { get; set; } = Array.Empty (); [Required] @@ -314,7 +314,7 @@ namespace Xamarin.MacDev.Tasks { listOfArguments.Add (new (arguments, input)); } - Parallel.ForEach (listOfArguments, (arg) => { + ForEach (listOfArguments, (arg) => { ExecuteAsync (AOTCompilerPath, arg.Arguments, sdkDevPath: SdkDevPath, showErrorIfFailure: false /* we show our own error below */) .ContinueWith ((v) => { if (v.Result.ExitCode != 0) diff --git a/msbuild/Xamarin.MacDev.Tasks/Tasks/Codesign.cs b/msbuild/Xamarin.MacDev.Tasks/Tasks/Codesign.cs index 1c8527d96c..c6518f29dd 100644 --- a/msbuild/Xamarin.MacDev.Tasks/Tasks/Codesign.cs +++ b/msbuild/Xamarin.MacDev.Tasks/Tasks/Codesign.cs @@ -17,7 +17,7 @@ using Xamarin.Utils; #nullable disable namespace Xamarin.MacDev.Tasks { - public class Codesign : XamarinTask, ITaskCallback, ICancelableTask { + public class Codesign : XamarinParallelTask, ITaskCallback, ICancelableTask { const string ToolName = "codesign"; const string MacOSDirName = "MacOS"; const string CodeSignatureDirName = "_CodeSignature"; @@ -468,7 +468,7 @@ namespace Xamarin.MacDev.Tasks { for (var b = 0; b < buckets.Count; b++) { var bucket = buckets [b]; - Parallel.ForEach (bucket, new ParallelOptions { MaxDegreeOfParallelism = Math.Max (Environment.ProcessorCount / 2, 1) }, (item) => { + ForEach (bucket, (item) => { Sign (item); var files = GetCodesignedFiles (item.Item); diff --git a/msbuild/Xamarin.MacDev.Tasks/Tasks/ScnTool.cs b/msbuild/Xamarin.MacDev.Tasks/Tasks/ScnTool.cs index 0220c6ec39..445ceb8d46 100644 --- a/msbuild/Xamarin.MacDev.Tasks/Tasks/ScnTool.cs +++ b/msbuild/Xamarin.MacDev.Tasks/Tasks/ScnTool.cs @@ -10,7 +10,7 @@ using Xamarin.Messaging.Build.Client; using Xamarin.Utils; namespace Xamarin.MacDev.Tasks { - public class ScnTool : XamarinTask { + public class ScnTool : XamarinParallelTask { #region Inputs [Required] @@ -95,7 +95,7 @@ namespace Xamarin.MacDev.Tasks { bundleResources.Add (bundleResource); } - Parallel.ForEach (listOfArguments, (arg) => { + ForEach (listOfArguments, (arg) => { ExecuteAsync ("xcrun", arg.Arguments, sdkDevPath: SdkDevPath).Wait (); }); diff --git a/msbuild/Xamarin.MacDev.Tasks/Tasks/SymbolStrip.cs b/msbuild/Xamarin.MacDev.Tasks/Tasks/SymbolStrip.cs index b961079caa..d61a4d296d 100644 --- a/msbuild/Xamarin.MacDev.Tasks/Tasks/SymbolStrip.cs +++ b/msbuild/Xamarin.MacDev.Tasks/Tasks/SymbolStrip.cs @@ -12,7 +12,7 @@ using Xamarin.Messaging.Build.Client; #nullable enable namespace Xamarin.MacDev.Tasks { - public class SymbolStrip : XamarinTask, ITaskCallback { + public class SymbolStrip : XamarinParallelTask, ITaskCallback { #region Inputs [Required] @@ -60,7 +60,7 @@ namespace Xamarin.MacDev.Tasks { if (ShouldExecuteRemotely ()) return new TaskRunner (SessionId, BuildEngine4).RunAsync (this).Result; - Parallel.ForEach (Executable, new ParallelOptions { MaxDegreeOfParallelism = Math.Max (Environment.ProcessorCount / 2, 1) }, (item) => { + ForEach (Executable, (item) => { ExecuteStrip (item); }); diff --git a/msbuild/Xamarin.MacDev.Tasks/Tasks/XamarinParallelTask.cs b/msbuild/Xamarin.MacDev.Tasks/Tasks/XamarinParallelTask.cs new file mode 100644 index 0000000000..528f8c5972 --- /dev/null +++ b/msbuild/Xamarin.MacDev.Tasks/Tasks/XamarinParallelTask.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; + +using Xamarin.Localization.MSBuild; +using Xamarin.Utils; + +#nullable enable + +namespace Xamarin.MacDev.Tasks { + public abstract class XamarinParallelTask : XamarinTask { + // How many tasks we execute in parallel. Default is number of processors / 2. + public string MaxDegreeOfParallelism { get; set; } = string.Empty; + + int GetMaxDegreeOfParallelism () + { + if (!string.IsNullOrEmpty (MaxDegreeOfParallelism)) { + if (int.TryParse (MaxDegreeOfParallelism, out var max)) + return max; + Log.LogWarning (MSBStrings.W7121 /* Unable to parse the value '{0}' for the property 'MaxDegreeOfParallelism'. Falling back to the default value (number of processors / 2). */, MaxDegreeOfParallelism); + } + return Math.Max (Environment.ProcessorCount / 2, 1); + } + + protected void ForEach (IEnumerable source, Action body) + { + var options = new ParallelOptions { MaxDegreeOfParallelism = GetMaxDegreeOfParallelism () }; + Parallel.ForEach (source, options, body); + } + } +} diff --git a/msbuild/Xamarin.Shared/Xamarin.Shared.targets b/msbuild/Xamarin.Shared/Xamarin.Shared.targets index a5b9bb0b13..530c65ee96 100644 --- a/msbuild/Xamarin.Shared/Xamarin.Shared.targets +++ b/msbuild/Xamarin.Shared/Xamarin.Shared.targets @@ -1070,6 +1070,7 @@ Copyright (C) 2018 Microsoft. All rights reserved. Condition="'$(IsMacEnabled)' == 'true'" DeviceSpecificIntermediateOutputPath="$(DeviceSpecificIntermediateOutputPath)" IsWatchApp="$(IsWatchApp)" + MaxDegreeOfParallelism="$(ColladaMaxDegreeOfParallelism)" ProjectDir="$(MSBuildProjectDirectory)" ResourcePrefix="$(_ResourcePrefix)" SdkPlatform="$(_SdkPlatform)" @@ -2257,6 +2258,7 @@ Copyright (C) 2018 Microsoft. All rights reserved. diff --git a/src/CoreGraphics/CGPDFArray.cs b/src/CoreGraphics/CGPDFArray.cs index f6eab3cdb4..e006417903 100644 --- a/src/CoreGraphics/CGPDFArray.cs +++ b/src/CoreGraphics/CGPDFArray.cs @@ -31,6 +31,7 @@ #nullable enable using System; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Foundation; using ObjCRuntime; @@ -76,65 +77,73 @@ namespace CoreGraphics { // CGPDFBoolean -> unsigned char -> CGPDFObject.h [DllImport (Constants.CoreGraphicsLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - extern static bool CGPDFArrayGetBoolean (/* CGPDFArrayRef */ IntPtr array, /* size_t */ nint index, /* CGPDFBoolean* */ [MarshalAs (UnmanagedType.I1)] out bool value); + unsafe extern static byte CGPDFArrayGetBoolean (/* CGPDFArrayRef */ IntPtr array, /* size_t */ nint index, /* CGPDFBoolean* */ byte* value); - public bool GetBoolean (nint idx, out bool result) + public unsafe bool GetBoolean (nint idx, out bool result) { - return CGPDFArrayGetBoolean (Handle, idx, out result); + byte res = 0; + var rv = CGPDFArrayGetBoolean (Handle, idx, &res) != 0; + result = res != 0; + return rv; } #if !NET public bool GetBoolean (int idx, out bool result) { - return CGPDFArrayGetBoolean (Handle, idx, out result); + return GetBoolean ((nint) idx, out result); } #endif // CGPDFInteger -> long int 32/64 bits -> CGPDFObject.h [DllImport (Constants.CoreGraphicsLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - extern static bool CGPDFArrayGetInteger (/* CGPDFArrayRef */ IntPtr array, /* size_t */ nint index, /* CGPDFInteger* */ out nint value); + unsafe extern static byte CGPDFArrayGetInteger (/* CGPDFArrayRef */ IntPtr array, /* size_t */ nint index, /* CGPDFInteger* */ nint* value); public bool GetInt (nint idx, out nint result) { - return CGPDFArrayGetInteger (Handle, idx, out result); + result = default; + unsafe { + return CGPDFArrayGetInteger (Handle, idx, (nint*) Unsafe.AsPointer (ref result)) != 0; + } } #if !NET public bool GetInt (int idx, out nint result) { - return CGPDFArrayGetInteger (Handle, idx, out result); + return GetInt ((nint) idx, out result); } #endif // CGPDFReal -> CGFloat -> CGPDFObject.h [DllImport (Constants.CoreGraphicsLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - extern static bool CGPDFArrayGetNumber (/* CGPDFArrayRef */ IntPtr array, /* size_t */ nint index, /* CGPDFReal* */ out nfloat value); + unsafe extern static byte CGPDFArrayGetNumber (/* CGPDFArrayRef */ IntPtr array, /* size_t */ nint index, /* CGPDFReal* */ nfloat* value); public bool GetFloat (nint idx, out nfloat result) { - return CGPDFArrayGetNumber (Handle, idx, out result); + result = default; + unsafe { + return CGPDFArrayGetNumber (Handle, idx, (nfloat*) Unsafe.AsPointer (ref result)) != 0; + } } #if !NET public bool GetFloat (int idx, out nfloat result) { - return CGPDFArrayGetNumber (Handle, idx, out result); + return GetFloat ((nint) idx, out result); } #endif [DllImport (Constants.CoreGraphicsLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - extern static bool CGPDFArrayGetName (/* CGPDFArrayRef */ IntPtr array, /* size_t */ nint index, /* const char** */ out IntPtr value); + unsafe extern static byte CGPDFArrayGetName (/* CGPDFArrayRef */ IntPtr array, /* size_t */ nint index, /* const char** */ IntPtr* value); public bool GetName (nint idx, out string? result) { IntPtr res; - var r = CGPDFArrayGetName (Handle, idx, out res); + bool r; + unsafe { + r = CGPDFArrayGetName (Handle, idx, &res) != 0; + } result = r ? Marshal.PtrToStringAnsi (res) : null; return r; } @@ -147,12 +156,15 @@ namespace CoreGraphics { #endif [DllImport (Constants.CoreGraphicsLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - extern static bool CGPDFArrayGetDictionary (/* CGPDFArrayRef */ IntPtr array, /* size_t */ nint index, /* CGPDFDictionaryRef* */ out IntPtr value); + unsafe extern static byte CGPDFArrayGetDictionary (/* CGPDFArrayRef */ IntPtr array, /* size_t */ nint index, /* CGPDFDictionaryRef* */ IntPtr* value); public bool GetDictionary (nint idx, out CGPDFDictionary? result) { - var r = CGPDFArrayGetDictionary (Handle, idx, out var res); + IntPtr res; + bool r; + unsafe { + r = CGPDFArrayGetDictionary (Handle, idx, &res) != 0; + } result = r ? new CGPDFDictionary (res) : null; return r; } @@ -165,12 +177,15 @@ namespace CoreGraphics { #endif [DllImport (Constants.CoreGraphicsLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - extern static bool CGPDFArrayGetStream (/* CGPDFArrayRef */ IntPtr array, /* size_t */ nint index, /* CGPDFStreamRef* */ out IntPtr value); + unsafe extern static byte CGPDFArrayGetStream (/* CGPDFArrayRef */ IntPtr array, /* size_t */ nint index, /* CGPDFStreamRef* */ IntPtr* value); public bool GetStream (nint idx, out CGPDFStream? result) { - var r = CGPDFArrayGetStream (Handle, idx, out var ptr); + IntPtr ptr; + bool r; + unsafe { + r = CGPDFArrayGetStream (Handle, idx, &ptr) != 0; + } result = r ? new CGPDFStream (ptr) : null; return r; } @@ -183,12 +198,15 @@ namespace CoreGraphics { #endif [DllImport (Constants.CoreGraphicsLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - extern static bool CGPDFArrayGetArray (/* CGPDFArrayRef */ IntPtr array, /* size_t */ nint index, /* CGPDFArrayRef* */ out IntPtr value); + unsafe extern static byte CGPDFArrayGetArray (/* CGPDFArrayRef */ IntPtr array, /* size_t */ nint index, /* CGPDFArrayRef* */ IntPtr* value); public bool GetArray (nint idx, out CGPDFArray? array) { - var r = CGPDFArrayGetArray (Handle, idx, out var ptr); + bool r; + IntPtr ptr; + unsafe { + r = CGPDFArrayGetArray (Handle, idx, &ptr) != 0; + } array = r ? new CGPDFArray (ptr) : null; return r; } @@ -201,12 +219,15 @@ namespace CoreGraphics { #endif [DllImport (Constants.CoreGraphicsLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - extern static bool CGPDFArrayGetString (/* CGPDFArrayRef */ IntPtr array, /* size_t */ nint index, /* CGPDFStringRef* */ out IntPtr value); + unsafe extern static byte CGPDFArrayGetString (/* CGPDFArrayRef */ IntPtr array, /* size_t */ nint index, /* CGPDFStringRef* */ IntPtr* value); public bool GetString (nint idx, out string? result) { - var r = CGPDFArrayGetString (Handle, idx, out var res); + IntPtr res; + bool r; + unsafe { + r = CGPDFArrayGetString (Handle, idx, &res) != 0; + } result = r ? CGPDFString.ToString (res) : null; return r; } @@ -250,8 +271,7 @@ namespace CoreGraphics { [Watch (5, 0)] #endif [DllImport (Constants.CoreGraphicsLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - unsafe extern static bool CGPDFArrayApplyBlock (/* CGPDFArrayRef */ IntPtr array, /* CGPDFArrayApplierBlock */ BlockLiteral* block, /* void* */ IntPtr info); + unsafe extern static byte CGPDFArrayApplyBlock (/* CGPDFArrayRef */ IntPtr array, /* CGPDFArrayApplierBlock */ BlockLiteral* block, /* void* */ IntPtr info); #if NET [SupportedOSPlatform ("ios")] @@ -277,7 +297,7 @@ namespace CoreGraphics { #endif var gc_handle = info is null ? default (GCHandle) : GCHandle.Alloc (info); try { - return CGPDFArrayApplyBlock (Handle, &block, info is null ? IntPtr.Zero : GCHandle.ToIntPtr (gc_handle)); + return CGPDFArrayApplyBlock (Handle, &block, info is null ? IntPtr.Zero : GCHandle.ToIntPtr (gc_handle)) != 0; } finally { if (info is not null) gc_handle.Free (); diff --git a/src/CoreGraphics/CGPath.cs b/src/CoreGraphics/CGPath.cs index 375888eeee..ced5e16217 100644 --- a/src/CoreGraphics/CGPath.cs +++ b/src/CoreGraphics/CGPath.cs @@ -32,6 +32,7 @@ using System; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using CoreFoundation; @@ -97,10 +98,10 @@ namespace CoreGraphics { } [DllImport (Constants.CoreGraphicsLibrary)] - extern static /* CGMutablePathRef */ IntPtr CGPathCreateMutableCopyByTransformingPath (/* CGPathRef */ IntPtr path, /* const CGAffineTransform* */ ref CGAffineTransform transform); + unsafe extern static /* CGMutablePathRef */ IntPtr CGPathCreateMutableCopyByTransformingPath (/* CGPathRef */ IntPtr path, /* const CGAffineTransform* */ CGAffineTransform* transform); - public CGPath (CGPath reference, CGAffineTransform transform) - : base (CGPathCreateMutableCopyByTransformingPath (Runtime.ThrowOnNull (reference, nameof (reference)).Handle, ref transform), true) + public unsafe CGPath (CGPath reference, CGAffineTransform transform) + : base (CGPathCreateMutableCopyByTransformingPath (Runtime.ThrowOnNull (reference, nameof (reference)).Handle, &transform), true) { } @@ -142,8 +143,7 @@ namespace CoreGraphics { } [DllImport (Constants.CoreGraphicsLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - extern static bool CGPathEqualToPath (/* CGPathRef */ IntPtr path1, /* CGPathRef */ IntPtr path2); + extern static byte CGPathEqualToPath (/* CGPathRef */ IntPtr path1, /* CGPathRef */ IntPtr path2); public static bool operator == (CGPath? path1, CGPath? path2) { @@ -173,7 +173,7 @@ namespace CoreGraphics { if (other is null) return false; - return CGPathEqualToPath (this.Handle, other.Handle); + return CGPathEqualToPath (this.Handle, other.Handle) != 0; } [DllImport (Constants.CoreGraphicsLibrary)] @@ -363,16 +363,16 @@ namespace CoreGraphics { } [DllImport (Constants.CoreGraphicsLibrary)] - unsafe extern static void CGPathAddArc (/* CGMutablePathRef */ IntPtr path, CGAffineTransform* m, /* CGFloat */ nfloat x, /* CGFloat */ nfloat y, /* CGFloat */ nfloat radius, /* CGFloat */ nfloat startAngle, /* CGFloat */ nfloat endAngle, [MarshalAs (UnmanagedType.I1)] bool clockwise); + unsafe extern static void CGPathAddArc (/* CGMutablePathRef */ IntPtr path, CGAffineTransform* m, /* CGFloat */ nfloat x, /* CGFloat */ nfloat y, /* CGFloat */ nfloat radius, /* CGFloat */ nfloat startAngle, /* CGFloat */ nfloat endAngle, byte clockwise); public unsafe void AddArc (CGAffineTransform m, nfloat x, nfloat y, nfloat radius, nfloat startAngle, nfloat endAngle, bool clockwise) { - CGPathAddArc (Handle, &m, x, y, radius, startAngle, endAngle, clockwise); + CGPathAddArc (Handle, &m, x, y, radius, startAngle, endAngle, clockwise.AsByte ()); } public unsafe void AddArc (nfloat x, nfloat y, nfloat radius, nfloat startAngle, nfloat endAngle, bool clockwise) { - CGPathAddArc (Handle, null, x, y, radius, startAngle, endAngle, clockwise); + CGPathAddArc (Handle, null, x, y, radius, startAngle, endAngle, clockwise.AsByte ()); } [DllImport (Constants.CoreGraphicsLibrary)] @@ -419,22 +419,23 @@ namespace CoreGraphics { } [DllImport (Constants.CoreGraphicsLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - extern static bool CGPathIsEmpty (/* CGPathRef */ IntPtr path); + extern static byte CGPathIsEmpty (/* CGPathRef */ IntPtr path); public bool IsEmpty { get { - return CGPathIsEmpty (Handle); + return CGPathIsEmpty (Handle) != 0; } } [DllImport (Constants.CoreGraphicsLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - extern static bool CGPathIsRect (/* CGPathRef */ IntPtr path, out CGRect rect); + unsafe extern static byte CGPathIsRect (/* CGPathRef */ IntPtr path, CGRect* rect); public bool IsRect (out CGRect rect) { - return CGPathIsRect (Handle, out rect); + unsafe { + rect = default; + return CGPathIsRect (Handle, (CGRect*) Unsafe.AsPointer (ref rect)) != 0; + } } [DllImport (Constants.CoreGraphicsLibrary)] @@ -465,17 +466,16 @@ namespace CoreGraphics { } [DllImport (Constants.CoreGraphicsLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - unsafe extern static bool CGPathContainsPoint (IntPtr path, CGAffineTransform* m, CGPoint point, [MarshalAs (UnmanagedType.I1)] bool eoFill); + unsafe extern static byte CGPathContainsPoint (IntPtr path, CGAffineTransform* m, CGPoint point, byte eoFill); public unsafe bool ContainsPoint (CGAffineTransform m, CGPoint point, bool eoFill) { - return CGPathContainsPoint (Handle, &m, point, eoFill); + return CGPathContainsPoint (Handle, &m, point, eoFill.AsByte ()) != 0; } public unsafe bool ContainsPoint (CGPoint point, bool eoFill) { - return CGPathContainsPoint (Handle, null, point, eoFill); + return CGPathContainsPoint (Handle, null, point, eoFill.AsByte ()) != 0; } public delegate void ApplierFunction (CGPathElement element); @@ -554,11 +554,11 @@ namespace CoreGraphics { [Mac (13, 0), iOS (16, 0), TV (16, 0), MacCatalyst (16, 0), Watch (9, 0)] #endif [DllImport (Constants.CoreGraphicsLibrary)] - static extern IntPtr CGPathCreateCopyByNormalizing (IntPtr path, [MarshalAs (UnmanagedType.I1)] bool evenOddFillRule); + static extern IntPtr CGPathCreateCopyByNormalizing (IntPtr path, byte evenOddFillRule); public CGPath? CreateByNormalizing (bool evenOddFillRule) { - return Runtime.GetINativeObject (CGPathCreateCopyByNormalizing (Handle, evenOddFillRule), owns: true); + return Runtime.GetINativeObject (CGPathCreateCopyByNormalizing (Handle, evenOddFillRule.AsByte ()), owns: true); } #if NET @@ -570,11 +570,11 @@ namespace CoreGraphics { [Mac (13, 0), iOS (16, 0), TV (16, 0), MacCatalyst (16, 0), Watch (9, 0)] #endif [DllImport (Constants.CoreGraphicsLibrary)] - static extern IntPtr CGPathCreateCopyByUnioningPath (IntPtr path, IntPtr maskPath, [MarshalAs (UnmanagedType.I1)] bool evenOddFillRule); + static extern IntPtr CGPathCreateCopyByUnioningPath (IntPtr path, IntPtr maskPath, byte evenOddFillRule); public CGPath? CreateByUnioningPath (CGPath? maskPath, bool evenOddFillRule) { - return Runtime.GetINativeObject (CGPathCreateCopyByUnioningPath (Handle, maskPath.GetHandle (), evenOddFillRule), owns: true); + return Runtime.GetINativeObject (CGPathCreateCopyByUnioningPath (Handle, maskPath.GetHandle (), evenOddFillRule.AsByte ()), owns: true); } #if NET @@ -586,11 +586,11 @@ namespace CoreGraphics { [Mac (13, 0), iOS (16, 0), TV (16, 0), MacCatalyst (16, 0), Watch (9, 0)] #endif [DllImport (Constants.CoreGraphicsLibrary)] - static extern IntPtr CGPathCreateCopyByIntersectingPath (IntPtr path, IntPtr maskPath, [MarshalAs (UnmanagedType.I1)] bool evenOddFillRule); + static extern IntPtr CGPathCreateCopyByIntersectingPath (IntPtr path, IntPtr maskPath, byte evenOddFillRule); public CGPath? CreateByIntersectingPath (CGPath? maskPath, bool evenOddFillRule) { - return Runtime.GetINativeObject (CGPathCreateCopyByIntersectingPath (Handle, maskPath.GetHandle (), evenOddFillRule), owns: true); + return Runtime.GetINativeObject (CGPathCreateCopyByIntersectingPath (Handle, maskPath.GetHandle (), evenOddFillRule.AsByte ()), owns: true); } #if NET @@ -602,11 +602,11 @@ namespace CoreGraphics { [Mac (13, 0), iOS (16, 0), TV (16, 0), MacCatalyst (16, 0), Watch (9, 0)] #endif [DllImport (Constants.CoreGraphicsLibrary)] - static extern IntPtr CGPathCreateCopyBySubtractingPath (IntPtr path, IntPtr maskPath, [MarshalAs (UnmanagedType.I1)] bool evenOddFillRule); + static extern IntPtr CGPathCreateCopyBySubtractingPath (IntPtr path, IntPtr maskPath, byte evenOddFillRule); public CGPath? CreateBySubtractingPath (CGPath? maskPath, bool evenOddFillRule) { - return Runtime.GetINativeObject (CGPathCreateCopyBySubtractingPath (Handle, maskPath.GetHandle (), evenOddFillRule), owns: true); + return Runtime.GetINativeObject (CGPathCreateCopyBySubtractingPath (Handle, maskPath.GetHandle (), evenOddFillRule.AsByte ()), owns: true); } #if NET @@ -618,11 +618,11 @@ namespace CoreGraphics { [Mac (13, 0), iOS (16, 0), TV (16, 0), MacCatalyst (16, 0), Watch (9, 0)] #endif [DllImport (Constants.CoreGraphicsLibrary)] - static extern IntPtr CGPathCreateCopyBySymmetricDifferenceOfPath (IntPtr path, IntPtr maskPath, [MarshalAs (UnmanagedType.I1)] bool evenOddFillRule); + static extern IntPtr CGPathCreateCopyBySymmetricDifferenceOfPath (IntPtr path, IntPtr maskPath, byte evenOddFillRule); public CGPath? CreateBySymmetricDifferenceOfPath (CGPath? maskPath, bool evenOddFillRule) { - return Runtime.GetINativeObject (CGPathCreateCopyBySymmetricDifferenceOfPath (Handle, maskPath.GetHandle (), evenOddFillRule), owns: true); + return Runtime.GetINativeObject (CGPathCreateCopyBySymmetricDifferenceOfPath (Handle, maskPath.GetHandle (), evenOddFillRule.AsByte ()), owns: true); } #if NET @@ -634,11 +634,11 @@ namespace CoreGraphics { [Mac (13, 0), iOS (16, 0), TV (16, 0), MacCatalyst (16, 0), Watch (9, 0)] #endif [DllImport (Constants.CoreGraphicsLibrary)] - static extern IntPtr CGPathCreateCopyOfLineBySubtractingPath (IntPtr path, IntPtr maskPath, [MarshalAs (UnmanagedType.I1)] bool evenOddFillRule); + static extern IntPtr CGPathCreateCopyOfLineBySubtractingPath (IntPtr path, IntPtr maskPath, byte evenOddFillRule); public CGPath? CreateLineBySubtractingPath (CGPath? maskPath, bool evenOddFillRule) { - return Runtime.GetINativeObject (CGPathCreateCopyOfLineBySubtractingPath (Handle, maskPath.GetHandle (), evenOddFillRule), owns: true); + return Runtime.GetINativeObject (CGPathCreateCopyOfLineBySubtractingPath (Handle, maskPath.GetHandle (), evenOddFillRule.AsByte ()), owns: true); } #if NET @@ -650,11 +650,11 @@ namespace CoreGraphics { [Mac (13, 0), iOS (16, 0), TV (16, 0), MacCatalyst (16, 0), Watch (9, 0)] #endif [DllImport (Constants.CoreGraphicsLibrary)] - static extern IntPtr CGPathCreateCopyOfLineByIntersectingPath (IntPtr path, IntPtr maskPath, [MarshalAs (UnmanagedType.I1)] bool evenOddFillRule); + static extern IntPtr CGPathCreateCopyOfLineByIntersectingPath (IntPtr path, IntPtr maskPath, byte evenOddFillRule); public CGPath? CreateLineByIntersectingPath (CGPath? maskPath, bool evenOddFillRule) { - return Runtime.GetINativeObject (CGPathCreateCopyOfLineByIntersectingPath (Handle, maskPath.GetHandle (), evenOddFillRule), owns: true); + return Runtime.GetINativeObject (CGPathCreateCopyOfLineByIntersectingPath (Handle, maskPath.GetHandle (), evenOddFillRule.AsByte ()), owns: true); } #if NET @@ -666,11 +666,11 @@ namespace CoreGraphics { [Mac (13, 0), iOS (16, 0), TV (16, 0), MacCatalyst (16, 0), Watch (9, 0)] #endif [DllImport (Constants.CoreGraphicsLibrary)] - static extern unsafe /* CFArrayRef __nullable */ IntPtr CGPathCreateSeparateComponents (IntPtr path, [MarshalAs (UnmanagedType.I1)] bool evenOddFillRule); + static extern unsafe /* CFArrayRef __nullable */ IntPtr CGPathCreateSeparateComponents (IntPtr path, byte evenOddFillRule); public CGPath [] GetSeparateComponents (bool evenOddFillRule) { - var cfArrayRef = CGPathCreateSeparateComponents (Handle, evenOddFillRule); + var cfArrayRef = CGPathCreateSeparateComponents (Handle, evenOddFillRule.AsByte ()); if (cfArrayRef == IntPtr.Zero) return Array.Empty (); return NSArray.ArrayFromHandle (cfArrayRef); @@ -701,12 +701,11 @@ namespace CoreGraphics { [Mac (13, 0), iOS (16, 0), TV (16, 0), MacCatalyst (16, 0), Watch (9, 0)] #endif [DllImport (Constants.CoreGraphicsLibrary)] - [return: MarshalAs (UnmanagedType.I1)] - static extern bool CGPathIntersectsPath (IntPtr path1, IntPtr path2, [MarshalAs (UnmanagedType.I1)] bool evenOddFillRule); + static extern byte CGPathIntersectsPath (IntPtr path1, IntPtr path2, byte evenOddFillRule); public bool DoesIntersect (CGPath? maskPath, bool evenOddFillRule) { - return CGPathIntersectsPath (Handle, maskPath.GetHandle (), evenOddFillRule); + return CGPathIntersectsPath (Handle, maskPath.GetHandle (), evenOddFillRule.AsByte ()) != 0; } static CGPath MakeMutable (IntPtr source, bool owns) @@ -769,11 +768,13 @@ namespace CoreGraphics { } [DllImport (Constants.CoreGraphicsLibrary)] - extern static IntPtr CGPathCreateCopyByTransformingPath (/* CGPathRef */ IntPtr path, ref CGAffineTransform transform); + unsafe extern static IntPtr CGPathCreateCopyByTransformingPath (/* CGPathRef */ IntPtr path, CGAffineTransform* transform); public CGPath CopyByTransformingPath (CGAffineTransform transform) { - return MakeMutable (CGPathCreateCopyByTransformingPath (Handle, ref transform), true); + unsafe { + return MakeMutable (CGPathCreateCopyByTransformingPath (Handle, &transform), true); + } } [DllImport (Constants.CoreGraphicsLibrary)] diff --git a/src/Foundation/NSObject2.cs b/src/Foundation/NSObject2.cs index 514a9cbf7a..4ec5f625f2 100644 --- a/src/Foundation/NSObject2.cs +++ b/src/Foundation/NSObject2.cs @@ -20,6 +20,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // using System; +using System.Diagnostics.CodeAnalysis; using System.Reflection; using System.Collections.Generic; using System.ComponentModel; @@ -252,9 +253,17 @@ namespace Foundation { GC.SuppressFinalize (this); } +#if NET + // This method should never be called when using the managed static registrar, so assert that never happens by throwing an exception in that case. + // This method doesn't necessarily work with NativeAOT, but this is covered by the exception, because the managed static registrar is required for NativeAOT. + // + // IL2072: 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors', 'DynamicallyAccessedMemberTypes.NonPublicConstructors' in call to 'System.Runtime.CompilerServices.RuntimeHelpers.GetUninitializedObject(Type)'. The return value of method 'ObjCRuntime.Runtime.GetGCHandleTarget(IntPtr)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to. + [UnconditionalSuppressMessage("", "IL2072", Justification = "The APIs this method tries to access are marked by other means, so this is linker-safe.")] +#endif internal static IntPtr CreateNSObject (IntPtr type_gchandle, IntPtr handle, Flags flags) { #if NET + // Note that the code in this method doesn't necessarily work with NativeAOT, so assert that never happens by throwing an exception if using the managed static registrar (which is required for NativeAOT) if (Runtime.IsManagedStaticRegistrar) { throw new System.Diagnostics.UnreachableException (); } diff --git a/src/NativeTypes/Drawing.tt b/src/NativeTypes/Drawing.tt index 2d88893e7a..f09e5d2f9c 100644 --- a/src/NativeTypes/Drawing.tt +++ b/src/NativeTypes/Drawing.tt @@ -28,6 +28,7 @@ using System; using System.Drawing; #endif using System.Globalization; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Foundation; @@ -173,7 +174,10 @@ namespace CoreGraphics <#= type.ArgName #> = Empty; return false; } - return NativeDrawingMethods.<#= type.Name #>MakeWithDictionaryRepresentation (dictionaryRepresentation.Handle, out <#=type.ArgName#>); + unsafe { + <#=type.ArgName#> = default; + return NativeDrawingMethods.<#= type.Name #>MakeWithDictionaryRepresentation (dictionaryRepresentation.Handle, (<#= type.Name #> *) Unsafe.AsPointer<<#= type.Name #>> (ref <#=type.ArgName#>)) != 0; + } } public NSDictionary ToDictionary () @@ -604,7 +608,10 @@ namespace CoreGraphics rect = Empty; return false; } - return NativeDrawingMethods.CGRectMakeWithDictionaryRepresentation (dictionaryRepresentation.Handle, out rect); + rect = default; + unsafe { + return NativeDrawingMethods.CGRectMakeWithDictionaryRepresentation (dictionaryRepresentation.Handle, (CGRect *) Unsafe.AsPointer (ref rect)) != 0; + } } public NSDictionary ToDictionary () @@ -622,14 +629,11 @@ namespace CoreGraphics internal const string CG = Constants.CoreGraphicsLibrary; #endif [DllImport (CG)] - [return: MarshalAs (UnmanagedType.I1)] - internal extern static bool CGRectMakeWithDictionaryRepresentation (IntPtr dict, out CGRect rect); + internal unsafe extern static byte CGRectMakeWithDictionaryRepresentation (IntPtr dict, CGRect* rect); [DllImport (CG)] - [return: MarshalAs (UnmanagedType.I1)] - internal extern static bool CGPointMakeWithDictionaryRepresentation (IntPtr dict, out CGPoint point); + internal unsafe extern static byte CGPointMakeWithDictionaryRepresentation (IntPtr dict, CGPoint* point); [DllImport (CG)] - [return: MarshalAs (UnmanagedType.I1)] - internal extern static bool CGSizeMakeWithDictionaryRepresentation (IntPtr dict, out CGSize point); + internal unsafe extern static byte CGSizeMakeWithDictionaryRepresentation (IntPtr dict, CGSize* point); [DllImport (CG)] internal extern static IntPtr CGRectCreateDictionaryRepresentation (CGRect rect); diff --git a/src/ObjCRuntime/BlockCallbackAttribute.cs b/src/ObjCRuntime/BlockCallbackAttribute.cs new file mode 100644 index 0000000000..eac616d8b9 --- /dev/null +++ b/src/ObjCRuntime/BlockCallbackAttribute.cs @@ -0,0 +1,20 @@ +using System; + +namespace ObjCRuntime { + /// + /// This attribute is applied to delegate parameters in a delegate to specify + /// that the delegate parameter needs an Objective-C Block-style bridge. + /// + /// + /// + /// + [AttributeUsage (AttributeTargets.Parameter, AllowMultiple = false)] + public class BlockCallbackAttribute : Attribute { + /// + /// Initializes a new instance of the class. + /// + public BlockCallbackAttribute () + { + } + } +} diff --git a/src/ObjCRuntime/Blocks.cs b/src/ObjCRuntime/Blocks.cs index 43a3e535ef..7a68a2fc19 100644 --- a/src/ObjCRuntime/Blocks.cs +++ b/src/ObjCRuntime/Blocks.cs @@ -25,6 +25,7 @@ // // using System; +using System.Diagnostics.CodeAnalysis; using System.Reflection; using System.Collections.Generic; using System.ComponentModel; @@ -404,8 +405,23 @@ namespace ObjCRuntime { return descriptor->copy_helper == ((BlockDescriptor*) literal->block_descriptor)->copy_helper; } +#if NET + // This method should never be called when using the managed static registrar, so assert that never happens by throwing an exception in that case. + // This method doesn't necessarily work with NativeAOT, but this is covered by the exception, because the managed static registrar is required for NativeAOT. + // + // IL2075: 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'System.Type.GetInterfaces()'. The return value of method 'System.Reflection.MemberInfo.DeclaringType.get' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to. + [UnconditionalSuppressMessage("", "IL2075", Justification = "The APIs this method tries to access are marked by other means, so this is linker-safe.")] + // IL2062: Value passed to parameter 'interfaceType' of method 'System.Type.GetInterfaceMap(Type)' can not be statically determined and may not meet 'DynamicallyAccessedMembersAttribute' requirements. + [UnconditionalSuppressMessage("", "IL2062", Justification = "The APIs this method tries to access are marked by other means, so this is linker-safe.")] +#endif static Type GetDelegateProxyType (MethodInfo minfo, uint token_ref, out MethodInfo baseMethod) { +#if NET + // Note that the code in this method doesn't necessarily work with NativeAOT, so assert that never happens by throwing an exception if using the managed static registrar (which is required for NativeAOT) + if (Runtime.IsManagedStaticRegistrar) + throw new System.Diagnostics.UnreachableException (); +#endif + // A mirror of this method is also implemented in StaticRegistrar:GetDelegateProxyType // If this method is changed, that method will probably have to be updated too (tests!!!) baseMethod = null; @@ -492,8 +508,22 @@ namespace ObjCRuntime { } [BindingImpl (BindingImplOptions.Optimizable)] +#if NET + // This method should never be called when using the managed static registrar, so assert that never happens by throwing an exception in that case. + // This method doesn't necessarily work with NativeAOT, but this is covered by the exception, because the managed static registrar is required for NativeAOT. + // + // IL2075: 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.NonPublicFields' in call to 'System.Type.GetField(String, BindingFlags)'. The return value of method 'ObjCRuntime.BlockLiteral.GetDelegateProxyType(MethodInfo, UInt32, MethodInfo&)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to. + // IL2075: 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Type.GetMethod(String, BindingFlags)'. The return value of method 'ObjCRuntime.BlockLiteral.GetDelegateProxyType(MethodInfo, UInt32, MethodInfo&)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to." + [UnconditionalSuppressMessage("", "IL2075", Justification = "The APIs this method tries to access are marked by other means, so this is linker-safe.")] +#endif internal static IntPtr GetBlockForDelegate (MethodInfo minfo, object @delegate, uint token_ref, string signature) { +#if NET + // Note that the code in this method doesn't necessarily work with NativeAOT, so assert that never happens by throwing an exception if using the managed static registrar (which is required for NativeAOT) + if (Runtime.IsManagedStaticRegistrar) + throw new System.Diagnostics.UnreachableException (); +#endif + if (@delegate is null) return IntPtr.Zero; diff --git a/src/ObjCRuntime/CCallbackAttribute.cs b/src/ObjCRuntime/CCallbackAttribute.cs new file mode 100644 index 0000000000..fce65a0d5b --- /dev/null +++ b/src/ObjCRuntime/CCallbackAttribute.cs @@ -0,0 +1,20 @@ +using System; + +namespace ObjCRuntime { + /// + /// This attribute is applied to delegate parameters in a delegate to specify + /// that the delegate parameter needs an C-style bridge. + /// + /// + /// + /// + [AttributeUsage (AttributeTargets.Parameter, AllowMultiple = false)] + public class CCallbackAttribute : Attribute { + /// + /// Initializes a new instance of the class. + /// + public CCallbackAttribute () + { + } + } +} diff --git a/src/audiounit.cs b/src/audiounit.cs index 4a7a95f601..828b85e98b 100644 --- a/src/audiounit.cs +++ b/src/audiounit.cs @@ -1,4 +1,4 @@ -/// +// // Authors: // Miguel de Icaza (miguel@xamarin.com) // diff --git a/src/bgen/Attributes.cs b/src/bgen/Attributes.cs index 23d5d91e3d..7166f07d94 100644 --- a/src/bgen/Attributes.cs +++ b/src/bgen/Attributes.cs @@ -368,18 +368,6 @@ public class AlignAttribute : Attribute { public class ParamsAttribute : Attribute { } -// -// These two attributes can be applied to parameters in a C# delegate -// declaration to specify what kind of bridge needs to be provided on -// callback. Either a Block style setup, or a C-style setup -// -[AttributeUsage (AttributeTargets.Parameter, AllowMultiple = false)] -public class BlockCallbackAttribute : Attribute { } - -[AttributeUsage (AttributeTargets.Parameter, AllowMultiple = false)] -public class CCallbackAttribute : Attribute { } - - // // When applied, flags the [Flags] as a notification and generates the // code to strongly type the notification. diff --git a/src/bgen/Generator.cs b/src/bgen/Generator.cs index 2502dea8ed..fbf815f36e 100644 --- a/src/bgen/Generator.cs +++ b/src/bgen/Generator.cs @@ -6813,12 +6813,17 @@ public partial class Generator : IMemberGatherer { { var pt = p.ParameterType; - string name; + string name = string.Empty; + if (AttributeManager.HasAttribute (p)) + name = "[BlockCallback] "; + else if (AttributeManager.HasAttribute (p)) + name = "[CCallback] "; + if (pt.IsByRef) { pt = pt.GetElementType (); - name = (removeRefTypes ? "" : (p.IsOut ? "out " : "ref ")) + TypeManager.RenderType (pt, p); + name += (removeRefTypes ? "" : (p.IsOut ? "out " : "ref ")) + TypeManager.RenderType (pt, p); } else - name = TypeManager.RenderType (pt, p); + name += TypeManager.RenderType (pt, p); if (!pt.IsValueType && AttributeManager.HasAttribute (p)) name += "?"; return name; diff --git a/src/bgen/bgen.csproj b/src/bgen/bgen.csproj index b60e6a4eaf..db14ea3860 100644 --- a/src/bgen/bgen.csproj +++ b/src/bgen/bgen.csproj @@ -47,6 +47,8 @@ + + diff --git a/src/coreaudiokit.cs b/src/coreaudiokit.cs index fed6fb9955..b810327dcf 100644 --- a/src/coreaudiokit.cs +++ b/src/coreaudiokit.cs @@ -1,4 +1,4 @@ -/// +// // Authors: // Miguel de Icaza (miguel@xamarin.com) // diff --git a/src/frameworks.sources b/src/frameworks.sources index 1467bcf5ec..311e78a931 100644 --- a/src/frameworks.sources +++ b/src/frameworks.sources @@ -1928,6 +1928,8 @@ SHARED_CORE_SOURCES = \ ObjCRuntime/ArgumentSemantic.cs \ ObjCRuntime/BindAsAttribute.cs \ ObjCRuntime/Blocks.cs \ + ObjCRuntime/BlockCallbackAttribute.cs \ + ObjCRuntime/CCallbackAttribute.cs \ ObjCRuntime/Class.cs \ ObjCRuntime/Constants.cs \ ObjCRuntime/DisposableObject.cs \ diff --git a/src/generator.csproj b/src/generator.csproj index 9405776086..a62bd3256c 100644 --- a/src/generator.csproj +++ b/src/generator.csproj @@ -133,6 +133,8 @@ + + diff --git a/src/modelio.cs b/src/modelio.cs index d54fdd8647..b80305461b 100644 --- a/src/modelio.cs +++ b/src/modelio.cs @@ -1,4 +1,4 @@ -/// +// // Authors: // Miguel de Icaza (miguel@xamarin.com) // diff --git a/src/scenekit.cs b/src/scenekit.cs index f7c0654b99..634ef90de6 100644 --- a/src/scenekit.cs +++ b/src/scenekit.cs @@ -1,4 +1,4 @@ -/// +// // Authors: // Miguel de Icaza (miguel@xamarin.com) // Aaron Bockover (abock@xamarin.com) diff --git a/tests/cecil-tests/BlittablePInvokes.KnownFailures.cs b/tests/cecil-tests/BlittablePInvokes.KnownFailures.cs index 3afb27007b..c81e75e561 100644 --- a/tests/cecil-tests/BlittablePInvokes.KnownFailures.cs +++ b/tests/cecil-tests/BlittablePInvokes.KnownFailures.cs @@ -196,20 +196,6 @@ namespace Cecil.Tests { "System.Boolean CoreGraphics.CGDisplay::CGDisplayIsCaptured(System.UInt32)", "System.Boolean CoreGraphics.CGEventSource::GetButtonState(CoreGraphics.CGEventSourceStateID,CoreGraphics.CGMouseButton)", "System.Boolean CoreGraphics.CGEventSource::GetKeyState(CoreGraphics.CGEventSourceStateID,System.UInt16)", - "System.Boolean CoreGraphics.CGPath::CGPathContainsPoint(System.IntPtr,CoreGraphics.CGAffineTransform*,CoreGraphics.CGPoint,System.Boolean)", - "System.Boolean CoreGraphics.CGPath::CGPathEqualToPath(System.IntPtr,System.IntPtr)", - "System.Boolean CoreGraphics.CGPath::CGPathIntersectsPath(System.IntPtr,System.IntPtr,System.Boolean)", - "System.Boolean CoreGraphics.CGPath::CGPathIsEmpty(System.IntPtr)", - "System.Boolean CoreGraphics.CGPath::CGPathIsRect(System.IntPtr,CoreGraphics.CGRect&)", - "System.Boolean CoreGraphics.CGPDFArray::CGPDFArrayApplyBlock(System.IntPtr,ObjCRuntime.BlockLiteral*,System.IntPtr)", - "System.Boolean CoreGraphics.CGPDFArray::CGPDFArrayGetArray(System.IntPtr,System.IntPtr,System.IntPtr&)", - "System.Boolean CoreGraphics.CGPDFArray::CGPDFArrayGetBoolean(System.IntPtr,System.IntPtr,System.Boolean&)", - "System.Boolean CoreGraphics.CGPDFArray::CGPDFArrayGetDictionary(System.IntPtr,System.IntPtr,System.IntPtr&)", - "System.Boolean CoreGraphics.CGPDFArray::CGPDFArrayGetInteger(System.IntPtr,System.IntPtr,System.IntPtr&)", - "System.Boolean CoreGraphics.CGPDFArray::CGPDFArrayGetName(System.IntPtr,System.IntPtr,System.IntPtr&)", - "System.Boolean CoreGraphics.CGPDFArray::CGPDFArrayGetNumber(System.IntPtr,System.IntPtr,System.Runtime.InteropServices.NFloat&)", - "System.Boolean CoreGraphics.CGPDFArray::CGPDFArrayGetStream(System.IntPtr,System.IntPtr,System.IntPtr&)", - "System.Boolean CoreGraphics.CGPDFArray::CGPDFArrayGetString(System.IntPtr,System.IntPtr,System.IntPtr&)", "System.Boolean CoreGraphics.CGPDFDictionary::CGPDFDictionaryGetArray(System.IntPtr,System.IntPtr,System.IntPtr&)", "System.Boolean CoreGraphics.CGPDFDictionary::CGPDFDictionaryGetBoolean(System.IntPtr,System.IntPtr,System.Boolean&)", "System.Boolean CoreGraphics.CGPDFDictionary::CGPDFDictionaryGetDictionary(System.IntPtr,System.IntPtr,System.IntPtr&)", @@ -239,9 +225,6 @@ namespace Cecil.Tests { "System.Boolean CoreGraphics.CGPDFScanner::CGPDFScannerScan(System.IntPtr)", "System.Boolean CoreGraphics.CGRectExtensions::CGRectIsInfinite(CoreGraphics.CGRect)", "System.Boolean CoreGraphics.CGRectExtensions::CGRectIsNull(CoreGraphics.CGRect)", - "System.Boolean CoreGraphics.NativeDrawingMethods::CGPointMakeWithDictionaryRepresentation(System.IntPtr,CoreGraphics.CGPoint&)", - "System.Boolean CoreGraphics.NativeDrawingMethods::CGRectMakeWithDictionaryRepresentation(System.IntPtr,CoreGraphics.CGRect&)", - "System.Boolean CoreGraphics.NativeDrawingMethods::CGSizeMakeWithDictionaryRepresentation(System.IntPtr,CoreGraphics.CGSize&)", "System.Boolean CoreMedia.CMBlockBuffer::CMBlockBufferIsEmpty(System.IntPtr)", "System.Boolean CoreMedia.CMBlockBuffer::CMBlockBufferIsRangeContiguous(System.IntPtr,System.UIntPtr,System.UIntPtr)", "System.Boolean CoreMedia.CMClock::CMClockMightDrift(System.IntPtr,System.IntPtr)", @@ -372,16 +355,6 @@ namespace Cecil.Tests { "System.Int32 Security.SslContext::SSLCopyALPNProtocols(System.IntPtr,System.IntPtr&)", "System.Int32 Security.SslContext::SSLSetSessionTicketsEnabled(System.IntPtr,System.Boolean)", "System.Int32 SystemConfiguration.NetworkReachability::SCNetworkReachabilityGetFlags(System.IntPtr,SystemConfiguration.NetworkReachabilityFlags&)", - "System.IntPtr CoreGraphics.CGPath::CGPathCreateCopyByIntersectingPath(System.IntPtr,System.IntPtr,System.Boolean)", - "System.IntPtr CoreGraphics.CGPath::CGPathCreateCopyByNormalizing(System.IntPtr,System.Boolean)", - "System.IntPtr CoreGraphics.CGPath::CGPathCreateCopyBySubtractingPath(System.IntPtr,System.IntPtr,System.Boolean)", - "System.IntPtr CoreGraphics.CGPath::CGPathCreateCopyBySymmetricDifferenceOfPath(System.IntPtr,System.IntPtr,System.Boolean)", - "System.IntPtr CoreGraphics.CGPath::CGPathCreateCopyByTransformingPath(System.IntPtr,CoreGraphics.CGAffineTransform&)", - "System.IntPtr CoreGraphics.CGPath::CGPathCreateCopyByUnioningPath(System.IntPtr,System.IntPtr,System.Boolean)", - "System.IntPtr CoreGraphics.CGPath::CGPathCreateCopyOfLineByIntersectingPath(System.IntPtr,System.IntPtr,System.Boolean)", - "System.IntPtr CoreGraphics.CGPath::CGPathCreateCopyOfLineBySubtractingPath(System.IntPtr,System.IntPtr,System.Boolean)", - "System.IntPtr CoreGraphics.CGPath::CGPathCreateMutableCopyByTransformingPath(System.IntPtr,CoreGraphics.CGAffineTransform&)", - "System.IntPtr CoreGraphics.CGPath::CGPathCreateSeparateComponents(System.IntPtr,System.Boolean)", "System.IntPtr CoreGraphics.CGPattern::CGPatternCreate(System.IntPtr,CoreGraphics.CGRect,CoreGraphics.CGAffineTransform,System.Runtime.InteropServices.NFloat,System.Runtime.InteropServices.NFloat,CoreGraphics.CGPatternTiling,System.Boolean,CoreGraphics.CGPatternCallbacks&)", "System.IntPtr CoreGraphics.CGPDFStream::CGPDFStreamCopyData(System.IntPtr,CoreGraphics.CGPDFDataFormat&)", "System.IntPtr CoreGraphics.CGShading::CGShadingCreateAxial(System.IntPtr,CoreGraphics.CGPoint,CoreGraphics.CGPoint,System.IntPtr,System.Boolean,System.Boolean)", @@ -433,7 +406,6 @@ namespace Cecil.Tests { "System.IntPtr SystemConfiguration.NetworkReachability::SCNetworkReachabilityCreateWithAddressPair(System.IntPtr,System.IntPtr,SystemConfiguration.NetworkReachability/sockaddr_in&)", "System.IntPtr SystemConfiguration.NetworkReachability::SCNetworkReachabilityCreateWithAddressPair(System.IntPtr,SystemConfiguration.NetworkReachability/sockaddr_in&,System.IntPtr)", "System.IntPtr SystemConfiguration.NetworkReachability::SCNetworkReachabilityCreateWithAddressPair(System.IntPtr,SystemConfiguration.NetworkReachability/sockaddr_in&,SystemConfiguration.NetworkReachability/sockaddr_in&)", - "System.Void CoreGraphics.CGPath::CGPathAddArc(System.IntPtr,CoreGraphics.CGAffineTransform*,System.Runtime.InteropServices.NFloat,System.Runtime.InteropServices.NFloat,System.Runtime.InteropServices.NFloat,System.Runtime.InteropServices.NFloat,System.Runtime.InteropServices.NFloat,System.Boolean)", "System.Void CoreGraphics.CGPDFDocument::CGPDFDocumentGetVersion(System.IntPtr,System.Int32&,System.Int32&)", "System.Void CoreGraphics.CGRectExtensions::CGRectDivide(CoreGraphics.CGRect,CoreGraphics.CGRect&,CoreGraphics.CGRect&,System.Runtime.InteropServices.NFloat,CoreGraphics.CGRectEdge)", "System.Void CoreText.CTFontManager::CTFontManagerRegisterFontDescriptors(System.IntPtr,CoreText.CTFontManagerScope,System.Boolean,ObjCRuntime.BlockLiteral*)", diff --git a/tests/dotnet/UnitTests/ProjectTest.cs b/tests/dotnet/UnitTests/ProjectTest.cs index a10f5f6f71..88e687c56b 100644 --- a/tests/dotnet/UnitTests/ProjectTest.cs +++ b/tests/dotnet/UnitTests/ProjectTest.cs @@ -1127,6 +1127,36 @@ namespace Xamarin.Tests { $"The workload '{targetFramework}' is out of support and will not receive security updates in the future. Please refer to https://aka.ms/maui-support-policy for more information about the support policy."); } + [Test] + [TestCase (ApplePlatform.iOS, "iossimulator-x64")] + [TestCase (ApplePlatform.iOS, "ios-arm64")] + [TestCase (ApplePlatform.TVOS, "tvossimulator-arm64")] + [TestCase (ApplePlatform.MacOSX, "osx-arm64")] + [TestCase (ApplePlatform.MacCatalyst, "maccatalyst-x64")] + public void BuildNetFutureApp (ApplePlatform platform, string runtimeIdentifiers) + { + // Builds an app with a higher .NET version than we support (for instance 'net9.0-ios' when we support 'net8.0-ios') + var project = "MySimpleApp"; + Configuration.IgnoreIfIgnoredPlatform (platform); + Configuration.AssertRuntimeIdentifiersAvailable (platform, runtimeIdentifiers); + + var majorNetVersion = Version.Parse (Configuration.DotNetTfm.Replace ("net", "")).Major; + var netVersion = $"net{majorNetVersion + 1}.0"; + var project_path = GetProjectPath (project, runtimeIdentifiers: runtimeIdentifiers, platform: platform, out var appPath, netVersion: netVersion); + Clean (project_path); + var properties = GetDefaultProperties (runtimeIdentifiers); + var targetFramework = platform.ToFramework (netVersion); + properties ["TargetFramework"] = targetFramework; + properties ["ExcludeNUnitLiteReference"] = "true"; + properties ["ExcludeTouchUnitReference"] = "true"; + + var result = DotNet.AssertBuildFailure (project_path, properties); + var errors = BinLog.GetBuildLogErrors (result.BinLogPath).ToList (); + + AssertErrorMessages (errors, + $"The current .NET SDK does not support targeting .NET {majorNetVersion + 1}.0. Either target .NET {majorNetVersion}.0 or lower, or use a version of the .NET SDK that supports .NET {majorNetVersion + 1}.0. Download the .NET SDK from https://aka.ms/dotnet/download"); + } + [Test] [TestCase (ApplePlatform.iOS, "iossimulator-x64")] [TestCase (ApplePlatform.iOS, "ios-arm64")] diff --git a/tests/dotnet/UnitTests/TrimmerWarningsTest.cs b/tests/dotnet/UnitTests/TrimmerWarningsTest.cs index 31cb9291a5..3f10af0d5f 100644 --- a/tests/dotnet/UnitTests/TrimmerWarningsTest.cs +++ b/tests/dotnet/UnitTests/TrimmerWarningsTest.cs @@ -23,11 +23,6 @@ namespace Xamarin.Tests { case ApplePlatform.iOS: case ApplePlatform.TVOS: expectedWarnings = new ExpectedBuildMessage [] { - new ExpectedBuildMessage ("src/Foundation/NSObject2.cs" /* line 266 */, "Foundation.NSObject.CreateNSObject(IntPtr, IntPtr, NSObject.Flags): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors', 'DynamicallyAccessedMemberTypes.NonPublicConstructors' in call to 'System.Runtime.CompilerServices.RuntimeHelpers.GetUninitializedObject(Type)'. The return value of method 'ObjCRuntime.Runtime.GetGCHandleTarget(IntPtr)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to."), - new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 520 */, "ObjCRuntime.BlockLiteral.GetBlockForDelegate(MethodInfo, Object, UInt32, String): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.NonPublicFields' in call to 'System.Type.GetField(String, BindingFlags)'. The return value of method 'ObjCRuntime.BlockLiteral.GetDelegateProxyType(MethodInfo, UInt32, MethodInfo&)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to."), - new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 515 */, "ObjCRuntime.BlockLiteral.GetBlockForDelegate(MethodInfo, Object, UInt32, String): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Type.GetMethod(String, BindingFlags)'. The return value of method 'ObjCRuntime.BlockLiteral.GetDelegateProxyType(MethodInfo, UInt32, MethodInfo&)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to."), - new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 423 */, "ObjCRuntime.BlockLiteral.GetDelegateProxyType(MethodInfo, UInt32, MethodInfo&): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'System.Type.GetInterfaces()'. The return value of method 'System.Reflection.MemberInfo.DeclaringType.get' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to."), - new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 427 */, "ObjCRuntime.BlockLiteral.GetDelegateProxyType(MethodInfo, UInt32, MethodInfo&): Value passed to parameter 'interfaceType' of method 'System.Type.GetInterfaceMap(Type)' can not be statically determined and may not meet 'DynamicallyAccessedMembersAttribute' requirements."), new ExpectedBuildMessage ("src/ObjCRuntime/Class.cs" /* line 541 */, "ObjCRuntime.Class.ResolveToken(Assembly, Module, UInt32): Using member 'System.Reflection.Module.ResolveMethod(Int32)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Trimming changes metadata tokens."), new ExpectedBuildMessage ("src/ObjCRuntime/Class.cs" /* line 528 */, "ObjCRuntime.Class.ResolveToken(Assembly, Module, UInt32): Using member 'System.Reflection.Module.ResolveType(Int32)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Trimming changes metadata tokens."), new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 2434 */, "ObjCRuntime.Runtime.FindClosedMethod(Type, MethodBase): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Type.GetMethods(BindingFlags)'. The parameter 'closed_type' of method 'ObjCRuntime.Runtime.FindClosedMethod(Type, MethodBase)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to."), @@ -38,11 +33,6 @@ namespace Xamarin.Tests { break; case ApplePlatform.MacOSX: expectedWarnings = new ExpectedBuildMessage [] { - new ExpectedBuildMessage ("src/Foundation/NSObject2.cs" /* line 266 */, "Foundation.NSObject.CreateNSObject(IntPtr, IntPtr, NSObject.Flags): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors', 'DynamicallyAccessedMemberTypes.NonPublicConstructors' in call to 'System.Runtime.CompilerServices.RuntimeHelpers.GetUninitializedObject(Type)'. The return value of method 'ObjCRuntime.Runtime.GetGCHandleTarget(IntPtr)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to."), - new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 520 */, "ObjCRuntime.BlockLiteral.GetBlockForDelegate(MethodInfo, Object, UInt32, String): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.NonPublicFields' in call to 'System.Type.GetField(String, BindingFlags)'. The return value of method 'ObjCRuntime.BlockLiteral.GetDelegateProxyType(MethodInfo, UInt32, MethodInfo&)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to."), - new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 515 */, "ObjCRuntime.BlockLiteral.GetBlockForDelegate(MethodInfo, Object, UInt32, String): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Type.GetMethod(String, BindingFlags)'. The return value of method 'ObjCRuntime.BlockLiteral.GetDelegateProxyType(MethodInfo, UInt32, MethodInfo&)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to."), - new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 423 */, "ObjCRuntime.BlockLiteral.GetDelegateProxyType(MethodInfo, UInt32, MethodInfo&): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'System.Type.GetInterfaces()'. The return value of method 'System.Reflection.MemberInfo.DeclaringType.get' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to."), - new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 427 */, "ObjCRuntime.BlockLiteral.GetDelegateProxyType(MethodInfo, UInt32, MethodInfo&): Value passed to parameter 'interfaceType' of method 'System.Type.GetInterfaceMap(Type)' can not be statically determined and may not meet 'DynamicallyAccessedMembersAttribute' requirements."), new ExpectedBuildMessage ("src/ObjCRuntime/Class.cs" /* line 541 */, "ObjCRuntime.Class.ResolveToken(Assembly, Module, UInt32): Using member 'System.Reflection.Module.ResolveMethod(Int32)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Trimming changes metadata tokens."), new ExpectedBuildMessage ("src/ObjCRuntime/Class.cs" /* line 528 */, "ObjCRuntime.Class.ResolveToken(Assembly, Module, UInt32): Using member 'System.Reflection.Module.ResolveType(Int32)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Trimming changes metadata tokens."), new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 2434 */, "ObjCRuntime.Runtime.FindClosedMethod(Type, MethodBase): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Type.GetMethods(BindingFlags)'. The parameter 'closed_type' of method 'ObjCRuntime.Runtime.FindClosedMethod(Type, MethodBase)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to."), @@ -53,11 +43,6 @@ namespace Xamarin.Tests { break; case ApplePlatform.MacCatalyst: expectedWarnings = new ExpectedBuildMessage [] { - new ExpectedBuildMessage ("src/Foundation/NSObject2.cs" /* line 266 */, "Foundation.NSObject.CreateNSObject(IntPtr, IntPtr, NSObject.Flags): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors', 'DynamicallyAccessedMemberTypes.NonPublicConstructors' in call to 'System.Runtime.CompilerServices.RuntimeHelpers.GetUninitializedObject(Type)'. The return value of method 'ObjCRuntime.Runtime.GetGCHandleTarget(IntPtr)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to."), - new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 520 */, "ObjCRuntime.BlockLiteral.GetBlockForDelegate(MethodInfo, Object, UInt32, String): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.NonPublicFields' in call to 'System.Type.GetField(String, BindingFlags)'. The return value of method 'ObjCRuntime.BlockLiteral.GetDelegateProxyType(MethodInfo, UInt32, MethodInfo&)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to."), - new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 515 */, "ObjCRuntime.BlockLiteral.GetBlockForDelegate(MethodInfo, Object, UInt32, String): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Type.GetMethod(String, BindingFlags)'. The return value of method 'ObjCRuntime.BlockLiteral.GetDelegateProxyType(MethodInfo, UInt32, MethodInfo&)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to."), - new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 423 */, "ObjCRuntime.BlockLiteral.GetDelegateProxyType(MethodInfo, UInt32, MethodInfo&): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'System.Type.GetInterfaces()'. The return value of method 'System.Reflection.MemberInfo.DeclaringType.get' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to."), - new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 427 */, "ObjCRuntime.BlockLiteral.GetDelegateProxyType(MethodInfo, UInt32, MethodInfo&): Value passed to parameter 'interfaceType' of method 'System.Type.GetInterfaceMap(Type)' can not be statically determined and may not meet 'DynamicallyAccessedMembersAttribute' requirements."), new ExpectedBuildMessage ("src/ObjCRuntime/Class.cs" /* line 541 */, "ObjCRuntime.Class.ResolveToken(Assembly, Module, UInt32): Using member 'System.Reflection.Module.ResolveMethod(Int32)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Trimming changes metadata tokens."), new ExpectedBuildMessage ("src/ObjCRuntime/Class.cs" /* line 528 */, "ObjCRuntime.Class.ResolveToken(Assembly, Module, UInt32): Using member 'System.Reflection.Module.ResolveType(Int32)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Trimming changes metadata tokens."), new ExpectedBuildMessage ("src/ObjCRuntime/Runtime.cs" /* line 2434 */, "ObjCRuntime.Runtime.FindClosedMethod(Type, MethodBase): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Type.GetMethods(BindingFlags)'. The parameter 'closed_type' of method 'ObjCRuntime.Runtime.FindClosedMethod(Type, MethodBase)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to."), @@ -86,13 +71,8 @@ namespace Xamarin.Tests { case ApplePlatform.iOS: case ApplePlatform.TVOS: expectedWarnings = new ExpectedBuildMessage [] { - new ExpectedBuildMessage ("src/Foundation/NSObject2.cs" /* line 266 */, "Foundation.NSObject.CreateNSObject(IntPtr, IntPtr, NSObject.Flags): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors', 'DynamicallyAccessedMemberTypes.NonPublicConstructors' in call to 'System.Runtime.CompilerServices.RuntimeHelpers.GetUninitializedObject(Type)'. The return value of method 'ObjCRuntime.Runtime.GetGCHandleTarget(IntPtr)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to."), new ExpectedBuildMessage ("src/Foundation/NSObject2.cs" /* line 554 */, "Foundation.NSObject.DynamicConformsToProtocol(NativeHandle): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'System.Type.GetInterfaces()'. The return value of method 'System.Object.GetType()' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to."), new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 154 */, "ObjCRuntime.BlockLiteral.FindTrampoline(Type, String): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Type.GetMethod(String, BindingFlags)'. The parameter 'trampolineType' of method 'ObjCRuntime.BlockLiteral.FindTrampoline(Type, String)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to."), - new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 520 */, "ObjCRuntime.BlockLiteral.GetBlockForDelegate(MethodInfo, Object, UInt32, String): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.NonPublicFields' in call to 'System.Type.GetField(String, BindingFlags)'. The return value of method 'ObjCRuntime.BlockLiteral.GetDelegateProxyType(MethodInfo, UInt32, MethodInfo&)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to."), - new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 515 */, "ObjCRuntime.BlockLiteral.GetBlockForDelegate(MethodInfo, Object, UInt32, String): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Type.GetMethod(String, BindingFlags)'. The return value of method 'ObjCRuntime.BlockLiteral.GetDelegateProxyType(MethodInfo, UInt32, MethodInfo&)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to."), - new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 423 */, "ObjCRuntime.BlockLiteral.GetDelegateProxyType(MethodInfo, UInt32, MethodInfo&): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'System.Type.GetInterfaces()'. The return value of method 'System.Reflection.MemberInfo.DeclaringType.get' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to."), - new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 427 */, "ObjCRuntime.BlockLiteral.GetDelegateProxyType(MethodInfo, UInt32, MethodInfo&): Value passed to parameter 'interfaceType' of method 'System.Type.GetInterfaceMap(Type)' can not be statically determined and may not meet 'DynamicallyAccessedMembersAttribute' requirements."), new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 213 */, "ObjCRuntime.BlockLiteral.SetupBlock(Delegate, Delegate, Boolean): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String)'. The return value of method 'ObjCRuntime.UserDelegateTypeAttribute.UserDelegateType.get' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to."), new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 313 */, "ObjCRuntime.BlockLiteral.SetupBlock(Delegate, Delegate): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String)'. The return value of method 'ObjCRuntime.MonoPInvokeCallbackAttribute.DelegateType.get' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to."), new ExpectedBuildMessage ("src/ObjCRuntime/Class.cs" /* line 541 */, "ObjCRuntime.Class.ResolveToken(Assembly, Module, UInt32): Using member 'System.Reflection.Module.ResolveMethod(Int32)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Trimming changes metadata tokens."), @@ -129,13 +109,8 @@ namespace Xamarin.Tests { break; case ApplePlatform.MacOSX: expectedWarnings = new ExpectedBuildMessage [] { - new ExpectedBuildMessage ("src/Foundation/NSObject2.cs" /* line 266 */, "Foundation.NSObject.CreateNSObject(IntPtr, IntPtr, NSObject.Flags): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors', 'DynamicallyAccessedMemberTypes.NonPublicConstructors' in call to 'System.Runtime.CompilerServices.RuntimeHelpers.GetUninitializedObject(Type)'. The return value of method 'ObjCRuntime.Runtime.GetGCHandleTarget(IntPtr)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to."), new ExpectedBuildMessage ("src/Foundation/NSObject2.cs" /* line 554 */, "Foundation.NSObject.DynamicConformsToProtocol(NativeHandle): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'System.Type.GetInterfaces()'. The return value of method 'System.Object.GetType()' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to."), new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 154 */, "ObjCRuntime.BlockLiteral.FindTrampoline(Type, String): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Type.GetMethod(String, BindingFlags)'. The parameter 'trampolineType' of method 'ObjCRuntime.BlockLiteral.FindTrampoline(Type, String)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to."), - new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 520 */, "ObjCRuntime.BlockLiteral.GetBlockForDelegate(MethodInfo, Object, UInt32, String): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.NonPublicFields' in call to 'System.Type.GetField(String, BindingFlags)'. The return value of method 'ObjCRuntime.BlockLiteral.GetDelegateProxyType(MethodInfo, UInt32, MethodInfo&)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to."), - new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 515 */, "ObjCRuntime.BlockLiteral.GetBlockForDelegate(MethodInfo, Object, UInt32, String): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Type.GetMethod(String, BindingFlags)'. The return value of method 'ObjCRuntime.BlockLiteral.GetDelegateProxyType(MethodInfo, UInt32, MethodInfo&)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to."), - new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 423 */, "ObjCRuntime.BlockLiteral.GetDelegateProxyType(MethodInfo, UInt32, MethodInfo&): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'System.Type.GetInterfaces()'. The return value of method 'System.Reflection.MemberInfo.DeclaringType.get' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to."), - new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 427 */, "ObjCRuntime.BlockLiteral.GetDelegateProxyType(MethodInfo, UInt32, MethodInfo&): Value passed to parameter 'interfaceType' of method 'System.Type.GetInterfaceMap(Type)' can not be statically determined and may not meet 'DynamicallyAccessedMembersAttribute' requirements."), new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 213 */, "ObjCRuntime.BlockLiteral.SetupBlock(Delegate, Delegate, Boolean): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String)'. The return value of method 'ObjCRuntime.UserDelegateTypeAttribute.UserDelegateType.get' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to."), new ExpectedBuildMessage ("src/ObjCRuntime/Class.cs" /* line 541 */, "ObjCRuntime.Class.ResolveToken(Assembly, Module, UInt32): Using member 'System.Reflection.Module.ResolveMethod(Int32)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Trimming changes metadata tokens."), new ExpectedBuildMessage ("src/ObjCRuntime/Class.cs" /* line 528 */, "ObjCRuntime.Class.ResolveToken(Assembly, Module, UInt32): Using member 'System.Reflection.Module.ResolveType(Int32)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Trimming changes metadata tokens."), @@ -173,13 +148,8 @@ namespace Xamarin.Tests { break; case ApplePlatform.MacCatalyst: expectedWarnings = new ExpectedBuildMessage [] { - new ExpectedBuildMessage ("src/Foundation/NSObject2.cs" /* line 266 */, "Foundation.NSObject.CreateNSObject(IntPtr, IntPtr, NSObject.Flags): 'type' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicConstructors', 'DynamicallyAccessedMemberTypes.NonPublicConstructors' in call to 'System.Runtime.CompilerServices.RuntimeHelpers.GetUninitializedObject(Type)'. The return value of method 'ObjCRuntime.Runtime.GetGCHandleTarget(IntPtr)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to."), new ExpectedBuildMessage ("src/Foundation/NSObject2.cs" /* line 554 */, "Foundation.NSObject.DynamicConformsToProtocol(NativeHandle): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'System.Type.GetInterfaces()'. The return value of method 'System.Object.GetType()' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to."), new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 154 */, "ObjCRuntime.BlockLiteral.FindTrampoline(Type, String): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods', 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Type.GetMethod(String, BindingFlags)'. The parameter 'trampolineType' of method 'ObjCRuntime.BlockLiteral.FindTrampoline(Type, String)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to."), - new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 520 */, "ObjCRuntime.BlockLiteral.GetBlockForDelegate(MethodInfo, Object, UInt32, String): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.NonPublicFields' in call to 'System.Type.GetField(String, BindingFlags)'. The return value of method 'ObjCRuntime.BlockLiteral.GetDelegateProxyType(MethodInfo, UInt32, MethodInfo&)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to."), - new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 515 */, "ObjCRuntime.BlockLiteral.GetBlockForDelegate(MethodInfo, Object, UInt32, String): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.NonPublicMethods' in call to 'System.Type.GetMethod(String, BindingFlags)'. The return value of method 'ObjCRuntime.BlockLiteral.GetDelegateProxyType(MethodInfo, UInt32, MethodInfo&)' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to."), - new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 423 */, "ObjCRuntime.BlockLiteral.GetDelegateProxyType(MethodInfo, UInt32, MethodInfo&): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.Interfaces' in call to 'System.Type.GetInterfaces()'. The return value of method 'System.Reflection.MemberInfo.DeclaringType.get' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to."), - new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 427 */, "ObjCRuntime.BlockLiteral.GetDelegateProxyType(MethodInfo, UInt32, MethodInfo&): Value passed to parameter 'interfaceType' of method 'System.Type.GetInterfaceMap(Type)' can not be statically determined and may not meet 'DynamicallyAccessedMembersAttribute' requirements."), new ExpectedBuildMessage ("src/ObjCRuntime/Blocks.cs" /* line 213 */, "ObjCRuntime.BlockLiteral.SetupBlock(Delegate, Delegate, Boolean): 'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'System.Type.GetMethod(String)'. The return value of method 'ObjCRuntime.UserDelegateTypeAttribute.UserDelegateType.get' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to."), new ExpectedBuildMessage ("src/ObjCRuntime/Class.cs" /* line 541 */, "ObjCRuntime.Class.ResolveToken(Assembly, Module, UInt32): Using member 'System.Reflection.Module.ResolveMethod(Int32)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Trimming changes metadata tokens."), new ExpectedBuildMessage ("src/ObjCRuntime/Class.cs" /* line 528 */, "ObjCRuntime.Class.ResolveToken(Assembly, Module, UInt32): Using member 'System.Reflection.Module.ResolveType(Int32)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Trimming changes metadata tokens."), diff --git a/tests/generator/BGenTests.cs b/tests/generator/BGenTests.cs index d37b2fd8ee..bed17e4d5c 100644 --- a/tests/generator/BGenTests.cs +++ b/tests/generator/BGenTests.cs @@ -1434,6 +1434,12 @@ namespace GeneratorTests { BuildFile (Profile.iOS, "tests/internal-delegate.cs"); } + [Test] + public void DelegateParameterAttributes () + { + BuildFile (Profile.iOS, "tests/delegate-parameter-attributes.cs"); + } + #if NET [Test] public void Issue19612 () diff --git a/tests/generator/tests/delegate-parameter-attributes.cs b/tests/generator/tests/delegate-parameter-attributes.cs new file mode 100644 index 0000000000..04aea8c960 --- /dev/null +++ b/tests/generator/tests/delegate-parameter-attributes.cs @@ -0,0 +1,6 @@ +using Foundation; + +namespace Test { + [Protocol] + interface DerivedProtocol : INSFilePresenter { } +} diff --git a/tests/monotouch-test/System.Net.Http/MessageHandlers.cs b/tests/monotouch-test/System.Net.Http/MessageHandlers.cs index 6b94c6e01d..977a46dffc 100644 --- a/tests/monotouch-test/System.Net.Http/MessageHandlers.cs +++ b/tests/monotouch-test/System.Net.Http/MessageHandlers.cs @@ -818,7 +818,6 @@ namespace MonoTests.System.Net.Http { for (var i = 0; i < iterations; i++) { var rsp = delegatingHandler.Responses [i]; Assert.IsTrue (delegatingHandler.IsCompleted (i), $"Completed #{i}"); - Assert.IsTrue (rsp.IsSuccessStatusCode, $"IsSuccessStatusCode #{i}"); Assert.AreEqual ("OK", rsp.ReasonPhrase, $"ReasonPhrase #{i}"); Assert.AreEqual (HttpStatusCode.OK, rsp.StatusCode, $"StatusCode #{i}"); diff --git a/tools/common/Frameworks.cs b/tools/common/Frameworks.cs index 289c2a8b63..1e076bc9e3 100644 --- a/tools/common/Frameworks.cs +++ b/tools/common/Frameworks.cs @@ -652,7 +652,7 @@ public class Frameworks : Dictionary { { "Cinematic", "Cinematic", new Version (17, 0), NotAvailableInSimulator }, { "Symbols", "Symbols", 17, 0 }, { "NetworkExtension", "NetworkExtension", 17, 0 }, - { "Phase", "PHASE", new Version (17,0), NotAvailableInSimulator }, + { "Phase", "PHASE", new Version (17,0), NotAvailableInSimulator }, }; } return tvos_frameworks;