[net9.0] Merge main into net9.0.

This commit is contained in:
Rolf Bjarne Kvinge 2024-03-07 14:52:30 +01:00
Родитель 2ce49e0226 560941d962
Коммит e49bd6edda
33 изменённых файлов: 301 добавлений и 167 удалений

Просмотреть файл

@ -24,7 +24,7 @@ jobs:
branches: Localization branches: Localization
soft_fail: true soft_fail: true
- uses: peterjgrainger/action-create-branch@v2.4.0 - uses: peterjgrainger/action-create-branch@v3.0.0
name: 'Create Localization Branch' name: 'Create Localization Branch'
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Просмотреть файл

@ -66,8 +66,10 @@ using (var writer = new StreamWriter (outputPath)) {
} }
var earliestSupportedTFV = supportedTFVs.Select (v => Version.Parse (v)).OrderBy (v => v).First (); 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 ($" <ImportGroup Condition=\" '$(TargetPlatformIdentifier)' == '{platform}' And '$(UsingAppleNETSdk)' != 'true'\">"); writer.WriteLine ($" <ImportGroup Condition=\" '$(TargetPlatformIdentifier)' == '{platform}' And '$(UsingAppleNETSdk)' != 'true'\">");
writer.WriteLine ($" <Import Project=\"Sdk-eol.props\" Sdk=\"Microsoft.{platform}.Sdk.{tfm}\" Condition=\" $([MSBuild]::VersionLessThan($(TargetFrameworkVersion), '{earliestSupportedTFV}'))\" />"); writer.WriteLine ($" <Import Project=\"Sdk-eol.props\" Sdk=\"Microsoft.{platform}.Sdk.{tfm}\" Condition=\" $([MSBuild]::VersionLessThan($(TargetFrameworkVersion), '{earliestSupportedTFV}'))\" />");
writer.WriteLine ($" <Import Project=\"Sdk.props\" Sdk=\"Microsoft.{platform}.Sdk.{tfm}\" Condition=\" $([MSBuild]::VersionGreaterThan($(TargetFrameworkVersion), '{latestSupportedTFV}'))\" />");
writer.WriteLine ($" </ImportGroup>"); writer.WriteLine ($" </ImportGroup>");
writer.WriteLine (); writer.WriteLine ();
writer.WriteLine ($" <ItemGroup Condition=\" '$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '6.0')) \">"); writer.WriteLine ($" <ItemGroup Condition=\" '$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '6.0')) \">");

Просмотреть файл

@ -1252,6 +1252,7 @@
Assemblies="@(_AssembliesToAOT)" Assemblies="@(_AssembliesToAOT)"
AOTCompilerPath="$(_XamarinAOTCompiler)" AOTCompilerPath="$(_XamarinAOTCompiler)"
InputDirectory="$(_AOTInputDirectory)" InputDirectory="$(_AOTInputDirectory)"
MaxDegreeOfParallelism="$(AotCompileMaxDegreeOfParallelism)"
MinimumOSVersion="$(_MinimumOSVersion)" MinimumOSVersion="$(_MinimumOSVersion)"
OutputDirectory="$(_AOTOutputDirectory)\%(_AssembliesToAOT.Arch)" OutputDirectory="$(_AOTOutputDirectory)\%(_AssembliesToAOT.Arch)"
SdkDevPath="$(_SdkDevPath)" SdkDevPath="$(_SdkDevPath)"

Просмотреть файл

@ -1545,4 +1545,13 @@
{0}: the path to a file {0}: the path to a file
</comment> </comment>
</data> </data>
<data name="W7121" xml:space="preserve">
<value>Unable to parse the value '{0}' for the property 'MaxDegreeOfParallelism'. Falling back to the default value (number of processors / 2).</value>
<comment>
{0}: a developer-supplied property value.
MaxDegreeOfParallelism: name of the property (do not translate)
</comment>
</data>
</root> </root>

Просмотреть файл

