[net9.0] Merge main into net9.0. (#20244)
--------- Co-authored-by: Yauheni Pakala <evgeniy.pakalo@gmail.com> Co-authored-by: Manuel de la Pena <mandel@microsoft.com> Co-authored-by: Haritha Mohan <harithamohan@microsoft.com>
This commit is contained in:
Коммит
82b9e51eb3
|
@ -2070,6 +2070,7 @@
|
|||
<Unzip
|
||||
SessionId="$(BuildSessionId)"
|
||||
Condition="'$(IsMacEnabled)' == 'true' Or '$(IsHotRestartBuild)' == 'true'"
|
||||
CopyToWindows="true"
|
||||
ZipFilePath="%(_CompressedXpcServices.Identity)"
|
||||
ExtractionPath="%(_CompressedXpcServices.ExtractionPath)"
|
||||
>
|
||||
|
|
|
@ -78,9 +78,9 @@
|
|||
<Uri>https://github.com/dotnet/templating</Uri>
|
||||
<Sha />
|
||||
</Dependency>
|
||||
<Dependency Name="Microsoft.DotNet.XHarness.iOS.Shared" Version="9.0.0-prerelease.24119.1">
|
||||
<Dependency Name="Microsoft.DotNet.XHarness.iOS.Shared" Version="9.0.0-prerelease.24129.1">
|
||||
<Uri>https://github.com/dotnet/xharness</Uri>
|
||||
<Sha>8aa2a4cb80000ebb46ee61cd6ac29b2e63ebe87c</Sha>
|
||||
<Sha>9649ddab48b3795a49c6b51ccf588d56ca4be4e5</Sha>
|
||||
</Dependency>
|
||||
</ToolsetDependencies>
|
||||
</Dependencies>
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<MicrosoftNETRuntimeMonoTargetsSdkPackageVersion>9.0.0-alpha.1.23556.4</MicrosoftNETRuntimeMonoTargetsSdkPackageVersion>
|
||||
<MicrosoftTemplateEngineTasksVersion>7.0.100-alpha.1.21601.1</MicrosoftTemplateEngineTasksVersion>
|
||||
<MicrosoftDotNetCecilPackageVersion>0.11.4-alpha.24120.1</MicrosoftDotNetCecilPackageVersion>
|
||||
<MicrosoftDotNetXHarnessiOSSharedPackageVersion>9.0.0-prerelease.24119.1</MicrosoftDotNetXHarnessiOSSharedPackageVersion>
|
||||
<MicrosoftDotNetXHarnessiOSSharedPackageVersion>9.0.0-prerelease.24129.1</MicrosoftDotNetXHarnessiOSSharedPackageVersion>
|
||||
<!-- Manually updated versions -->
|
||||
<Emscriptennet7WorkloadVersion>$(MicrosoftNETWorkloadEmscriptenCurrentManifest80100Version)</Emscriptennet7WorkloadVersion>
|
||||
<EmscriptenWorkloadVersion>$(MicrosoftNETWorkloadEmscriptenCurrentManifest80100Version)</EmscriptenWorkloadVersion>
|
||||
|
|
|
@ -1533,4 +1533,16 @@
|
|||
{1}: the exit code of a process
|
||||
</comment>
|
||||
</data>
|
||||
|
||||
<data name="E7119" xml:space="preserve">
|
||||
<value>Task execution was cancelled.</value>
|
||||
<comment></comment>
|
||||
</data>
|
||||
|
||||
<data name="E7120" xml:space="preserve">
|
||||
<value>Unable to compute the remote generator properties. Please file an issue at https://github.com/xamarin/xamarin-macios/issues/new and attach the following file: {0}</value>
|
||||
<comment>
|
||||
{0}: the path to a file
|
||||
</comment>
|
||||
</data>
|
||||
</root>
|
||||
|
|
|
@ -223,6 +223,12 @@ namespace Xamarin.MacDev.Tasks {
|
|||
|
||||
public override bool Execute ()
|
||||
{
|
||||
if (Assemblies.Length == 0) {
|
||||
// Not sure how this can happen, since Assemblies is [Required], but it seems to happen once in a while.
|
||||
Log.LogMessage (MessageImportance.Low, "Nothing to AOT-compile");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ShouldExecuteRemotely ())
|
||||
return new TaskRunner (SessionId, BuildEngine4).RunAsync (this).Result;
|
||||
|
||||
|
|
|
@ -122,6 +122,10 @@ namespace Xamarin.MacDev.Tasks {
|
|||
arguments.Add (projectPath);
|
||||
|
||||
ExecuteAsync (executable, arguments, environment: environment).Wait ();
|
||||
if (!File.Exists (outputFile)) {
|
||||
Log.LogError (MSBStrings.E7120 /* Unable to compute the remote generator properties. Please file an issue at https://github.com/xamarin/xamarin-macios/issues/new and attach the following file: {0} */, binlog);
|
||||
return;
|
||||
}
|
||||
var computedPropertes = File.ReadAllLines (outputFile);
|
||||
foreach (var line in computedPropertes) {
|
||||
var property = line.Substring (0, line.IndexOf ('='));
|
||||
|
|
|
@ -181,7 +181,11 @@ namespace Xamarin.MacDev.Tasks {
|
|||
|
||||
public bool ShouldCopyToBuildServer (ITaskItem item) => true;
|
||||
|
||||
public bool ShouldCreateOutputFile (ITaskItem item) => true;
|
||||
public bool ShouldCreateOutputFile (ITaskItem item)
|
||||
{
|
||||
// Don't create output files for the packaged files, because we already copy the entire files to Windows (TransferBindingResourcePackagesToWindowsAsync).
|
||||
return Array.IndexOf (PackagedFiles, item) == -1;
|
||||
}
|
||||
|
||||
public void Cancel ()
|
||||
{
|
||||
|
|
|
@ -6,6 +6,7 @@ using System.Linq;
|
|||
using Microsoft.Build.Framework;
|
||||
using Microsoft.Build.Utilities;
|
||||
|
||||
using Xamarin.Localization.MSBuild;
|
||||
using Xamarin.Messaging.Build.Client;
|
||||
|
||||
#nullable enable
|
||||
|
@ -38,6 +39,8 @@ namespace Xamarin.MacDev.Tasks {
|
|||
|
||||
#endregion
|
||||
|
||||
bool cancelled;
|
||||
|
||||
public override bool Execute ()
|
||||
{
|
||||
if (ShouldExecuteRemotely ())
|
||||
|
@ -48,10 +51,16 @@ namespace Xamarin.MacDev.Tasks {
|
|||
foreach (var item in DirectoryPath) {
|
||||
var path = item.ItemSpec.TrimEnd ('\\', '/');
|
||||
var entriesFullPath = IncludeDirectories ?
|
||||
Directory.GetFileSystemEntries (path, Pattern, searchOption) :
|
||||
Directory.GetFiles (path, Pattern, searchOption);
|
||||
Directory.EnumerateFileSystemEntries (path, Pattern, searchOption) :
|
||||
Directory.EnumerateFiles (path, Pattern, searchOption);
|
||||
|
||||
Log.LogMessage (MessageImportance.Low, $"Searching for {(IncludeDirectories ? "files and directories" : "files")} in {path} with pattern '{Pattern}' and search option {searchOption}. Current directory: {Environment.CurrentDirectory}");
|
||||
|
||||
foreach (var entry in entriesFullPath) {
|
||||
if (cancelled) {
|
||||
Log.LogError (MSBStrings.E7119 /* Task execution was cancelled. */);
|
||||
return false;
|
||||
}
|
||||
var recursiveDir = entry.Substring (path.Length + 1);
|
||||
var newItem = new TaskItem (entry);
|
||||
item.CopyMetadataTo (newItem);
|
||||
|
@ -70,6 +79,7 @@ namespace Xamarin.MacDev.Tasks {
|
|||
{
|
||||
if (ShouldExecuteRemotely ())
|
||||
BuildConnection.CancelAsync (BuildEngine4).Wait ();
|
||||
cancelled = true;
|
||||
}
|
||||
|
||||
public IEnumerable<ITaskItem> GetAdditionalItemsToBeCopied ()
|
||||
|
|
|
@ -22,6 +22,9 @@ namespace Xamarin.MacDev.Tasks {
|
|||
/// This task works on Windows too, but if the task encounters a symlink while extracting, an error will be shown.
|
||||
/// </summary>
|
||||
public class Unzip : XamarinTask, ITaskCallback {
|
||||
// If we should copy the extracted files to Windows (as opposed to just creating an empty output file).
|
||||
public bool CopyToWindows { get; set; }
|
||||
|
||||
[Required]
|
||||
public ITaskItem? ZipFilePath { get; set; }
|
||||
|
||||
|
@ -37,8 +40,15 @@ namespace Xamarin.MacDev.Tasks {
|
|||
|
||||
public override bool Execute ()
|
||||
{
|
||||
if (ShouldExecuteRemotely ())
|
||||
return new TaskRunner (SessionId, BuildEngine4).RunAsync (this).Result;
|
||||
if (ShouldExecuteRemotely ()) {
|
||||
var taskRunner = new TaskRunner (SessionId, BuildEngine4);
|
||||
var rv = taskRunner.RunAsync (this).Result;
|
||||
|
||||
if (rv && CopyToWindows)
|
||||
CopyFilesToWindowsAsync (taskRunner, TouchedFiles).Wait ();
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
return ExecuteLocally ();
|
||||
}
|
||||
|
@ -51,7 +61,12 @@ namespace Xamarin.MacDev.Tasks {
|
|||
|
||||
public bool ShouldCopyToBuildServer (ITaskItem item) => true;
|
||||
|
||||
public bool ShouldCreateOutputFile (ITaskItem item) => true;
|
||||
public bool ShouldCreateOutputFile (ITaskItem item)
|
||||
{
|
||||
if (CopyToWindows)
|
||||
return Array.IndexOf (TouchedFiles, item) == -1;
|
||||
return true;
|
||||
}
|
||||
|
||||
public IEnumerable<ITaskItem> GetAdditionalItemsToBeCopied () => Enumerable.Empty<ITaskItem> ();
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ using Microsoft.Build.Tasks;
|
|||
using Microsoft.Build.Utilities;
|
||||
|
||||
using Xamarin.Localization.MSBuild;
|
||||
using Xamarin.Messaging.Build.Client;
|
||||
using Xamarin.Utils;
|
||||
using static Xamarin.Bundler.FileCopier;
|
||||
|
||||
|
@ -244,5 +245,13 @@ namespace Xamarin.MacDev.Tasks {
|
|||
{
|
||||
return CreateItemsForAllFilesRecursively (directories?.Select (v => v.ItemSpec));
|
||||
}
|
||||
|
||||
internal async global::System.Threading.Tasks.Task CopyFilesToWindowsAsync (TaskRunner runner, IEnumerable<ITaskItem> items)
|
||||
{
|
||||
foreach (var item in items) {
|
||||
Log.LogMessage (MessageImportance.Low, $"Copying {item.ItemSpec} from the remote Mac to Windows");
|
||||
await runner.GetFileAsync (this, item.ItemSpec).ConfigureAwait (false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -179,10 +179,10 @@ namespace CoreGraphics {
|
|||
}
|
||||
|
||||
[DllImport (Constants.ApplicationServicesCoreGraphicsLibrary)]
|
||||
extern static IntPtr CGEventCreateKeyboardEvent (IntPtr source, ushort virtualKey, [MarshalAs (UnmanagedType.I1)] bool keyDown);
|
||||
extern static IntPtr CGEventCreateKeyboardEvent (IntPtr source, ushort virtualKey, byte keyDown);
|
||||
|
||||
public CGEvent (CGEventSource? source, ushort virtualKey, bool keyDown)
|
||||
: base (CGEventCreateKeyboardEvent (source.GetHandle (), virtualKey, keyDown), true)
|
||||
: base (CGEventCreateKeyboardEvent (source.GetHandle (), virtualKey, keyDown.AsByte ()), true)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -406,41 +406,42 @@ namespace CoreGraphics {
|
|||
}
|
||||
|
||||
[DllImport (Constants.ApplicationServicesCoreGraphicsLibrary)]
|
||||
extern static void CGEventTapEnable (IntPtr machPort, [MarshalAs (UnmanagedType.I1)] bool enable);
|
||||
extern static void CGEventTapEnable (IntPtr machPort, byte enable);
|
||||
|
||||
public static void TapEnable (CFMachPort machPort)
|
||||
{
|
||||
if (machPort is null)
|
||||
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (machPort));
|
||||
CGEventTapEnable (machPort.Handle, true);
|
||||
CGEventTapEnable (machPort.Handle, 1);
|
||||
}
|
||||
|
||||
public static void TapDisable (CFMachPort machPort)
|
||||
{
|
||||
if (machPort is null)
|
||||
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (machPort));
|
||||
CGEventTapEnable (machPort.Handle, false);
|
||||
CGEventTapEnable (machPort.Handle, 0);
|
||||
}
|
||||
|
||||
[DllImport (Constants.ApplicationServicesCoreGraphicsLibrary)]
|
||||
[return: MarshalAs (UnmanagedType.I1)]
|
||||
extern static bool CGEventTapIsEnabled (IntPtr machPort);
|
||||
extern static byte CGEventTapIsEnabled (IntPtr machPort);
|
||||
|
||||
public static bool IsTapEnabled (CFMachPort machPort)
|
||||
{
|
||||
if (machPort is null)
|
||||
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (machPort));
|
||||
return CGEventTapIsEnabled (machPort.Handle);
|
||||
return CGEventTapIsEnabled (machPort.Handle) != 0;
|
||||
}
|
||||
|
||||
[DllImport (Constants.ApplicationServicesCoreGraphicsLibrary)]
|
||||
unsafe extern static void CGEventKeyboardGetUnicodeString (IntPtr handle, nuint maxLen, out nuint actualLen, char *buffer);
|
||||
unsafe extern static void CGEventKeyboardGetUnicodeString (IntPtr handle, nuint maxLen, nuint* actualLen, ushort *buffer);
|
||||
|
||||
public unsafe string GetUnicodeString ()
|
||||
{
|
||||
char *buffer = stackalloc char [40];
|
||||
CGEventKeyboardGetUnicodeString (Handle, 40, out var actual, buffer);
|
||||
return new String (buffer, 0, (int) actual);
|
||||
const int bufferLength = 40;
|
||||
ushort *buffer = stackalloc ushort [bufferLength];
|
||||
nuint actual = 0;
|
||||
CGEventKeyboardGetUnicodeString (Handle, bufferLength, &actual, buffer);
|
||||
return new String ((char *) buffer, 0, (int) actual);
|
||||
}
|
||||
|
||||
#if NET
|
||||
|
@ -500,16 +501,16 @@ namespace CoreGraphics {
|
|||
unsafe extern static int /* CGError = int32_t */ CGGetEventTapList (
|
||||
uint /* uint32_t */ maxNumberOfTaps,
|
||||
CGEventTapInformation *tapList,
|
||||
out uint /* uint32_t* */ eventTapCount);
|
||||
uint* /* uint32_t* */ eventTapCount);
|
||||
|
||||
public unsafe CGEventTapInformation []? GetEventTapList ()
|
||||
{
|
||||
uint count;
|
||||
if (CGGetEventTapList (0, null, out count) != 0)
|
||||
if (CGGetEventTapList (0, null, &count) != 0)
|
||||
return null;
|
||||
var result = new CGEventTapInformation [count];
|
||||
fixed (CGEventTapInformation *p = result){
|
||||
if (CGGetEventTapList (count, p, out count) != 0)
|
||||
if (CGGetEventTapList (count, p, &count) != 0)
|
||||
return null;
|
||||
}
|
||||
return result;
|
||||
|
@ -519,33 +520,53 @@ namespace CoreGraphics {
|
|||
[SupportedOSPlatform ("macos")]
|
||||
[SupportedOSPlatform ("maccatalyst")]
|
||||
#endif
|
||||
[DllImport (Constants.ApplicationServicesCoreGraphicsLibrary, EntryPoint="CGPreflightListenEventAccess")]
|
||||
[return: MarshalAs (UnmanagedType.I1)]
|
||||
public static extern bool PreflightListenEventAccess ();
|
||||
[DllImport (Constants.ApplicationServicesCoreGraphicsLibrary)]
|
||||
static extern byte CGPreflightListenEventAccess ();
|
||||
|
||||
#if NET
|
||||
[SupportedOSPlatform ("macos")]
|
||||
[SupportedOSPlatform ("maccatalyst")]
|
||||
#endif
|
||||
public static bool PreflightListenEventAccess () => CGPreflightListenEventAccess () != 0;
|
||||
|
||||
#if NET
|
||||
[SupportedOSPlatform ("macos")]
|
||||
[SupportedOSPlatform ("maccatalyst")]
|
||||
#endif
|
||||
[DllImport (Constants.ApplicationServicesCoreGraphicsLibrary, EntryPoint="CGRequestListenEventAccess")]
|
||||
[return: MarshalAs (UnmanagedType.I1)]
|
||||
public static extern bool RequestListenEventAccess ();
|
||||
static extern byte CGRequestListenEventAccess ();
|
||||
|
||||
#if NET
|
||||
[SupportedOSPlatform ("macos")]
|
||||
[SupportedOSPlatform ("maccatalyst")]
|
||||
#endif
|
||||
[DllImport (Constants.ApplicationServicesCoreGraphicsLibrary, EntryPoint="CGPreflightPostEventAccess")]
|
||||
[return: MarshalAs (UnmanagedType.I1)]
|
||||
public static extern bool PreflightPostEventAccess ();
|
||||
public static bool RequestListenEventAccess () => CGRequestListenEventAccess () != 0;
|
||||
|
||||
#if NET
|
||||
[SupportedOSPlatform ("macos")]
|
||||
[SupportedOSPlatform ("maccatalyst")]
|
||||
#endif
|
||||
[DllImport (Constants.ApplicationServicesCoreGraphicsLibrary, EntryPoint="CGRequestPostEventAccess")]
|
||||
[return: MarshalAs (UnmanagedType.I1)]
|
||||
public static extern bool RequestPostEventAccess ();
|
||||
[DllImport (Constants.ApplicationServicesCoreGraphicsLibrary)]
|
||||
static extern byte CGPreflightPostEventAccess ();
|
||||
|
||||
#if NET
|
||||
[SupportedOSPlatform ("macos")]
|
||||
[SupportedOSPlatform ("maccatalyst")]
|
||||
#endif
|
||||
public static bool PreflightPostEventAccess () => CGPreflightPostEventAccess () != 0;
|
||||
|
||||
#if NET
|
||||
[SupportedOSPlatform ("macos")]
|
||||
[SupportedOSPlatform ("maccatalyst")]
|
||||
#endif
|
||||
[DllImport (Constants.ApplicationServicesCoreGraphicsLibrary)]
|
||||
static extern byte CGRequestPostEventAccess ();
|
||||
|
||||
#if NET
|
||||
[SupportedOSPlatform ("macos")]
|
||||
[SupportedOSPlatform ("maccatalyst")]
|
||||
#endif
|
||||
public static bool RequestPostEventAccess () => CGRequestPostEventAccess () != 0;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -62,8 +62,8 @@ namespace CoreGraphics {
|
|||
cbacks.evaluate = &EvaluateCallback;
|
||||
cbacks.release = &ReleaseCallback;
|
||||
#else
|
||||
cbacks.evaluate = new CGFunctionEvaluateCallback (EvaluateCallback);
|
||||
cbacks.release = new CGFunctionReleaseCallback (ReleaseCallback);
|
||||
cbacks.evaluate = Marshal.GetFunctionPointerForDelegate (evaluateCallbackDelegate);
|
||||
cbacks.release = Marshal.GetFunctionPointerForDelegate (releaseCallbackDelegate);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -116,13 +116,13 @@ namespace CoreGraphics {
|
|||
public unsafe delegate* unmanaged<IntPtr, nfloat*, nfloat*, void> evaluate;
|
||||
public unsafe delegate* unmanaged<IntPtr, void> release;
|
||||
#else
|
||||
public CGFunctionEvaluateCallback? evaluate;
|
||||
public CGFunctionReleaseCallback? release;
|
||||
public IntPtr evaluate;
|
||||
public IntPtr release;
|
||||
#endif
|
||||
}
|
||||
|
||||
[DllImport (Constants.CoreGraphicsLibrary)]
|
||||
extern static unsafe IntPtr CGFunctionCreate (/* void* */ IntPtr data, /* size_t */ nint domainDimension, /* CGFloat* */ nfloat* domain, nint rangeDimension, /* CGFloat* */ nfloat* range, ref CGFunctionCallbacks callbacks);
|
||||
extern static unsafe IntPtr CGFunctionCreate (/* void* */ IntPtr data, /* size_t */ nint domainDimension, /* CGFloat* */ nfloat* domain, nint rangeDimension, /* CGFloat* */ nfloat* range, CGFunctionCallbacks* callbacks);
|
||||
|
||||
unsafe public delegate void CGFunctionEvaluate (nfloat* data, nfloat* outData);
|
||||
|
||||
|
@ -145,14 +145,17 @@ namespace CoreGraphics {
|
|||
var gch = GCHandle.Alloc (this);
|
||||
unsafe {
|
||||
fixed (nfloat* domainPtr = domain, rangePtr = range) {
|
||||
var handle = CGFunctionCreate (GCHandle.ToIntPtr (gch), domain is not null ? domain.Length / 2 : 0, domainPtr, range is not null ? range.Length / 2 : 0, rangePtr, ref cbacks);
|
||||
fixed (CGFunctionCallbacks* cbacksptr = &cbacks) {
|
||||
var handle = CGFunctionCreate (GCHandle.ToIntPtr (gch), domain is not null ? domain.Length / 2 : 0, domainPtr, range is not null ? range.Length / 2 : 0, rangePtr, cbacksptr);
|
||||
InitializeHandle (handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#if NET
|
||||
[UnmanagedCallersOnly]
|
||||
#else
|
||||
static CGFunctionReleaseCallback releaseCallbackDelegate = ReleaseCallback;
|
||||
#if !MONOMAC
|
||||
[MonoPInvokeCallback (typeof (CGFunctionReleaseCallback))]
|
||||
#endif
|
||||
|
@ -165,6 +168,7 @@ namespace CoreGraphics {
|
|||
#if NET
|
||||
[UnmanagedCallersOnly]
|
||||
#else
|
||||
unsafe static CGFunctionEvaluateCallback evaluateCallbackDelegate = EvaluateCallback;
|
||||
#if !MONOMAC
|
||||
[MonoPInvokeCallback (typeof (CGFunctionEvaluateCallback))]
|
||||
#endif
|
||||
|
|
|
@ -179,7 +179,7 @@ namespace CoreGraphics {
|
|||
extern static unsafe /* CGImageRef */ IntPtr CGImageCreate (/* size_t */ nint width, /* size_t */ nint height,
|
||||
/* size_t */ nint bitsPerComponent, /* size_t */ nint bitsPerPixel, /* size_t */ nint bytesPerRow,
|
||||
/* CGColorSpaceRef */ IntPtr space, CGBitmapFlags bitmapInfo, /* CGDataProviderRef */ IntPtr provider,
|
||||
/* CGFloat[] */ nfloat* decode, [MarshalAs (UnmanagedType.I1)] bool shouldInterpolate, CGColorRenderingIntent intent);
|
||||
/* CGFloat[] */ nfloat* decode, byte shouldInterpolate, CGColorRenderingIntent intent);
|
||||
|
||||
static IntPtr Create (int width, int height, int bitsPerComponent, int bitsPerPixel, int bytesPerRow,
|
||||
CGColorSpace? colorSpace, CGBitmapFlags bitmapFlags, CGDataProvider? provider,
|
||||
|
@ -200,7 +200,7 @@ namespace CoreGraphics {
|
|||
fixed (nfloat* decodePtr = decode) {
|
||||
return CGImageCreate (width, height, bitsPerComponent, bitsPerPixel, bytesPerRow,
|
||||
colorSpace.GetHandle (), bitmapFlags, provider.GetHandle (),
|
||||
decodePtr, shouldInterpolate, intent);
|
||||
decodePtr, shouldInterpolate.AsByte (), intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ namespace CoreGraphics {
|
|||
fixed (nfloat* decodePtr = decode) {
|
||||
return CGImageCreate (width, height, bitsPerComponent, bitsPerPixel, bytesPerRow,
|
||||
colorSpace.GetHandle (), (CGBitmapFlags) alphaInfo, provider.GetHandle (),
|
||||
decodePtr, shouldInterpolate, intent);
|
||||
decodePtr, shouldInterpolate.AsByte (), intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -301,13 +301,13 @@ namespace CoreGraphics {
|
|||
|
||||
[DllImport (Constants.CoreGraphicsLibrary)]
|
||||
extern static unsafe /* CGImageRef */ IntPtr CGImageCreateWithJPEGDataProvider (/* CGDataProviderRef */ IntPtr source,
|
||||
/* CGFloat[] */ nfloat* decode, [MarshalAs (UnmanagedType.I1)] bool shouldInterpolate, CGColorRenderingIntent intent);
|
||||
/* CGFloat[] */ nfloat* decode, byte shouldInterpolate, CGColorRenderingIntent intent);
|
||||
|
||||
public static CGImage? FromJPEG (CGDataProvider? provider, nfloat []? decode, bool shouldInterpolate, CGColorRenderingIntent intent)
|
||||
{
|
||||
unsafe {
|
||||
fixed (nfloat* decodePtr = decode) {
|
||||
var handle = CGImageCreateWithJPEGDataProvider (provider.GetHandle (), decodePtr, shouldInterpolate, intent);
|
||||
var handle = CGImageCreateWithJPEGDataProvider (provider.GetHandle (), decodePtr, shouldInterpolate.AsByte (), intent);
|
||||
return FromHandle (handle, true);
|
||||
}
|
||||
}
|
||||
|
@ -315,13 +315,13 @@ namespace CoreGraphics {
|
|||
|
||||
[DllImport (Constants.CoreGraphicsLibrary)]
|
||||
extern static unsafe /* CGImageRef */ IntPtr CGImageCreateWithPNGDataProvider (/* CGDataProviderRef */ IntPtr source,
|
||||
/* CGFloat[] */ nfloat* decode, [MarshalAs (UnmanagedType.I1)] bool shouldInterpolate, CGColorRenderingIntent intent);
|
||||
/* CGFloat[] */ nfloat* decode, byte shouldInterpolate, CGColorRenderingIntent intent);
|
||||
|
||||
public static CGImage? FromPNG (CGDataProvider provider, nfloat []? decode, bool shouldInterpolate, CGColorRenderingIntent intent)
|
||||
{
|
||||
unsafe {
|
||||
fixed (nfloat* decodePtr = decode) {
|
||||
var handle = CGImageCreateWithPNGDataProvider (provider.GetHandle (), decodePtr, shouldInterpolate, intent);
|
||||
var handle = CGImageCreateWithPNGDataProvider (provider.GetHandle (), decodePtr, shouldInterpolate.AsByte (), intent);
|
||||
return FromHandle (handle, true);
|
||||
}
|
||||
}
|
||||
|
@ -330,7 +330,7 @@ namespace CoreGraphics {
|
|||
[DllImport (Constants.CoreGraphicsLibrary)]
|
||||
extern static unsafe /* CGImageRef */ IntPtr CGImageMaskCreate (/* size */ nint width, /* size */ nint height,
|
||||
/* size */ nint bitsPerComponent, /* size */ nint bitsPerPixel, /* size */ nint bytesPerRow,
|
||||
/* CGDataProviderRef */ IntPtr provider, /* CGFloat[] */ nfloat* decode, [MarshalAs (UnmanagedType.I1)] bool shouldInterpolate);
|
||||
/* CGDataProviderRef */ IntPtr provider, /* CGFloat[] */ nfloat* decode, byte shouldInterpolate);
|
||||
|
||||
public static CGImage? CreateMask (int width, int height, int bitsPerComponent, int bitsPerPixel, int bytesPerRow, CGDataProvider? provider, nfloat []? decode, bool shouldInterpolate)
|
||||
{
|
||||
|
@ -345,7 +345,7 @@ namespace CoreGraphics {
|
|||
unsafe {
|
||||
fixed (nfloat* decodePtr = decode) {
|
||||
|
||||
var handle = CGImageMaskCreate (width, height, bitsPerComponent, bitsPerPixel, bytesPerRow, provider.GetHandle (), decodePtr, shouldInterpolate);
|
||||
var handle = CGImageMaskCreate (width, height, bitsPerComponent, bitsPerPixel, bytesPerRow, provider.GetHandle (), decodePtr, shouldInterpolate.AsByte ());
|
||||
return FromHandle (handle, true);
|
||||
}
|
||||
}
|
||||
|
@ -405,12 +405,11 @@ namespace CoreGraphics {
|
|||
}
|
||||
|
||||
[DllImport (Constants.CoreGraphicsLibrary)]
|
||||
[return: MarshalAs (UnmanagedType.I1)]
|
||||
extern static bool CGImageIsMask (/* CGImageRef */ IntPtr image);
|
||||
extern static byte CGImageIsMask (/* CGImageRef */ IntPtr image);
|
||||
|
||||
public bool IsMask {
|
||||
get {
|
||||
return CGImageIsMask (Handle);
|
||||
return CGImageIsMask (Handle) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -498,12 +497,11 @@ namespace CoreGraphics {
|
|||
}
|
||||
|
||||
[DllImport (Constants.CoreGraphicsLibrary)]
|
||||
[return: MarshalAs (UnmanagedType.I1)]
|
||||
extern static bool CGImageGetShouldInterpolate (/* CGImageRef */ IntPtr image);
|
||||
extern static byte CGImageGetShouldInterpolate (/* CGImageRef */ IntPtr image);
|
||||
|
||||
public bool ShouldInterpolate {
|
||||
get {
|
||||
return CGImageGetShouldInterpolate (Handle);
|
||||
return CGImageGetShouldInterpolate (Handle) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -491,6 +491,11 @@ namespace Foundation {
|
|||
};
|
||||
|
||||
if (stream != Stream.Null) {
|
||||
// Rewind the stream to the beginning in case the HttpContent implementation
|
||||
// will be accessed again (e.g. for retry/redirect) and it keeps its stream open behind the scenes.
|
||||
if (stream.CanSeek)
|
||||
stream.Seek (0, SeekOrigin.Begin);
|
||||
|
||||
// HttpContent.TryComputeLength is `protected internal` :-( but it's indirectly called by headers
|
||||
var length = request.Content?.Headers?.ContentLength;
|
||||
if (length.HasValue && (length <= MaxInputInMemory))
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -57,9 +57,6 @@
|
|||
<Compile Include="$(RepositoryPath)\tools\common\Execution.cs">
|
||||
<Link>Execution.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Resources.Designer.cs">
|
||||
<DependentUpon>..\Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="..\..\tools\common\Driver.execution.cs">
|
||||
<Link>Driver.execution.cs</Link>
|
||||
</Compile>
|
||||
|
@ -72,6 +69,13 @@
|
|||
<EmbeddedResource Include="..\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>..\Resources.Designer.cs</LastGenOutput>
|
||||
<StronglyTypedFileName>..\Resources.Designer.cs</StronglyTypedFileName>
|
||||
<StronglyTypedLanguage>CSharp</StronglyTypedLanguage>
|
||||
<StronglyTypedNamespace>bgen</StronglyTypedNamespace>
|
||||
<StronglyTypedClassName>Resources</StronglyTypedClassName>
|
||||
<ManifestResourceName>bgen.Resources</ManifestResourceName>
|
||||
<GenerateResource>true</GenerateResource>
|
||||
<PublicClass>false</PublicClass>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ clean-local::
|
|||
|
||||
## run targets = build + [install] + exec
|
||||
|
||||
run run-all run-tests run-test:
|
||||
run run-all run-tests run-test run-unit-tests:
|
||||
$(Q) for subdir in $(SUBDIRS); do \
|
||||
$(MAKE) -C $$subdir run || exit 1; \
|
||||
done
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
TOP=../..
|
||||
include $(TOP)/Make.config
|
||||
|
||||
run-tests:
|
||||
run-tests run-unit-tests:
|
||||
$(DOTNET) test $(TEST_FILTER)
|
||||
|
|
|
@ -194,15 +194,8 @@ namespace Cecil.Tests {
|
|||
"Security.SslStatus Security.SslContext::SSLWrite(System.IntPtr,System.Byte*,System.IntPtr,System.IntPtr&)",
|
||||
"System.Boolean CoreGraphics.CGColor::CGColorEqualToColor(System.IntPtr,System.IntPtr)",
|
||||
"System.Boolean CoreGraphics.CGDisplay::CGDisplayIsCaptured(System.UInt32)",
|
||||
"System.Boolean CoreGraphics.CGEvent::CGEventTapIsEnabled(System.IntPtr)",
|
||||
"System.Boolean CoreGraphics.CGEvent::PreflightListenEventAccess()",
|
||||
"System.Boolean CoreGraphics.CGEvent::PreflightPostEventAccess()",
|
||||
"System.Boolean CoreGraphics.CGEvent::RequestListenEventAccess()",
|
||||
"System.Boolean CoreGraphics.CGEvent::RequestPostEventAccess()",
|
||||
"System.Boolean CoreGraphics.CGEventSource::GetButtonState(CoreGraphics.CGEventSourceStateID,CoreGraphics.CGMouseButton)",
|
||||
"System.Boolean CoreGraphics.CGEventSource::GetKeyState(CoreGraphics.CGEventSourceStateID,System.UInt16)",
|
||||
"System.Boolean CoreGraphics.CGImage::CGImageGetShouldInterpolate(System.IntPtr)",
|
||||
"System.Boolean CoreGraphics.CGImage::CGImageIsMask(System.IntPtr)",
|
||||
"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)",
|
||||
|
@ -364,7 +357,6 @@ namespace Cecil.Tests {
|
|||
"System.Int32 AudioUnit.AudioUnit::AudioUnitGetProperty(System.IntPtr,AudioUnit.AudioUnitPropertyIDType,AudioUnit.AudioUnitScopeType,System.UInt32,System.UInt32&,System.UInt32&)",
|
||||
"System.Int32 AudioUnit.AudioUnit::AudioUnitSetProperty(System.IntPtr,AudioUnit.AudioUnitPropertyIDType,AudioUnit.AudioUnitScopeType,System.UInt32,AudioToolbox.AudioStreamBasicDescription&,System.UInt32)",
|
||||
"System.Int32 AudioUnit.AUGraph::NewAUGraph(System.IntPtr&)",
|
||||
"System.Int32 CoreGraphics.CGEvent::CGGetEventTapList(System.UInt32,CoreGraphics.CGEventTapInformation*,System.UInt32&)",
|
||||
"System.Int32 CoreMedia.CMBufferQueue::CMBufferQueueCreate(System.IntPtr,System.IntPtr,CoreMedia.CMBufferQueue/CMBufferCallbacks,System.IntPtr&)",
|
||||
"System.Int32 CoreMedia.CMBufferQueue::CMBufferQueueCreate(System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr&)",
|
||||
"System.Int32 CoreVideo.CVDisplayLink::CVDisplayLinkTranslateTime(System.IntPtr,CoreVideo.CVTimeStamp,CoreVideo.CVTimeStamp&)",
|
||||
|
@ -380,12 +372,6 @@ namespace Cecil.Tests {
|
|||
"System.Int32 Security.SslContext::SSLCopyALPNProtocols(System.IntPtr,System.IntPtr&)",
|
||||
"System.Int32 Security.SslContext::SSLSetSessionTicketsEnabled(System.IntPtr,System.Boolean)",
|
||||
"System.Int32 SystemConfiguration.NetworkReachability::SCNetworkReachabilityGetFlags(System.IntPtr,SystemConfiguration.NetworkReachabilityFlags&)",
|
||||
"System.IntPtr CoreGraphics.CGEvent::CGEventCreateKeyboardEvent(System.IntPtr,System.UInt16,System.Boolean)",
|
||||
"System.IntPtr CoreGraphics.CGFunction::CGFunctionCreate(System.IntPtr,System.IntPtr,System.Runtime.InteropServices.NFloat*,System.IntPtr,System.Runtime.InteropServices.NFloat*,CoreGraphics.CGFunction/CGFunctionCallbacks&)",
|
||||
"System.IntPtr CoreGraphics.CGImage::CGImageCreate(System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr,CoreGraphics.CGBitmapFlags,System.IntPtr,System.Runtime.InteropServices.NFloat*,System.Boolean,CoreGraphics.CGColorRenderingIntent)",
|
||||
"System.IntPtr CoreGraphics.CGImage::CGImageCreateWithJPEGDataProvider(System.IntPtr,System.Runtime.InteropServices.NFloat*,System.Boolean,CoreGraphics.CGColorRenderingIntent)",
|
||||
"System.IntPtr CoreGraphics.CGImage::CGImageCreateWithPNGDataProvider(System.IntPtr,System.Runtime.InteropServices.NFloat*,System.Boolean,CoreGraphics.CGColorRenderingIntent)",
|
||||
"System.IntPtr CoreGraphics.CGImage::CGImageMaskCreate(System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr,System.IntPtr,System.Runtime.InteropServices.NFloat*,System.Boolean)",
|
||||
"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)",
|
||||
|
@ -447,8 +433,6 @@ namespace Cecil.Tests {
|
|||
"System.IntPtr SystemConfiguration.NetworkReachability::SCNetworkReachabilityCreateWithAddressPair(System.IntPtr,System.IntPtr,SystemConfiguration.NetworkReachability/sockaddr_in&)",
|
||||
"System.IntPtr SystemConfiguration.NetworkReachability::SCNetworkReachabilityCreateWithAddressPair(System.IntPtr,SystemConfiguration.NetworkReachability/sockaddr_in&,System.IntPtr)",
|
||||
"System.IntPtr SystemConfiguration.NetworkReachability::SCNetworkReachabilityCreateWithAddressPair(System.IntPtr,SystemConfiguration.NetworkReachability/sockaddr_in&,SystemConfiguration.NetworkReachability/sockaddr_in&)",
|
||||
"System.Void CoreGraphics.CGEvent::CGEventKeyboardGetUnicodeString(System.IntPtr,System.UIntPtr,System.UIntPtr&,System.Char*)",
|
||||
"System.Void CoreGraphics.CGEvent::CGEventTapEnable(System.IntPtr,System.Boolean)",
|
||||
"System.Void CoreGraphics.CGPath::CGPathAddArc(System.IntPtr,CoreGraphics.CGAffineTransform*,System.Runtime.InteropServices.NFloat,System.Runtime.InteropServices.NFloat,System.Runtime.InteropServices.NFloat,System.Runtime.InteropServices.NFloat,System.Runtime.InteropServices.NFloat,System.Boolean)",
|
||||
"System.Void CoreGraphics.CGPDFDocument::CGPDFDocumentGetVersion(System.IntPtr,System.Int32&,System.Int32&)",
|
||||
"System.Void CoreGraphics.CGRectExtensions::CGRectDivide(CoreGraphics.CGRect,CoreGraphics.CGRect&,CoreGraphics.CGRect&,System.Runtime.InteropServices.NFloat,CoreGraphics.CGRectEdge)",
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,226 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
|
||||
using NUnit.Framework;
|
||||
|
||||
using Mono.Cecil;
|
||||
using Mono.Cecil.Cil;
|
||||
|
||||
using ObjCRuntime;
|
||||
|
||||
using Xamarin.Tests;
|
||||
using Xamarin.Utils;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace Cecil.Tests {
|
||||
[TestFixture]
|
||||
public partial class Documentation {
|
||||
// Verify that all our publicly visible APIs are documented.
|
||||
// This is obviously not true, so we have a rather huge list of known failures.
|
||||
// However, this will prevent us from adding more undocumented APIs by accident.
|
||||
[Test]
|
||||
public void VerifyEveryVisibleMemberIsDocumented ()
|
||||
{
|
||||
// We join all the APIs from all the platforms, so we can only run this test when all platforms are enabled.
|
||||
Configuration.IgnoreIfAnyIgnoredPlatforms ();
|
||||
|
||||
// Collect everything
|
||||
var xmlMembers = new HashSet<AssemblyApi> ();
|
||||
var dllMembers = new HashSet<AssemblyApi> ();
|
||||
foreach (var info in Helper.NetPlatformAssemblyDefinitions) {
|
||||
// Just pick one of the implementation assemblies.
|
||||
// We can't just list all the members in the ref assembly, because it doesn't contain any private members, and some private members are documented.
|
||||
var implementationAssembly = Helper.NetPlatformImplementationAssemblyDefinitions.Where (v => Path.GetFileName (v.Path) == Path.GetFileName (info.Path)).First ();
|
||||
|
||||
var xml = GetDocumentedMembers (Path.ChangeExtension (info.Path, ".xml"));
|
||||
xmlMembers.UnionWith (xml);
|
||||
var dll = GetAssemblyMembers (implementationAssembly.Assembly);
|
||||
dllMembers.UnionWith (dll);
|
||||
}
|
||||
|
||||
// Propagate publicness
|
||||
foreach (var dll in dllMembers) {
|
||||
if (xmlMembers.TryGetValue (dll, out var xml)) {
|
||||
xml.PubliclyVisible = dll.PubliclyVisible;
|
||||
}
|
||||
}
|
||||
|
||||
var documentedButNotPresent = xmlMembers.Except (dllMembers).ToList ();
|
||||
Assert.Multiple (() => {
|
||||
foreach (var doc in documentedButNotPresent)
|
||||
Assert.Fail ($"{doc}: Documented API not found in the platform assembly. This probably indicates that the code to compute the doc name for a given member is incorrect.");
|
||||
});
|
||||
|
||||
var visibleButNotDocumented = dllMembers.Except (xmlMembers).Where (v => v.PubliclyVisible == true).Select (v => v.DocId).OrderBy (v => v).ToList ();
|
||||
var knownfailuresFilename = $"Documentation.KnownFailures.txt";
|
||||
var knownfailuresPath = Path.Combine (Configuration.SourceRoot, "tests", "cecil-tests", knownfailuresFilename);
|
||||
var knownfailures = File.Exists (knownfailuresPath) ? File.ReadAllLines (knownfailuresPath) : Array.Empty<string> ();
|
||||
|
||||
var unknownFailures = visibleButNotDocumented.Except (knownfailures).ToList ();
|
||||
var fixedFailures = knownfailures.Except (visibleButNotDocumented).ToList ();
|
||||
|
||||
if (unknownFailures.Any () || fixedFailures.Any ()) {
|
||||
if (!string.IsNullOrEmpty (Environment.GetEnvironmentVariable ("WRITE_KNOWN_FAILURES"))) {
|
||||
File.WriteAllLines (knownfailuresPath, visibleButNotDocumented);
|
||||
Assert.Fail ($"Found {unknownFailures.Count} undocumented APIs (not known failures) and {fixedFailures.Count} APIs that were marked as known failures but are now documented. The known failures have been updated, so please commit the results. Re-running the test should now succeed.");
|
||||
} else {
|
||||
if (unknownFailures.Any ()) {
|
||||
Console.WriteLine ($"Undocumented APIs that aren't known failures (found {unknownFailures.Count}, showing at most 10):");
|
||||
foreach (var failure in unknownFailures.Take (10))
|
||||
Console.WriteLine ($" {failure}");
|
||||
if (unknownFailures.Count > 10)
|
||||
Console.WriteLine ($" ... and {unknownFailures.Count () - 10} more");
|
||||
}
|
||||
if (fixedFailures.Any ()) {
|
||||
Console.WriteLine ($"Documented APIs that are known failures (found {fixedFailures.Count}, showing at most 10):");
|
||||
foreach (var failure in fixedFailures.Take (10))
|
||||
Console.WriteLine ($" {failure}");
|
||||
if (fixedFailures.Count > 10)
|
||||
Console.WriteLine ($" ... and {fixedFailures.Count () - 10} more");
|
||||
}
|
||||
Assert.Fail ($"Found {unknownFailures.Count} undocumented APIs (not known failures) and {fixedFailures.Count} APIs that were marked as known failures but are now documented. If this is expected, set the WRITE_KNOWN_FAILURES=1 environment variable, run the test again, and commit the modified known failures file.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static HashSet<AssemblyApi> GetDocumentedMembers (string xml)
|
||||
{
|
||||
var rv = new HashSet<AssemblyApi> ();
|
||||
var doc = new XmlDocument ();
|
||||
doc.LoadWithoutNetworkAccess (xml);
|
||||
foreach (XmlNode node in doc.SelectNodes ("/doc/members/member")!) {
|
||||
rv.Add (new AssemblyApi (node.Attributes! ["name"]!.Value!, null));
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
class AssemblyApi {
|
||||
public string DocId;
|
||||
public bool? PubliclyVisible;
|
||||
|
||||
public AssemblyApi (string docId, bool? visible)
|
||||
{
|
||||
DocId = docId;
|
||||
PubliclyVisible = visible;
|
||||
}
|
||||
|
||||
public override int GetHashCode ()
|
||||
{
|
||||
return DocId.GetHashCode ();
|
||||
}
|
||||
|
||||
public override bool Equals (object? other)
|
||||
{
|
||||
return other is AssemblyApi aa && aa.DocId == DocId;
|
||||
}
|
||||
}
|
||||
|
||||
static HashSet<AssemblyApi> GetAssemblyMembers (AssemblyDefinition asm)
|
||||
{
|
||||
var rv = new HashSet<AssemblyApi> ();
|
||||
|
||||
foreach (var member in asm.EnumerateMembers ()) {
|
||||
string name;
|
||||
|
||||
if (member is MethodDefinition md) {
|
||||
name = "M:" + GetDocId (md);
|
||||
} else if (member is PropertyDefinition pd) {
|
||||
name = "P:" + GetDocId (pd);
|
||||
} else if (member is FieldDefinition fd) {
|
||||
name = "F:" + GetDocId (fd.DeclaringType) + "." + fd.Name;
|
||||
} else if (member is EventDefinition ed) {
|
||||
name = "E:" + GetDocId (ed);
|
||||
} else if (member is TypeDefinition td) {
|
||||
name = "T:" + GetDocId (td);
|
||||
} else {
|
||||
throw new NotImplementedException ($"Unknown member type: {member.GetType ()}");
|
||||
}
|
||||
rv.Add (new AssemblyApi (name, member.IsPubliclyVisible ()));
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
// https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/xmldoc/#id-strings
|
||||
|
||||
static string GetDocId (MethodDefinition md)
|
||||
{
|
||||
var methodName = md.Name.Replace ('.', '#');
|
||||
var name = GetDocId (md.DeclaringType) + "." + methodName;
|
||||
if (md.HasGenericParameters)
|
||||
name += $"``{md.GenericParameters.Count}";
|
||||
if (md.HasParameters) {
|
||||
name += "(" + string.Join (",", md.Parameters.Select (p => GetDocId (p.ParameterType))) + ")";
|
||||
}
|
||||
|
||||
if (md.Name == "op_Explicit" || md.Name == "op_Implicit") {
|
||||
name += "~" + GetDocId (md.ReturnType);
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
static string GetDocId (EventDefinition ed) => GetDocId (ed.DeclaringType) + "." + ed.Name;
|
||||
|
||||
static string GetDocId (PropertyDefinition pd)
|
||||
{
|
||||
var name = GetDocId (pd.DeclaringType) + "." + pd.Name;
|
||||
if (pd.HasParameters) {
|
||||
name += "(" + string.Join (",", pd.Parameters.Select (p => GetDocId (p.ParameterType))) + ")";
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
static string GetDocId (TypeReference tr)
|
||||
{
|
||||
string name = "";
|
||||
if (tr.IsNested) {
|
||||
var decl = tr.DeclaringType;
|
||||
while (decl.IsNested) {
|
||||
name = decl.Name + "." + name;
|
||||
decl = decl.DeclaringType;
|
||||
}
|
||||
name = decl.Namespace + "." + decl.Name + "." + name;
|
||||
} else {
|
||||
name = tr.Namespace + ".";
|
||||
}
|
||||
|
||||
if (tr is GenericInstanceType git) {
|
||||
name += git.Name [0..(git.Name.IndexOf ('`'))];
|
||||
name += "{" + string.Join (",", git.GenericArguments.Select (v => GetDocId (v))) + "}";
|
||||
} else if (tr is TypeDefinition td && td.HasGenericParameters) {
|
||||
name += tr.Name;
|
||||
} else if (tr is ByReferenceType brt) {
|
||||
name += brt.ElementType.Name + "@";
|
||||
} else if (tr is GenericParameter gp) {
|
||||
name = $"`{gp.Position}";
|
||||
} else if (tr is ArrayType at) {
|
||||
name = GetDocId (at.ElementType);
|
||||
if (at.Rank == 1) {
|
||||
name += "[]";
|
||||
} else {
|
||||
name += "[";
|
||||
for (var d = 0; d < at.Dimensions.Count; d++) {
|
||||
if (d > 0)
|
||||
name += ",";
|
||||
var dim = at.Dimensions [d];
|
||||
if (dim.LowerBound.HasValue)
|
||||
name += dim.LowerBound.Value;
|
||||
name += ":";
|
||||
if (dim.UpperBound.HasValue)
|
||||
name += dim.UpperBound.Value;
|
||||
}
|
||||
name += "]";
|
||||
}
|
||||
} else {
|
||||
name += tr.Name;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
|
||||
using NUnit.Framework;
|
||||
|
||||
|
@ -668,6 +669,21 @@ namespace Cecil.Tests {
|
|||
}
|
||||
}
|
||||
|
||||
public static class Extensions {
|
||||
public static void LoadWithoutNetworkAccess (this XmlDocument doc, string filename)
|
||||
{
|
||||
using (var fs = new FileStream (filename, FileMode.Open, FileAccess.Read)) {
|
||||
var settings = new XmlReaderSettings () {
|
||||
XmlResolver = null,
|
||||
DtdProcessing = DtdProcessing.Parse,
|
||||
};
|
||||
using (var reader = XmlReader.Create (fs, settings)) {
|
||||
doc.Load (reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class AssemblyInfo {
|
||||
public AssemblyDefinition Assembly;
|
||||
public string Path;
|
||||
|
|
|
@ -7,7 +7,7 @@ all-local::
|
|||
build:
|
||||
$(Q) $(DOTNET) build $(DOTNET_BUILD_VERBOSITY) /bl
|
||||
|
||||
run-tests: build
|
||||
run-tests run-unit-tests: build
|
||||
$(DOTNET) test $(abspath $(TOP)/tests/cecil-tests/bin/Debug/$(DOTNET_TFM)/cecil-tests.dll) $(TEST_NAME) '--logger:console;verbosity=detailed'
|
||||
|
||||
clean:
|
||||
|
|
|
@ -279,7 +279,7 @@ namespace Xamarin.Tests {
|
|||
msg.AppendLine ($" {string.Join ($"{Environment.NewLine} ", error.ToString ().Split ('\n', '\r'))}");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
msg.AppendLine ($"Failed to list errors: {e}");
|
||||
msg.AppendLine ($"Failed to list errors in the binlog {binlogPath}: {e}");
|
||||
}
|
||||
#endif
|
||||
Assert.Fail (msg.ToString ());
|
||||
|
|
|
@ -4,7 +4,7 @@ include $(TOP)/Make.config
|
|||
|
||||
TARGETS += \
|
||||
|
||||
run-unit-tests:
|
||||
run-tests run-unit-tests:
|
||||
$(MAKE) -C UnitTests $@
|
||||
|
||||
all-local:: $(TARGETS)
|
||||
|
|
|
@ -12,7 +12,7 @@ publish:
|
|||
# Example TEST_FILTER:
|
||||
# TEST_FILTER="--filter FullyQualifiedName~BuildMyCocoaApp"
|
||||
# Docs: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-test#filter-option-details
|
||||
run-unit-tests:
|
||||
run-tests run-unit-tests:
|
||||
$(DOTNET) test DotNetUnitTests.csproj $(TEST_FILTER)
|
||||
|
||||
run-published:
|
||||
|
|
|
@ -8,7 +8,7 @@ build-unit-tests:
|
|||
$(Q_XBUILD) $(SYSTEM_XIBUILD) -t -- /Library/Frameworks//Mono.framework/Versions/Current/lib/mono/nuget/NuGet.exe restore $(TOP)/src/generator.sln
|
||||
$(SYSTEM_MSBUILD) generator-tests.csproj $(XBUILD_VERBOSITY)
|
||||
|
||||
run-unit-tests: build-unit-tests
|
||||
run-tests run-unit-tests: build-unit-tests
|
||||
rm -f .failed-stamp
|
||||
$(TOP)/tools/nunit3-console-3.11.1 $(abspath $(TOP)/tests/generator/bin/Debug/generator-tests.dll) "--result=$(abspath $(CURDIR)/TestResult.xml);format=nunit2" $(TEST_FIXTURE) --labels=After || touch $(CURDIR)/.failed-stamp
|
||||
@# Create an html file and tell MonkeyWrench to upload it (if we're running there)
|
||||
|
|
|
@ -758,5 +758,79 @@ namespace MonoTests.System.Net.Http {
|
|||
Assert.AreEqual (HttpStatusCode.Unauthorized, httpStatus, "Second status not ok");
|
||||
}
|
||||
}
|
||||
|
||||
class TestDelegateHandler : DelegatingHandler {
|
||||
public int Iterations;
|
||||
public HttpResponseMessage [] Responses;
|
||||
|
||||
public TestDelegateHandler (int iterations)
|
||||
{
|
||||
Responses = new HttpResponseMessage [iterations];
|
||||
Iterations = iterations;
|
||||
}
|
||||
|
||||
public bool IsCompleted (int iteration)
|
||||
{
|
||||
return Responses [iteration] is not null;
|
||||
}
|
||||
|
||||
protected override async Task<HttpResponseMessage> SendAsync (HttpRequestMessage request, CancellationToken cancellationToken)
|
||||
{
|
||||
// test that we can perform a retry with the same request
|
||||
for (var i = 0; i < Iterations; i++)
|
||||
Responses [i] = await base.SendAsync (request, cancellationToken);
|
||||
return Responses.Last ();
|
||||
}
|
||||
}
|
||||
|
||||
[TestCase]
|
||||
public void GHIssue16339 ()
|
||||
{
|
||||
// test that we can perform two diff requests with the same managed HttpRequestMessage
|
||||
var json = "{this:\"\", is:\"a\", test:2}";
|
||||
var iterations = 2;
|
||||
var bodies = new string [iterations];
|
||||
|
||||
var request = new HttpRequestMessage {
|
||||
Method = HttpMethod.Post,
|
||||
RequestUri = new (NetworkResources.Httpbin.PostUrl),
|
||||
Content = new StringContent (json, Encoding.UTF8, "application/json")
|
||||
};
|
||||
|
||||
using var delegatingHandler = new TestDelegateHandler (iterations) {
|
||||
InnerHandler = new NSUrlSessionHandler (),
|
||||
};
|
||||
|
||||
var done = TestRuntime.TryRunAsync (TimeSpan.FromSeconds (30), async () => {
|
||||
using var client = new HttpClient (delegatingHandler);
|
||||
var _ = await client.SendAsync (request);
|
||||
for (var i = 0; i < iterations; i++) {
|
||||
if (delegatingHandler.IsCompleted (i))
|
||||
bodies [i] = await delegatingHandler.Responses [i].Content.ReadAsStringAsync ();
|
||||
}
|
||||
}, out var ex);
|
||||
|
||||
if (!done) { // timeouts happen in the bots due to dns issues, connection issues etc.. we do not want to fail
|
||||
Assert.Inconclusive ("Request timedout.");
|
||||
} else {
|
||||
Assert.IsNull (ex, "Exception");
|
||||
|
||||
for (var i = 0; i < iterations; i++) {
|
||||
var rsp = delegatingHandler.Responses [i];
|
||||
Assert.IsTrue (delegatingHandler.IsCompleted (i), $"Completed #{i}");
|
||||
Assert.IsTrue (rsp.IsSuccessStatusCode, $"IsSuccessStatusCode #{i}");
|
||||
Assert.AreEqual ("OK", rsp.ReasonPhrase, $"ReasonPhrase #{i}");
|
||||
Assert.AreEqual (HttpStatusCode.OK, rsp.StatusCode, $"StatusCode #{i}");
|
||||
|
||||
var body = bodies [i];
|
||||
// Poor-man's json parser
|
||||
var data = body.Split ('\n', '\r').Single (v => v.Contains ("\"data\": \""));
|
||||
data = data.Trim ().Replace ("\"data\": \"", "").TrimEnd ('"', ',');
|
||||
data = data.Replace ("\\\"", "\"");
|
||||
|
||||
Assert.AreEqual (json, data, $"Post data #{i}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ all-local::
|
|||
# or multiple tests:
|
||||
# make run-tests TEST_FIXTURE="-test=Xamarin.MTouch.MT1016,Xamarin.MTouch.MT1017"
|
||||
|
||||
run-tests: bin/Debug/mtouchtests.dll test.config
|
||||
run-tests run-unit-tests: bin/Debug/mtouchtests.dll test.config
|
||||
rm -f .failed-stamp
|
||||
$(TOP)/tools/nunit3-console-3.11.1 "$(abspath $<)" "--result=$(abspath $(CURDIR)/TestResult.xml);format=nunit2" $(TEST_FIXTURE) --labels=After --inprocess || touch $(CURDIR)/.failed-stamp
|
||||
@# Create an html file and tell MonkeyWrench to upload it (if we're running there)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
TOP=../../../..
|
||||
include $(TOP)/Make.config
|
||||
|
||||
run-tests:
|
||||
run-tests run-unit-tests:
|
||||
$(Q_GEN) pwsh -Command "Install-Module -AcceptLicense -Force -AllowClobber Pester;Invoke-Pester"
|
||||
|
|
|
@ -26,7 +26,10 @@ stages:
|
|||
- job: apiscan
|
||||
displayName: 'APIScan:'
|
||||
timeoutInMinutes: 1000
|
||||
pool: VSEngSS-MicroBuild2022-1ES
|
||||
pool:
|
||||
name: MAUI-1ESPT
|
||||
demands:
|
||||
- ImageOverride -equals 1ESPT-Windows2022
|
||||
|
||||
strategy:
|
||||
matrix: $[ stageDependencies.configure_build.configure.outputs['apiscan_matrix.APISCAN_MATRIX'] ]
|
||||
|
|
|
@ -76,6 +76,10 @@ parameters:
|
|||
type: string
|
||||
default: ''
|
||||
|
||||
- name: retryCount
|
||||
type: number
|
||||
default: 3
|
||||
|
||||
steps:
|
||||
|
||||
- template: ../common/checkout.yml
|
||||
|
@ -132,6 +136,7 @@ steps:
|
|||
./maccore/tools/install-qa-provisioning-profiles.sh -v
|
||||
displayName: 'Add provisioning profiles'
|
||||
timeoutInMinutes: 30
|
||||
retryCountOnTaskFailure: ${{ parameters.retryCount }} # We sometinmes have network issues when we try to retrieve the version of provisionator
|
||||
env:
|
||||
AUTH_TOKEN_GITHUB_COM: ${{ parameters.gitHubToken }}
|
||||
AUTH_TOKEN_LA_DEV_APPLE_P12: ${{ parameters.xqaCertPass }}
|
||||
|
|
Загрузка…
Ссылка в новой задаче