Skip to content

Commit

Permalink
Merge branch 'main' into xcode13.0-quicklookui-b1
Browse files Browse the repository at this point in the history
  • Loading branch information
rachelkang committed Aug 10, 2021
2 parents d27fdac + 300fc28 commit 194d7c4
Show file tree
Hide file tree
Showing 58 changed files with 1,272 additions and 508 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;

namespace Xamarin.MacDev.Tasks
{
public abstract class GetFileSystemEntriesTaskBase : XamarinTask
{
#region Inputs

[Required]
public string DirectoryPath { get; set; }

[Required]
public string Pattern { get; set; }

[Required]
public bool Recursive { get; set; }
#endregion

#region Outputs

[Output]
public ITaskItem[] Entries { get; set; }

#endregion

public override bool Execute ()
{
var searchOption = Recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
var entriesFullPath = Directory.GetFileSystemEntries (DirectoryPath, Pattern, searchOption);

Entries = entriesFullPath.Select (v => new TaskItem (v)).ToArray ();

return !Log.HasLoggedErrors;
}
}
}
23 changes: 23 additions & 0 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/GetFileSystemEntries.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Microsoft.Build.Framework;
using Xamarin.Messaging.Build.Client;

namespace Xamarin.MacDev.Tasks
{
public class GetFileSystemEntries : GetFileSystemEntriesTaskBase, ICancelableTask
{
public override bool Execute ()
{
if (ShouldExecuteRemotely ())
return new TaskRunner (SessionId, BuildEngine4).RunAsync (this).Result;

return base.Execute ();
}

public void Cancel ()
{
if (ShouldExecuteRemotely ())
BuildConnection.CancelAsync (SessionId, BuildEngine4).Wait ();
}
}
}

2 changes: 2 additions & 0 deletions msbuild/Xamarin.Shared/Xamarin.Shared.targets
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ Copyright (C) 2018 Microsoft. All rights reserved.
<UsingTask TaskName="Xamarin.MacDev.Tasks.FindItemWithLogicalName" AssemblyFile="$(_TaskAssemblyName)" />
<UsingTask TaskName="Xamarin.MacDev.Tasks.GenerateBundleName" AssemblyFile="$(_TaskAssemblyName)" />
<UsingTask TaskName="Xamarin.MacDev.Tasks.GetDirectories" AssemblyFile="$(_TaskAssemblyName)" />
<UsingTask TaskName="Xamarin.MacDev.Tasks.GetFileSystemEntries" AssemblyFile="$(_TaskAssemblyName)" />
<UsingTask TaskName="Xamarin.MacDev.Tasks.GetFullPath" AssemblyFile="$(_TaskAssemblyName)" />
<UsingTask TaskName="Xamarin.MacDev.Tasks.GetMinimumOSVersion" AssemblyFile="$(_TaskAssemblyName)" />
<UsingTask TaskName="Xamarin.MacDev.Tasks.GetNativeExecutableName" AssemblyFile="$(_TaskAssemblyName)" />
Expand Down Expand Up @@ -1169,6 +1170,7 @@ Copyright (C) 2018 Microsoft. All rights reserved.
Resources="@(_Frameworks)"
SigningKey="$(_FrameworkCodeSigningKey)"
ExtraArgs="$(CodesignExtraArgs)"
UseSecureTimestamp="$(UseHardenedRuntime)"
>
</Codesign>

Expand Down
17 changes: 17 additions & 0 deletions msbuild/Xamarin.iOS.Tasks.Core/Xamarin.iOS.Common.targets
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,23 @@ Copyright (C) 2013-2016 Xamarin. All rights reserved.
<_CodesignDisableTimestamp Condition="'$(_SdkIsSimulator)' == 'true' Or '$(_BundlerDebug)' == 'true'">True</_CodesignDisableTimestamp>
</PropertyGroup>

<!-- Delete any crash dumps in the app bundle that might exist. Ref: https://github.com/xamarin/xamarin-macios/issues/12320 -->
<!-- Use a task to collect the files, so that we get the correct behavior on Windows -->
<GetFileSystemEntries
SessionId="$(BuildSessionId)"
Condition="'$(IsMacEnabled)' == 'true'"
DirectoryPath="$(AppBundleDir)"
Pattern="mono_crash.mem.*"
Recursive="false"
>
<Output TaskParameter="Entries" ItemName="_MonoCrashDumpsInAppBundle" />
</GetFileSystemEntries>
<Delete
SessionId="$(BuildSessionId)"
Condition="'$(IsMacEnabled)' == 'true'"
Files="@(_MonoCrashDumpsInAppBundle)"
/>

<Codesign
SessionId="$(BuildSessionId)"
Condition="'$(IsMacEnabled)' == 'true'"
Expand Down
41 changes: 40 additions & 1 deletion src/Security/Authorization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,23 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

#if MONOMAC
#if MONOMAC || __MACCATALYST__

using ObjCRuntime;
using Foundation;
using System;
using System.Runtime.InteropServices;
#if NET
using System.Runtime.Versioning;
#endif

namespace Security {

#if NET
[SupportedOSPlatform ("maccatalyst15.0")]
#else
[MacCatalyst (15,0)]
#endif
// Untyped enum in ObjC
public enum AuthorizationStatus {
Success = 0,
Expand All @@ -52,6 +61,11 @@ public enum AuthorizationStatus {
BadAddress = -60033,
}

#if NET
[SupportedOSPlatform ("maccatalyst15.0")]
#else
[MacCatalyst (15,0)]
#endif
// typedef UInt32 AuthorizationFlags;
[Flags]
public enum AuthorizationFlags : int {
Expand All @@ -68,18 +82,33 @@ public enum AuthorizationFlags : int {
// For ease of use, we let the user pass the AuthorizationParameters, and we
// create the structure for them with the proper data
//
#if NET
[SupportedOSPlatform ("maccatalyst15.0")]
#else
[MacCatalyst (15,0)]
#endif
public class AuthorizationParameters {
public string PathToSystemPrivilegeTool;
public string Prompt;
public string IconPath;
}

#if NET
[SupportedOSPlatform ("maccatalyst15.0")]
#else
[MacCatalyst (15,0)]
#endif
public class AuthorizationEnvironment {
public string Username;
public string Password;
public bool AddToSharedCredentialPool;
}

#if NET
[SupportedOSPlatform ("maccatalyst15.0")]
#else
[MacCatalyst (15,0)]
#endif
[StructLayout (LayoutKind.Sequential)]
struct AuthorizationItem {
public IntPtr /* AuthorizationString = const char * */ name;
Expand All @@ -88,11 +117,21 @@ struct AuthorizationItem {
public int /* UInt32 */ flags; // zero
}

#if NET
[SupportedOSPlatform ("maccatalyst15.0")]
#else
[MacCatalyst (15,0)]
#endif
unsafe struct AuthorizationItemSet {
public int /* UInt32 */ count;
public AuthorizationItem * /* AuthorizationItem* */ ptrToAuthorization;
}

#if NET
[SupportedOSPlatform ("maccatalyst15.0")]
#else
[MacCatalyst (15,0)]
#endif
public unsafe class Authorization : INativeObject, IDisposable {
IntPtr handle;

Expand Down
Loading

0 comments on commit 194d7c4

Please sign in to comment.