@ -16,7 +16,7 @@ using Xamarin.Utils;
#nullable enable #nullable enable
namespace Xamarin.MacDev.Tasks { namespace Xamarin.MacDev.Tasks {
public class AOTCompile : XamarinTask, ITaskCallback, ICancelableTask { public class AOTCompile : XamarinParallelTask, ITaskCallback, ICancelableTask {
public ITaskItem [] AotArguments { get; set; } = Array.Empty<ITaskItem> (); public ITaskItem [] AotArguments { get; set; } = Array.Empty<ITaskItem> ();
[Required] [Required]
@ -314,7 +314,7 @@ namespace Xamarin.MacDev.Tasks {
listOfArguments.Add (new (arguments, input)); 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 */) ExecuteAsync (AOTCompilerPath, arg.Arguments, sdkDevPath: SdkDevPath, showErrorIfFailure: false /* we show our own error below */)
.ContinueWith ((v) => { .ContinueWith ((v) => {
if (v.Result.ExitCode != 0) if (v.Result.ExitCode != 0)

Просмотреть файл

@ -17,7 +17,7 @@ using Xamarin.Utils;
#nullable disable #nullable disable
namespace Xamarin.MacDev.Tasks { namespace Xamarin.MacDev.Tasks {
public class Codesign : XamarinTask, ITaskCallback, ICancelableTask { public class Codesign : XamarinParallelTask, ITaskCallback, ICancelableTask {
const string ToolName = "codesign"; const string ToolName = "codesign";
const string MacOSDirName = "MacOS"; const string MacOSDirName = "MacOS";
const string CodeSignatureDirName = "_CodeSignature"; const string CodeSignatureDirName = "_CodeSignature";
@ -468,7 +468,7 @@ namespace Xamarin.MacDev.Tasks {
for (var b = 0; b < buckets.Count; b++) { for (var b = 0; b < buckets.Count; b++) {
var bucket = buckets [b]; var bucket = buckets [b];
Parallel.ForEach (bucket, new ParallelOptions { MaxDegreeOfParallelism = Math.Max (Environment.ProcessorCount / 2, 1) }, (item) => { ForEach (bucket, (item) => {
Sign (item); Sign (item);
var files = GetCodesignedFiles (item.Item); var files = GetCodesignedFiles (item.Item);

Просмотреть файл

@ -10,7 +10,7 @@ using Xamarin.Messaging.Build.Client;
using Xamarin.Utils; using Xamarin.Utils;
namespace Xamarin.MacDev.Tasks { namespace Xamarin.MacDev.Tasks {
public class ScnTool : XamarinTask { public class ScnTool : XamarinParallelTask {
#region Inputs #region Inputs
[Required] [Required]
@ -95,7 +95,7 @@ namespace Xamarin.MacDev.Tasks {
bundleResources.Add (bundleResource); bundleResources.Add (bundleResource);
} }
Parallel.ForEach (listOfArguments, (arg) => { ForEach (listOfArguments, (arg) => {
ExecuteAsync ("xcrun", arg.Arguments, sdkDevPath: SdkDevPath).Wait (); ExecuteAsync ("xcrun", arg.Arguments, sdkDevPath: SdkDevPath).Wait ();
}); });

Просмотреть файл

@ -12,7 +12,7 @@ using Xamarin.Messaging.Build.Client;
#nullable enable #nullable enable
namespace Xamarin.MacDev.Tasks { namespace Xamarin.MacDev.Tasks {
public class SymbolStrip : XamarinTask, ITaskCallback { public class SymbolStrip : XamarinParallelTask, ITaskCallback {
#region Inputs #region Inputs
[Required] [Required]
@ -60,7 +60,7 @@ namespace Xamarin.MacDev.Tasks {
if (ShouldExecuteRemotely ()) if (ShouldExecuteRemotely ())
return new TaskRunner (SessionId, BuildEngine4).RunAsync (this).Result; 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); ExecuteStrip (item);
}); });

Просмотреть файл

@ -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<TSource> (IEnumerable<TSource> source, Action<TSource> body)
{
var options = new ParallelOptions { MaxDegreeOfParallelism = GetMaxDegreeOfParallelism () };
Parallel.ForEach (source, options, body);
}
}
}

Просмотреть файл

@ -1070,6 +1070,7 @@ Copyright (C) 2018 Microsoft. All rights reserved.
Condition="'$(IsMacEnabled)' == 'true'" Condition="'$(IsMacEnabled)' == 'true'"
DeviceSpecificIntermediateOutputPath="$(DeviceSpecificIntermediateOutputPath)" DeviceSpecificIntermediateOutputPath="$(DeviceSpecificIntermediateOutputPath)"
IsWatchApp="$(IsWatchApp)" IsWatchApp="$(IsWatchApp)"
MaxDegreeOfParallelism="$(ColladaMaxDegreeOfParallelism)"
ProjectDir="$(MSBuildProjectDirectory)" ProjectDir="$(MSBuildProjectDirectory)"
ResourcePrefix="$(_ResourcePrefix)" ResourcePrefix="$(_ResourcePrefix)"
SdkPlatform="$(_SdkPlatform)" SdkPlatform="$(_SdkPlatform)"
@ -2257,6 +2258,7 @@ Copyright (C) 2018 Microsoft. All rights reserved.
<Codesign <Codesign
SessionId="$(BuildSessionId)" SessionId="$(BuildSessionId)"
Condition="'$(IsMacEnabled)' == 'true'" Condition="'$(IsMacEnabled)' == 'true'"
MaxDegreeOfParallelism="$(CodesignMaxDegreeOfParallelism)"
Resources="@(_ComputedCodesignItems)" Resources="@(_ComputedCodesignItems)"
ToolExe="$(CodesignExe)" ToolExe="$(CodesignExe)"
ToolPath="$(CodesignPath)" ToolPath="$(CodesignPath)"
@ -2787,6 +2789,7 @@ Copyright (C) 2018 Microsoft. All rights reserved.
Condition="'$(IsMacEnabled)' == 'true'" Condition="'$(IsMacEnabled)' == 'true'"
Executable="$(_AppContainerDir)%(_NativeStripItems.Identity)" Executable="$(_AppContainerDir)%(_NativeStripItems.Identity)"
Kind="%(_NativeStripItems.Kind)" Kind="%(_NativeStripItems.Kind)"
MaxDegreeOfParallelism="$(SymbolStripMaxDegreeOfParallelism)"
SymbolFile="%(_NativeStripItems.SymbolFile)" SymbolFile="%(_NativeStripItems.SymbolFile)"
/> />

Просмотреть файл

@ -31,6 +31,7 @@
#nullable enable #nullable enable
using System; using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Foundation; using Foundation;
using ObjCRuntime; using ObjCRuntime;
@ -76,65 +77,73 @@ namespace CoreGraphics {
// CGPDFBoolean -> unsigned char -> CGPDFObject.h // CGPDFBoolean -> unsigned char -> CGPDFObject.h
[DllImport (Constants.CoreGraphicsLibrary)] [DllImport (Constants.CoreGraphicsLibrary)]
[return: MarshalAs (UnmanagedType.I1)] unsafe extern static byte CGPDFArrayGetBoolean (/* CGPDFArrayRef */ IntPtr array, /* size_t */ nint index, /* CGPDFBoolean* */ byte* value);
extern static bool CGPDFArrayGetBoolean (/* CGPDFArrayRef */ IntPtr array, /* size_t */ nint index, /* CGPDFBoolean* */ [MarshalAs (UnmanagedType.I1)] out bool 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 #if !NET
public bool GetBoolean (int idx, out bool result) public bool GetBoolean (int idx, out bool result)
{ {
return CGPDFArrayGetBoolean (Handle, idx, out result); return GetBoolean ((nint) idx, out result);
} }
#endif #endif
// CGPDFInteger -> long int 32/64 bits -> CGPDFObject.h // CGPDFInteger -> long int 32/64 bits -> CGPDFObject.h
[DllImport (Constants.CoreGraphicsLibrary)] [DllImport (Constants.CoreGraphicsLibrary)]
[return: MarshalAs (UnmanagedType.I1)] unsafe extern static byte CGPDFArrayGetInteger (/* CGPDFArrayRef */ IntPtr array, /* size_t */ nint index, /* CGPDFInteger* */ nint* value);
extern static bool CGPDFArrayGetInteger (/* CGPDFArrayRef */ IntPtr array, /* size_t */ nint index, /* CGPDFInteger* */ out nint value);
public bool GetInt (nint idx, out nint result) public bool GetInt (nint idx, out nint result)
{ {
return CGPDFArrayGetInteger (Handle, idx, out result); result = default;
unsafe {
return CGPDFArrayGetInteger (Handle, idx, (nint*) Unsafe.AsPointer<nint> (ref result)) != 0;
}
} }
#if !NET #if !NET
public bool GetInt (int idx, out nint result) public bool GetInt (int idx, out nint result)
{ {
return CGPDFArrayGetInteger (Handle, idx, out result); return GetInt ((nint) idx, out result);
} }
#endif #endif
// CGPDFReal -> CGFloat -> CGPDFObject.h // CGPDFReal -> CGFloat -> CGPDFObject.h
[DllImport (Constants.CoreGraphicsLibrary)] [DllImport (Constants.CoreGraphicsLibrary)]
[return: MarshalAs (UnmanagedType.I1)] unsafe extern static byte CGPDFArrayGetNumber (/* CGPDFArrayRef */ IntPtr array, /* size_t */ nint index, /* CGPDFReal* */ nfloat* value);
extern static bool CGPDFArrayGetNumber (/* CGPDFArrayRef */ IntPtr array, /* size_t */ nint index, /* CGPDFReal* */ out nfloat value);
public bool GetFloat (nint idx, out nfloat result) public bool GetFloat (nint idx, out nfloat result)
{ {
return CGPDFArrayGetNumber (Handle, idx, out result); result = default;
unsafe {
return CGPDFArrayGetNumber (Handle, idx, (nfloat*) Unsafe.AsPointer<nfloat> (ref result)) != 0;
}
} }
#if !NET #if !NET
public bool GetFloat (int idx, out nfloat result) public bool GetFloat (int idx, out nfloat result)
{ {
return CGPDFArrayGetNumber (Handle, idx, out result); return GetFloat ((nint) idx, out result);
} }
#endif #endif
[DllImport (Constants.CoreGraphicsLibrary)] [DllImport (Constants.CoreGraphicsLibrary)]
[return: MarshalAs (UnmanagedType.I1)] unsafe extern static byte CGPDFArrayGetName (/* CGPDFArrayRef */ IntPtr array, /* size_t */ nint index, /* const char** */ IntPtr* value);
extern static bool CGPDFArrayGetName (/* CGPDFArrayRef */ IntPtr array, /* size_t */ nint index, /* const char** */ out IntPtr value);
public bool GetName (nint idx, out string? result) public bool GetName (nint idx, out string? result)
{ {
IntPtr res; IntPtr res;
var r = CGPDFArrayGetName (Handle, idx, out res); bool r;
unsafe {
r = CGPDFArrayGetName (Handle, idx, &res) != 0;
}
result = r ? Marshal.PtrToStringAnsi (res) : null; result = r ? Marshal.PtrToStringAnsi (res) : null;
return r; return r;
} }
@ -147,12 +156,15 @@ namespace CoreGraphics {
#endif #endif
[DllImport (Constants.CoreGraphicsLibrary)] [DllImport (Constants.CoreGraphicsLibrary)]
[return: MarshalAs (UnmanagedType.I1)] unsafe extern static byte CGPDFArrayGetDictionary (/* CGPDFArrayRef */ IntPtr array, /* size_t */ nint index, /* CGPDFDictionaryRef* */ IntPtr* value);
extern static bool CGPDFArrayGetDictionary (/* CGPDFArrayRef */ IntPtr array, /* size_t */ nint index, /* CGPDFDictionaryRef* */ out IntPtr value);
public bool GetDictionary (nint idx, out CGPDFDictionary? result) 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; result = r ? new CGPDFDictionary (res) : null;
return r; return r;
} }
@ -165,12 +177,15 @@ namespace CoreGraphics {
#endif #endif
[DllImport (Constants.CoreGraphicsLibrary)] [DllImport (Constants.CoreGraphicsLibrary)]
[return: MarshalAs (UnmanagedType.I1)] unsafe extern static byte CGPDFArrayGetStream (/* CGPDFArrayRef */ IntPtr array, /* size_t */ nint index, /* CGPDFStreamRef* */ IntPtr* value);
extern static bool CGPDFArrayGetStream (/* CGPDFArrayRef */ IntPtr array, /* size_t */ nint index, /* CGPDFStreamRef* */ out IntPtr value);
public bool GetStream (nint idx, out CGPDFStream? result) 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; result = r ? new CGPDFStream (ptr) : null;
return r; return r;
} }
@ -183,12 +198,15 @@ namespace CoreGraphics {
#endif #endif
[DllImport (Constants.CoreGraphicsLibrary)] [DllImport (Constants.CoreGraphicsLibrary)]
[return: MarshalAs (UnmanagedType.I1)] unsafe extern static byte CGPDFArrayGetArray (/* CGPDFArrayRef */ IntPtr array, /* size_t */ nint index, /* CGPDFArrayRef* */ IntPtr* value);
extern static bool CGPDFArrayGetArray (/* CGPDFArrayRef */ IntPtr array, /* size_t */ nint index, /* CGPDFArrayRef* */ out IntPtr value);
public bool GetArray (nint idx, out CGPDFArray? array) 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; array = r ? new CGPDFArray (ptr) : null;
return r; return r;
} }
@ -201,12 +219,15 @@ namespace CoreGraphics {
#endif #endif
[DllImport (Constants.CoreGraphicsLibrary)] [DllImport (Constants.CoreGraphicsLibrary)]
[return: MarshalAs (UnmanagedType.I1)] unsafe extern static byte CGPDFArrayGetString (/* CGPDFArrayRef */ IntPtr array, /* size_t */ nint index, /* CGPDFStringRef* */ IntPtr* value);
extern static bool CGPDFArrayGetString (/* CGPDFArrayRef */ IntPtr array, /* size_t */ nint index, /* CGPDFStringRef* */ out IntPtr value);
public bool GetString (nint idx, out string? result) 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; result = r ? CGPDFString.ToString (res) : null;
return r; return r;
} }
@ -250,8 +271,7 @@ namespace CoreGraphics {
[Watch (5, 0)] [Watch (5, 0)]
#endif #endif
[DllImport (Constants.CoreGraphicsLibrary)] [DllImport (Constants.CoreGraphicsLibrary)]
[return: MarshalAs (UnmanagedType.I1)] unsafe extern static byte CGPDFArrayApplyBlock (/* CGPDFArrayRef */ IntPtr array, /* CGPDFArrayApplierBlock */ BlockLiteral* block, /* void* */ IntPtr info);
unsafe extern static bool CGPDFArrayApplyBlock (/* CGPDFArrayRef */ IntPtr array, /* CGPDFArrayApplierBlock */ BlockLiteral* block, /* void* */ IntPtr info);
#if NET #if NET
[SupportedOSPlatform ("ios")] [SupportedOSPlatform ("ios")]
@ -277,7 +297,7 @@ namespace CoreGraphics {
#endif #endif
var gc_handle = info is null ? default (GCHandle) : GCHandle.Alloc (info); var gc_handle = info is null ? default (GCHandle) : GCHandle.Alloc (info);
try { 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 { } finally {
if (info is not null) if (info is not null)
gc_handle.Free (); gc_handle.Free ();

Просмотреть файл

@ -32,6 +32,7 @@ using System;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using CoreFoundation; using CoreFoundation;
@ -97,10 +98,10 @@ namespace CoreGraphics {
} }
[DllImport (Constants.CoreGraphicsLibrary)] [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) public unsafe CGPath (CGPath reference, CGAffineTransform transform)
: base (CGPathCreateMutableCopyByTransformingPath (Runtime.ThrowOnNull (reference, nameof (reference)).Handle, ref transform), true) : base (CGPathCreateMutableCopyByTransformingPath (Runtime.ThrowOnNull (reference, nameof (reference)).Handle, &transform), true)
{ {
} }
@ -142,8 +143,7 @@ namespace CoreGraphics {
} }
[DllImport (Constants.CoreGraphicsLibrary)] [DllImport (Constants.CoreGraphicsLibrary)]
[return: MarshalAs (UnmanagedType.I1)] extern static byte CGPathEqualToPath (/* CGPathRef */ IntPtr path1, /* CGPathRef */ IntPtr path2);
extern static bool CGPathEqualToPath (/* CGPathRef */ IntPtr path1, /* CGPathRef */ IntPtr path2);
public static bool operator == (CGPath? path1, CGPath? path2) public static bool operator == (CGPath? path1, CGPath? path2)
{ {
@ -173,7 +173,7 @@ namespace CoreGraphics {
if (other is null) if (other is null)
return false; return false;
return CGPathEqualToPath (this.Handle, other.Handle); return CGPathEqualToPath (this.Handle, other.Handle) != 0;
} }
[DllImport (Constants.CoreGraphicsLibrary)] [DllImport (Constants.CoreGraphicsLibrary)]
@ -363,16 +363,16 @@ namespace CoreGraphics {
} }
[DllImport (Constants.CoreGraphicsLibrary)] [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) 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) 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)] [DllImport (Constants.CoreGraphicsLibrary)]
@ -419,22 +419,23 @@ namespace CoreGraphics {
} }
[DllImport (Constants.CoreGraphicsLibrary)] [DllImport (Constants.CoreGraphicsLibrary)]
[return: MarshalAs (UnmanagedType.I1)] extern static byte CGPathIsEmpty (/* CGPathRef */ IntPtr path);
extern static bool CGPathIsEmpty (/* CGPathRef */ IntPtr path);
public bool IsEmpty { public bool IsEmpty {
get { get {
return CGPathIsEmpty (Handle); return CGPathIsEmpty (Handle) != 0;
} }
} }
[DllImport (Constants.CoreGraphicsLibrary)] [DllImport (Constants.CoreGraphicsLibrary)]
[return: MarshalAs (UnmanagedType.I1)] unsafe extern static byte CGPathIsRect (/* CGPathRef */ IntPtr path, CGRect* rect);
extern static bool CGPathIsRect (/* CGPathRef */ IntPtr path, out CGRect rect);
public bool IsRect (out CGRect rect) public bool IsRect (out CGRect rect)
{ {
return CGPathIsRect (Handle, out rect); unsafe {
rect = default;
return CGPathIsRect (Handle, (CGRect*) Unsafe.AsPointer<CGRect> (ref rect)) != 0;
}
} }
[DllImport (Constants.CoreGraphicsLibrary)] [DllImport (Constants.CoreGraphicsLibrary)]
@ -465,17 +466,16 @@ namespace CoreGraphics {
} }
[DllImport (Constants.CoreGraphicsLibrary)] [DllImport (Constants.CoreGraphicsLibrary)]
[return: MarshalAs (UnmanagedType.I1)] unsafe extern static byte CGPathContainsPoint (IntPtr path, CGAffineTransform* m, CGPoint point, byte eoFill);
unsafe extern static bool CGPathContainsPoint (IntPtr path, CGAffineTransform* m, CGPoint point, [MarshalAs (UnmanagedType.I1)] bool eoFill);
public unsafe bool ContainsPoint (CGAffineTransform m, CGPoint point, bool 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) 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); 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)] [Mac (13, 0), iOS (16, 0), TV (16, 0), MacCatalyst (16, 0), Watch (9, 0)]
#endif #endif
[DllImport (Constants.CoreGraphicsLibrary)] [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) public CGPath? CreateByNormalizing (bool evenOddFillRule)
{ {
return Runtime.GetINativeObject<CGPath> (CGPathCreateCopyByNormalizing (Handle, evenOddFillRule), owns: true); return Runtime.GetINativeObject<CGPath> (CGPathCreateCopyByNormalizing (Handle, evenOddFillRule.AsByte ()), owns: true);
} }
#if NET #if NET
@ -570,11 +570,11 @@ namespace CoreGraphics {
[Mac (13, 0), iOS (16, 0), TV (16, 0), MacCatalyst (16, 0), Watch (9, 0)] [Mac (13, 0), iOS (16, 0), TV (16, 0), MacCatalyst (16, 0), Watch (9, 0)]
#endif #endif
[DllImport (Constants.CoreGraphicsLibrary)] [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) public CGPath? CreateByUnioningPath (CGPath? maskPath, bool evenOddFillRule)
{ {
return Runtime.GetINativeObject<CGPath> (CGPathCreateCopyByUnioningPath (Handle, maskPath.GetHandle (), evenOddFillRule), owns: true); return Runtime.GetINativeObject<CGPath> (CGPathCreateCopyByUnioningPath (Handle, maskPath.GetHandle (), evenOddFillRule.AsByte ()), owns: true);
} }
#if NET #if NET
@ -586,11 +586,11 @@ namespace CoreGraphics {
[Mac (13, 0), iOS (16, 0), TV (16, 0), MacCatalyst (16, 0), Watch (9, 0)] [Mac (13, 0), iOS (16, 0), TV (16, 0), MacCatalyst (16, 0), Watch (9, 0)]
#endif #endif
[DllImport (Constants.CoreGraphicsLibrary)] [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) public CGPath? CreateByIntersectingPath (CGPath? maskPath, bool evenOddFillRule)
{ {
return Runtime.GetINativeObject<CGPath> (CGPathCreateCopyByIntersectingPath (Handle, maskPath.GetHandle (), evenOddFillRule), owns: true); return Runtime.GetINativeObject<CGPath> (CGPathCreateCopyByIntersectingPath (Handle, maskPath.GetHandle (), evenOddFillRule.AsByte ()), owns: true);
} }
#if NET #if NET
@ -602,11 +602,11 @@ namespace CoreGraphics {
[Mac (13, 0), iOS (16, 0), TV (16, 0), MacCatalyst (16, 0), Watch (9, 0)] [Mac (13, 0), iOS (16, 0), TV (16, 0), MacCatalyst (16, 0), Watch (9, 0)]
#endif #endif
[DllImport (Constants.CoreGraphicsLibrary)] [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) public CGPath? CreateBySubtractingPath (CGPath? maskPath, bool evenOddFillRule)
{ {
return Runtime.GetINativeObject<CGPath> (CGPathCreateCopyBySubtractingPath (Handle, maskPath.GetHandle (), evenOddFillRule), owns: true); return Runtime.GetINativeObject<CGPath> (CGPathCreateCopyBySubtractingPath (Handle, maskPath.GetHandle (), evenOddFillRule.AsByte ()), owns: true);
} }
#if NET #if NET
@ -618,11 +618,11 @@ namespace CoreGraphics {
[Mac (13, 0), iOS (16, 0), TV (16, 0), MacCatalyst (16, 0), Watch (9, 0)] [Mac (13, 0), iOS (16, 0), TV (16, 0), MacCatalyst (16, 0), Watch (9, 0)]
#endif #endif
[DllImport (Constants.CoreGraphicsLibrary)] [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) public CGPath? CreateBySymmetricDifferenceOfPath (CGPath? maskPath, bool evenOddFillRule)
{ {
return Runtime.GetINativeObject<CGPath> (CGPathCreateCopyBySymmetricDifferenceOfPath (Handle, maskPath.GetHandle (), evenOddFillRule), owns: true); return Runtime.GetINativeObject<CGPath> (CGPathCreateCopyBySymmetricDifferenceOfPath (Handle, maskPath.GetHandle (), evenOddFillRule.AsByte ()), owns: true);
} }
#if NET #if NET
@ -634,11 +634,11 @@ namespace CoreGraphics {
[Mac (13, 0), iOS (16, 0), TV (16, 0), MacCatalyst (16, 0), Watch (9, 0)] [Mac (13, 0), iOS (16, 0), TV (16, 0), MacCatalyst (16, 0), Watch (9, 0)]
#endif #endif
[DllImport (Constants.CoreGraphicsLibrary)] [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) public CGPath? CreateLineBySubtractingPath (CGPath? maskPath, bool evenOddFillRule)
{ {
return Runtime.GetINativeObject<CGPath> (CGPathCreateCopyOfLineBySubtractingPath (Handle, maskPath.GetHandle (), evenOddFillRule), owns: true); return Runtime.GetINativeObject<CGPath> (CGPathCreateCopyOfLineBySubtractingPath (Handle, maskPath.GetHandle (), evenOddFillRule.AsByte ()), owns: true);
} }
#if NET #if NET
@ -650,11 +650,11 @@ namespace CoreGraphics {
[Mac (13, 0), iOS (16, 0), TV (16, 0), MacCatalyst (16, 0), Watch (9, 0)] [Mac (13, 0), iOS (16, 0), TV (16, 0), MacCatalyst (16, 0), Watch (9, 0)]
#endif #endif
[DllImport (Constants.CoreGraphicsLibrary)] [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) public CGPath? CreateLineByIntersectingPath (CGPath? maskPath, bool evenOddFillRule)
{ {
return Runtime.GetINativeObject<CGPath> (CGPathCreateCopyOfLineByIntersectingPath (Handle, maskPath.GetHandle (), evenOddFillRule), owns: true); return Runtime.GetINativeObject<CGPath> (CGPathCreateCopyOfLineByIntersectingPath (Handle, maskPath.GetHandle (), evenOddFillRule.AsByte ()), owns: true);
} }
#if NET #if NET
@ -666,11 +666,11 @@ namespace CoreGraphics {
[Mac (13, 0), iOS (16, 0), TV (16, 0), MacCatalyst (16, 0), Watch (9, 0)] [Mac (13, 0), iOS (16, 0), TV (16, 0), MacCatalyst (16, 0), Watch (9, 0)]
#endif #endif
[DllImport (Constants.CoreGraphicsLibrary)] [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) public CGPath [] GetSeparateComponents (bool evenOddFillRule)
{ {
var cfArrayRef = CGPathCreateSeparateComponents (Handle, evenOddFillRule); var cfArrayRef = CGPathCreateSeparateComponents (Handle, evenOddFillRule.AsByte ());
if (cfArrayRef == IntPtr.Zero) if (cfArrayRef == IntPtr.Zero)
return Array.Empty<CGPath> (); return Array.Empty<CGPath> ();
return NSArray.ArrayFromHandle<CGPath> (cfArrayRef); return NSArray.ArrayFromHandle<CGPath> (cfArrayRef);
@ -701,12 +701,11 @@ namespace CoreGraphics {
[Mac (13, 0), iOS (16, 0), TV (16, 0), MacCatalyst (16, 0), Watch (9, 0)] [Mac (13, 0), iOS (16, 0), TV (16, 0), MacCatalyst (16, 0), Watch (9, 0)]
#endif #endif
[DllImport (Constants.CoreGraphicsLibrary)] [DllImport (Constants.CoreGraphicsLibrary)]
[return: MarshalAs (UnmanagedType.I1)] static extern byte CGPathIntersectsPath (IntPtr path1, IntPtr path2, byte evenOddFillRule);
static extern bool CGPathIntersectsPath (IntPtr path1, IntPtr path2, [MarshalAs (UnmanagedType.I1)] bool evenOddFillRule);
public bool DoesIntersect (CGPath? maskPath, bool 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) static CGPath MakeMutable (IntPtr source, bool owns)
@ -769,11 +768,13 @@ namespace CoreGraphics {
} }
[DllImport (Constants.CoreGraphicsLibrary)] [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) public CGPath CopyByTransformingPath (CGAffineTransform transform)
{ {
return MakeMutable (CGPathCreateCopyByTransformingPath (Handle, ref transform), true); unsafe {
return MakeMutable (CGPathCreateCopyByTransformingPath (Handle, &transform), true);
}
} }
[DllImport (Constants.CoreGraphicsLibrary)] [DllImport (Constants.CoreGraphicsLibrary)]

Просмотреть файл

@ -20,6 +20,7 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// //
using System; using System;
using System.Diagnostics.CodeAnalysis;
using System.Reflection; using System.Reflection;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@ -252,9 +253,17 @@ namespace Foundation {
GC.SuppressFinalize (this); 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) internal static IntPtr CreateNSObject (IntPtr type_gchandle, IntPtr handle, Flags flags)
{ {
#if NET #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) { if (Runtime.IsManagedStaticRegistrar) {
throw new System.Diagnostics.UnreachableException (); throw new System.Diagnostics.UnreachableException ();
} }

Просмотреть файл

@ -28,6 +28,7 @@ using System;
using System.Drawing; using System.Drawing;
#endif #endif
using System.Globalization; using System.Globalization;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Foundation; using Foundation;
@ -173,7 +174,10 @@ namespace CoreGraphics
<#= type.ArgName #> = Empty; <#= type.ArgName #> = Empty;
return false; 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 () public NSDictionary ToDictionary ()
@ -604,7 +608,10 @@ namespace CoreGraphics
rect = Empty; rect = Empty;
return false; return false;
} }
return NativeDrawingMethods.CGRectMakeWithDictionaryRepresentation (dictionaryRepresentation.Handle, out rect); rect = default;
unsafe {
return NativeDrawingMethods.CGRectMakeWithDictionaryRepresentation (dictionaryRepresentation.Handle, (CGRect *) Unsafe.AsPointer<CGRect> (ref rect)) != 0;
}
} }
public NSDictionary ToDictionary () public NSDictionary ToDictionary ()
@ -622,14 +629,11 @@ namespace CoreGraphics
internal const string CG = Constants.CoreGraphicsLibrary; internal const string CG = Constants.CoreGraphicsLibrary;
#endif #endif
[DllImport (CG)] [DllImport (CG)]
[return: MarshalAs (UnmanagedType.I1)] internal unsafe extern static byte CGRectMakeWithDictionaryRepresentation (IntPtr dict, CGRect* rect);
internal extern static bool CGRectMakeWithDictionaryRepresentation (IntPtr dict, out CGRect rect);
[DllImport (CG)] [DllImport (CG)]
[return: MarshalAs (UnmanagedType.I1)] internal unsafe extern static byte CGPointMakeWithDictionaryRepresentation (IntPtr dict, CGPoint* point);
internal extern static bool CGPointMakeWithDictionaryRepresentation (IntPtr dict, out CGPoint point);
[DllImport (CG)] [DllImport (CG)]
[return: MarshalAs (UnmanagedType.I1)] internal unsafe extern static byte CGSizeMakeWithDictionaryRepresentation (IntPtr dict, CGSize* point);
internal extern static bool CGSizeMakeWithDictionaryRepresentation (IntPtr dict, out CGSize point);
[DllImport (CG)] [DllImport (CG)]
internal extern static IntPtr CGRectCreateDictionaryRepresentation (CGRect rect); internal extern static IntPtr CGRectCreateDictionaryRepresentation (CGRect rect);

Просмотреть файл

@ -0,0 +1,20 @@
using System;
namespace ObjCRuntime {
/// <summary>
/// This attribute is applied to delegate parameters in a delegate to specify
/// that the delegate parameter needs an Objective-C Block-style bridge.
/// </summary>
/// <remarks>
/// <seealso cref='T:ObjCRuntime.CCallbackAttribute' />
/// </remarks>
[AttributeUsage (AttributeTargets.Parameter, AllowMultiple = false)]
public class BlockCallbackAttribute : Attribute {
/// <summary>
/// Initializes a new instance of the <see cref="BlockCallbackAttribute"/> class.
/// </summary>
public BlockCallbackAttribute ()
{
}
}
}

Просмотреть файл

@ -25,6 +25,7 @@
// //
// //
using System; using System;
using System.Diagnostics.CodeAnalysis;
using System.Reflection; using System.Reflection;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@ -404,8 +405,23 @@ namespace ObjCRuntime {
return descriptor->copy_helper == ((BlockDescriptor*) literal->block_descriptor)->copy_helper; 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) 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 // 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!!!) // If this method is changed, that method will probably have to be updated too (tests!!!)
baseMethod = null; baseMethod = null;
@ -492,8 +508,22 @@ namespace ObjCRuntime {
} }
[BindingImpl (BindingImplOptions.Optimizable)] [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) 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) if (@delegate is null)
return IntPtr.Zero; return IntPtr.Zero;

Просмотреть файл

@ -0,0 +1,20 @@
using System;
namespace ObjCRuntime {
/// <summary>
/// This attribute is applied to delegate parameters in a delegate to specify
/// that the delegate parameter needs an C-style bridge.
/// </summary>
/// <remarks>
/// <seealso cref='T:ObjCRuntime.BlockCallbackAttribute' />
/// </remarks>
[AttributeUsage (AttributeTargets.Parameter, AllowMultiple = false)]
public class CCallbackAttribute : Attribute {
/// <summary>
/// Initializes a new instance of the <see cref="CCallbackAttribute"/> class.
/// </summary>
public CCallbackAttribute ()
{
}
}
}

Просмотреть файл

@ -1,4 +1,4 @@
/// //
// Authors: // Authors:
// Miguel de Icaza (miguel@xamarin.com) // Miguel de Icaza (miguel@xamarin.com)
// //

Просмотреть файл

@ -368,18 +368,6 @@ public class AlignAttribute : Attribute {
public class ParamsAttribute : 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 // When applied, flags the [Flags] as a notification and generates the
// code to strongly type the notification. // code to strongly type the notification.

Просмотреть файл

@ -6813,12 +6813,17 @@ public partial class Generator : IMemberGatherer {
{ {
var pt = p.ParameterType; var pt = p.ParameterType;
string name; string name = string.Empty;
if (AttributeManager.HasAttribute<BlockCallbackAttribute> (p))
name = "[BlockCallback] ";
else if (AttributeManager.HasAttribute<CCallbackAttribute> (p))
name = "[CCallback] ";
if (pt.IsByRef) { if (pt.IsByRef) {
pt = pt.GetElementType (); pt = pt.GetElementType ();
name = (removeRefTypes ? "" : (p.IsOut ? "out " : "ref ")) + TypeManager.RenderType (pt, p); name += (removeRefTypes ? "" : (p.IsOut ? "out " : "ref ")) + TypeManager.RenderType (pt, p);
} else } else
name = TypeManager.RenderType (pt, p); name += TypeManager.RenderType (pt, p);
if (!pt.IsValueType && AttributeManager.HasAttribute<NullAllowedAttribute> (p)) if (!pt.IsValueType && AttributeManager.HasAttribute<NullAllowedAttribute> (p))
name += "?"; name += "?";
return name; return name;

Просмотреть файл

@ -47,6 +47,8 @@
<Compile Include="$(RepositoryPath)\src\ObjCRuntime\ArgumentSemantic.cs" /> <Compile Include="$(RepositoryPath)\src\ObjCRuntime\ArgumentSemantic.cs" />
<Compile Include="$(RepositoryPath)\src\ObjCRuntime\BindAsAttribute.cs" /> <Compile Include="$(RepositoryPath)\src\ObjCRuntime\BindAsAttribute.cs" />
<Compile Include="$(RepositoryPath)\src\ObjCRuntime\BindingImplAttribute.cs" /> <Compile Include="$(RepositoryPath)\src\ObjCRuntime\BindingImplAttribute.cs" />
<Compile Include="$(RepositoryPath)\src\ObjCRuntime\BlockCallbackAttribute.cs" />
<Compile Include="$(RepositoryPath)\src\ObjCRuntime\CCallbackAttribute.cs" />
<Compile Include="$(RepositoryPath)\src\ObjCRuntime\LinkWithAttribute.cs" /> <Compile Include="$(RepositoryPath)\src\ObjCRuntime\LinkWithAttribute.cs" />
<Compile Include="$(RepositoryPath)\src\ObjCRuntime\NativeAttribute.cs" /> <Compile Include="$(RepositoryPath)\src\ObjCRuntime\NativeAttribute.cs" />
<Compile Include="$(RepositoryPath)\src\ObjCRuntime\NativeNameAttribute.cs" /> <Compile Include="$(RepositoryPath)\src\ObjCRuntime\NativeNameAttribute.cs" />

Просмотреть файл

@ -1,4 +1,4 @@
/// //
// Authors: // Authors:
// Miguel de Icaza (miguel@xamarin.com) // Miguel de Icaza (miguel@xamarin.com)
// //

Просмотреть файл

@ -1928,6 +1928,8 @@ SHARED_CORE_SOURCES = \
ObjCRuntime/ArgumentSemantic.cs \ ObjCRuntime/ArgumentSemantic.cs \
ObjCRuntime/BindAsAttribute.cs \ ObjCRuntime/BindAsAttribute.cs \
ObjCRuntime/Blocks.cs \ ObjCRuntime/Blocks.cs \
ObjCRuntime/BlockCallbackAttribute.cs \
ObjCRuntime/CCallbackAttribute.cs \
ObjCRuntime/Class.cs \ ObjCRuntime/Class.cs \
ObjCRuntime/Constants.cs \ ObjCRuntime/Constants.cs \
ObjCRuntime/DisposableObject.cs \ ObjCRuntime/DisposableObject.cs \

Просмотреть файл

@ -133,6 +133,8 @@
<Compile Include="..\src\ObjCRuntime\ArgumentSemantic.cs" /> <Compile Include="..\src\ObjCRuntime\ArgumentSemantic.cs" />
<Compile Include="..\src\ObjCRuntime\BindAsAttribute.cs" /> <Compile Include="..\src\ObjCRuntime\BindAsAttribute.cs" />
<Compile Include="..\src\ObjCRuntime\BindingImplAttribute.cs" /> <Compile Include="..\src\ObjCRuntime\BindingImplAttribute.cs" />
<Compile Include="..\src\ObjCRuntime\BlockCallbackAttribute.cs" />
<Compile Include="..\src\ObjCRuntime\CCallbackAttribute.cs" />
<Compile Include="..\src\ObjCRuntime\LinkWithAttribute.cs" /> <Compile Include="..\src\ObjCRuntime\LinkWithAttribute.cs" />
<Compile Include="..\src\ObjCRuntime\NativeAttribute.cs" /> <Compile Include="..\src\ObjCRuntime\NativeAttribute.cs" />
<Compile Include="..\src\ObjCRuntime\NativeNameAttribute.cs" /> <Compile Include="..\src\ObjCRuntime\NativeNameAttribute.cs" />

Просмотреть файл

@ -1,4 +1,4 @@
/// //
// Authors: // Authors:
// Miguel de Icaza (miguel@xamarin.com) // Miguel de Icaza (miguel@xamarin.com)
// //

Просмотреть файл

@ -1,4 +1,4 @@
/// //
// Authors: // Authors:
// Miguel de Icaza (miguel@xamarin.com) // Miguel de Icaza (miguel@xamarin.com)
// Aaron Bockover (abock@xamarin.com) // Aaron Bockover (abock@xamarin.com)

Просмотреть файл

@ -196,20 +196,6 @@ namespace Cecil.Tests {
"System.Boolean CoreGraphics.CGDisplay::CGDisplayIsCaptured(System.UInt32)", "System.Boolean CoreGraphics.CGDisplay::CGDisplayIsCaptured(System.UInt32)",
"System.Boolean CoreGraphics.CGEventSource::GetButtonState(CoreGraphics.CGEventSourceStateID,CoreGraphics.CGMouseButton)", "System.Boolean CoreGraphics.CGEventSource::GetButtonState(CoreGraphics.CGEventSourceStateID,CoreGraphics.CGMouseButton)",
"System.Boolean CoreGraphics.CGEventSource::GetKeyState(CoreGraphics.CGEventSourceStateID,System.UInt16)", "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::CGPDFDictionaryGetArray(System.IntPtr,System.IntPtr,System.IntPtr&)",
"System.Boolean CoreGraphics.CGPDFDictionary::CGPDFDictionaryGetBoolean(System.IntPtr,System.IntPtr,System.Boolean&)", "System.Boolean CoreGraphics.CGPDFDictionary::CGPDFDictionaryGetBoolean(System.IntPtr,System.IntPtr,System.Boolean&)",
"System.Boolean CoreGraphics.CGPDFDictionary::CGPDFDictionaryGetDictionary(System.IntPtr,System.IntPtr,System.IntPtr&)", "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.CGPDFScanner::CGPDFScannerScan(System.IntPtr)",
"System.Boolean CoreGraphics.CGRectExtensions::CGRectIsInfinite(CoreGraphics.CGRect)", "System.Boolean CoreGraphics.CGRectExtensions::CGRectIsInfinite(CoreGraphics.CGRect)",
"System.Boolean CoreGraphics.CGRectExtensions::CGRectIsNull(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::CMBlockBufferIsEmpty(System.IntPtr)",
"System.Boolean CoreMedia.CMBlockBuffer::CMBlockBufferIsRangeContiguous(System.IntPtr,System.UIntPtr,System.UIntPtr)", "System.Boolean CoreMedia.CMBlockBuffer::CMBlockBufferIsRangeContiguous(System.IntPtr,System.UIntPtr,System.UIntPtr)",
"System.Boolean CoreMedia.CMClock::CMClockMightDrift(System.IntPtr,System.IntPtr)", "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::SSLCopyALPNProtocols(System.IntPtr,System.IntPtr&)",
"System.Int32 Security.SslContext::SSLSetSessionTicketsEnabled(System.IntPtr,System.Boolean)", "System.Int32 Security.SslContext::SSLSetSessionTicketsEnabled(System.IntPtr,System.Boolean)",
"System.Int32 SystemConfiguration.NetworkReachability::SCNetworkReachabilityGetFlags(System.IntPtr,SystemConfiguration.NetworkReachabilityFlags&)", "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.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.CGPDFStream::CGPDFStreamCopyData(System.IntPtr,CoreGraphics.CGPDFDataFormat&)",
"System.IntPtr CoreGraphics.CGShading::CGShadingCreateAxial(System.IntPtr,CoreGraphics.CGPoint,CoreGraphics.CGPoint,System.IntPtr,System.Boolean,System.Boolean)", "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,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&,System.IntPtr)",
"System.IntPtr SystemConfiguration.NetworkReachability::SCNetworkReachabilityCreateWithAddressPair(System.IntPtr,SystemConfiguration.NetworkReachability/sockaddr_in&,SystemConfiguration.NetworkReachability/sockaddr_in&)", "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.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 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*)", "System.Void CoreText.CTFontManager::CTFontManagerRegisterFontDescriptors(System.IntPtr,CoreText.CTFontManagerScope,System.Boolean,ObjCRuntime.BlockLiteral*)",

Просмотреть файл

@ -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."); $"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] [Test]
[TestCase (ApplePlatform.iOS, "iossimulator-x64")] [TestCase (ApplePlatform.iOS, "iossimulator-x64")]
[TestCase (ApplePlatform.iOS, "ios-arm64")] [TestCase (ApplePlatform.iOS, "ios-arm64")]

Просмотреть файл

@ -23,11 +23,6 @@ namespace Xamarin.Tests {
case ApplePlatform.iOS: case ApplePlatform.iOS:
case ApplePlatform.TVOS: case ApplePlatform.TVOS:
expectedWarnings = new ExpectedBuildMessage [] { 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 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/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."), 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; break;
case ApplePlatform.MacOSX: case ApplePlatform.MacOSX:
expectedWarnings = new ExpectedBuildMessage [] { 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 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/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."), 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; break;
case ApplePlatform.MacCatalyst: case ApplePlatform.MacCatalyst:
expectedWarnings = new ExpectedBuildMessage [] { 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 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/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."), 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.iOS:
case ApplePlatform.TVOS: case ApplePlatform.TVOS:
expectedWarnings = new ExpectedBuildMessage [] { 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/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 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 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/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."), 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; break;
case ApplePlatform.MacOSX: case ApplePlatform.MacOSX:
expectedWarnings = new ExpectedBuildMessage [] { 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/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 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 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 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/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; break;
case ApplePlatform.MacCatalyst: case ApplePlatform.MacCatalyst:
expectedWarnings = new ExpectedBuildMessage [] { 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/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 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 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 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/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."),

Просмотреть файл

@ -1434,6 +1434,12 @@ namespace GeneratorTests {
BuildFile (Profile.iOS, "tests/internal-delegate.cs"); BuildFile (Profile.iOS, "tests/internal-delegate.cs");
} }
[Test]
public void DelegateParameterAttributes ()
{
BuildFile (Profile.iOS, "tests/delegate-parameter-attributes.cs");
}
#if NET #if NET
[Test] [Test]
public void Issue19612 () public void Issue19612 ()

Просмотреть файл

@ -0,0 +1,6 @@
using Foundation;
namespace Test {
[Protocol]
interface DerivedProtocol : INSFilePresenter { }
}

Просмотреть файл

@ -818,7 +818,6 @@ namespace MonoTests.System.Net.Http {
for (var i = 0; i < iterations; i++) { for (var i = 0; i < iterations; i++) {
var rsp = delegatingHandler.Responses [i]; var rsp = delegatingHandler.Responses [i];
Assert.IsTrue (delegatingHandler.IsCompleted (i), $"Completed #{i}"); Assert.IsTrue (delegatingHandler.IsCompleted (i), $"Completed #{i}");
Assert.IsTrue (rsp.IsSuccessStatusCode, $"IsSuccessStatusCode #{i}");
Assert.AreEqual ("OK", rsp.ReasonPhrase, $"ReasonPhrase #{i}"); Assert.AreEqual ("OK", rsp.ReasonPhrase, $"ReasonPhrase #{i}");
Assert.AreEqual (HttpStatusCode.OK, rsp.StatusCode, $"StatusCode #{i}"); Assert.AreEqual (HttpStatusCode.OK, rsp.StatusCode, $"StatusCode #{i}");

Просмотреть файл

@ -652,7 +652,7 @@ public class Frameworks : Dictionary<string, Framework> {
{ "Cinematic", "Cinematic", new Version (17, 0), NotAvailableInSimulator }, { "Cinematic", "Cinematic", new Version (17, 0), NotAvailableInSimulator },
{ "Symbols", "Symbols", 17, 0 }, { "Symbols", "Symbols", 17, 0 },
{ "NetworkExtension", "NetworkExtension", 17, 0 }, { "NetworkExtension", "NetworkExtension", 17, 0 },
{ "Phase", "PHASE", new Version (17,0), NotAvailableInSimulator }, { "Phase", "PHASE", new Version (17,0), NotAvailableInSimulator },
}; };
} }
return tvos_frameworks; return tvos_frameworks;