Skip to content

Commit

Permalink
Merge main into xcode14. (#15950)
Browse files Browse the repository at this point in the history
  • Loading branch information
rolfbjarne authored Sep 15, 2022
2 parents b85a883 + 3e065fe commit 105d3eb
Show file tree
Hide file tree
Showing 71 changed files with 521 additions and 120 deletions.
2 changes: 1 addition & 1 deletion msbuild/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MessagingVersion>1.7.9</MessagingVersion>
<MessagingVersion>1.7.14</MessagingVersion>
<HotRestartVersion>1.0.93</HotRestartVersion>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ protected string ApplicationIdentifierKey {

public string BundleIdentifier { get; set; }

public string CodesignProvision { get; set; }

public string CodesignEntitlements { get; set; }

public string CodesignRequireProvisioningProfile { get; set; }

public string Keychain { get; set; }

public string SigningKey { get; set; }
Expand All @@ -117,8 +123,6 @@ protected string ApplicationIdentifierKey {

public bool RequireCodeSigning { get; set; }

public bool RequireProvisioningProfile { get; set; }

#endregion

#region Outputs
Expand All @@ -141,6 +145,59 @@ protected string ApplicationIdentifierKey {

#endregion

bool? requireProvisioningProfile;
public bool RequireProvisioningProfile {
get {
// RequireProvisioningProfile:
// * iOS, tvOS, watchOS: required if building for device or if a custom (.NET: non-empty) entitlement file is used
// * macOS, Mac Catalyst: requirerd if a provisioning profile is specified
// * Default logic is overridable by setting the "CodesignRequireProvisioningProfile=true|false" property

if (!requireProvisioningProfile.HasValue) {
if (string.IsNullOrEmpty (CodesignRequireProvisioningProfile)) {
switch (Platform) {
case ApplePlatform.iOS:
case ApplePlatform.TVOS:
case ApplePlatform.WatchOS:
requireProvisioningProfile = !SdkIsSimulator || HasEntitlements;
break;
case ApplePlatform.MacCatalyst:
case ApplePlatform.MacOSX:
requireProvisioningProfile = !string.IsNullOrEmpty (CodesignProvision);
break;
default:
throw new InvalidOperationException (string.Format (MSBStrings.InvalidPlatform, Platform));
}
} else {
requireProvisioningProfile = string.Equals (CodesignRequireProvisioningProfile, "true", StringComparison.OrdinalIgnoreCase);
}
}
return requireProvisioningProfile.Value;
}
}

bool? hasEntitlements;
bool HasEntitlements {
get {
if (!hasEntitlements.HasValue) {
if (string.IsNullOrEmpty (CodesignEntitlements)) {
// If no CodesignEntitlements was specified, we don't have any entitlements
hasEntitlements = false;
} else {
if (IsDotNet) {
// .NET: Check the file to see if there are any entitlements inside
var entitlements = PDictionary.FromFile (CodesignEntitlements);
hasEntitlements = entitlements.Count > 0;
} else {
// Legacy Xamarin: to preserve backwards compat, consider the presence of a file enough to say we have entitlements.
hasEntitlements = true;
}
}
}
return hasEntitlements.Value;
}
}

class CodeSignIdentity
{
public X509Certificate2 SigningKey { get; set; }
Expand Down
10 changes: 0 additions & 10 deletions msbuild/Xamarin.Shared/Xamarin.Shared.props
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,6 @@ Copyright (C) 2020 Microsoft. All rights reserved.
-->
<CodesignEntitlements Condition="'$(UsingAppleNETSdk)' == 'true' And '$(CodesignEntitlements)' == '' And Exists('Entitlements.plist') And '$(EnableDefaultCodesignEntitlements)' != 'false'">Entitlements.plist</CodesignEntitlements>

<!-- _RequireProvisioningProfile -->
<!-- Default: false -->
<!-- macOS: true if a provisioning profile is used -->
<!-- iOS/tvOS/watchOS: true if building for device or if a custom entitlements file is used -->
<!-- Mac Catalyst: true if a provisioning profile is used -->
<_RequireProvisioningProfile Condition="'$(_RequireProvisioningProfile)' == '' And '$(_PlatformName)' == 'macOS' And '$(CodesignProvision)' != ''">true</_RequireProvisioningProfile>
<_RequireProvisioningProfile Condition="'$(_RequireProvisioningProfile)' == '' And ('$(_PlatformName)' == 'iOS' Or '$(_PlatformName)' == 'tvOS' Or '$(_PlatformName)' == 'watchOS') And ('$(ComputedPlatform)' == 'iPhone' Or '$(CodesignEntitlements)' != '')">true</_RequireProvisioningProfile>
<_RequireProvisioningProfile Condition="'$(_RequireProvisioningProfile)' == '' And '$(_PlatformName)' == 'MacCatalyst' And '$(CodesignProvision)' != ''">true</_RequireProvisioningProfile>
<_RequireProvisioningProfile Condition="'$(_RequireProvisioningProfile)' == ''">false</_RequireProvisioningProfile>

<!-- If we should automatically try to detect the app manifest (Info.plist) from any None, BundleResource or Content items -->
<!-- It might be desirable to turn off the automatic detection if the current logic detects Info.plist that aren't the app manifest -->
<!-- One example would be when including native frameworks in the app bundle - frameworks have an Info.plist that might be picked up -->
Expand Down
4 changes: 3 additions & 1 deletion msbuild/Xamarin.Shared/Xamarin.Shared.targets
Original file line number Diff line number Diff line change
Expand Up @@ -1698,12 +1698,14 @@ Copyright (C) 2018 Microsoft. All rights reserved.
<Target Name="_DetectSigningIdentity" Condition="'$(_CanOutputAppBundle)' == 'true'" DependsOnTargets="$(_DetectSigningIdentityDependsOn)">
<DetectSigningIdentity
SessionId="$(BuildSessionId)"
CodesignProvision="$(CodesignProvision)"
CodesignEntitlements="$(CodesignEntitlements)"
CodesignRequireProvisioningProfile="$(CodesignRequireProvisioningProfile)"
Condition="'$(IsMacEnabled)' == 'true'"
AppBundleName="$(_AppBundleName)"
BundleIdentifier="$(_BundleIdentifier)"
Keychain="$(CodesignKeychain)"
RequireCodeSigning="$(_RequireCodeSigning)"
RequireProvisioningProfile="$(_RequireProvisioningProfile)"
SdkIsSimulator="$(_SdkIsSimulator)"
SdkPlatform="$(_SdkPlatform)"
ProvisioningProfile="$(CodesignProvision)"
Expand Down
37 changes: 37 additions & 0 deletions src/CoreGraphics/CGDataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,29 +144,48 @@ public CGDataProvider (NSData data)
{
}

#if NET
[DllImport (Constants.CoreGraphicsLibrary)]
extern static unsafe IntPtr CGDataProviderCreateWithData (/* void* */ IntPtr info, /* const void* */ IntPtr data, /* size_t */ nint size, /* CGDataProviderReleaseDataCallback */ delegate* unmanaged<IntPtr, IntPtr, nint, void> releaseData);
#else
[DllImport (Constants.CoreGraphicsLibrary)]
extern static IntPtr CGDataProviderCreateWithData (/* void* */ IntPtr info, /* const void* */ IntPtr data, /* size_t */ nint size, /* CGDataProviderReleaseDataCallback */ CGDataProviderReleaseDataCallback releaseData);
#endif

#if !NET
delegate void CGDataProviderReleaseDataCallback (IntPtr info, IntPtr data, nint size);
static CGDataProviderReleaseDataCallback release_gchandle_callback = ReleaseGCHandle;
static CGDataProviderReleaseDataCallback release_buffer_callback = ReleaseBuffer;
static CGDataProviderReleaseDataCallback release_func_callback = ReleaseFunc;
#endif

#if NET
[UnmanagedCallersOnly]
#else
[MonoPInvokeCallback (typeof (CGDataProviderReleaseDataCallback))]
#endif
private static void ReleaseGCHandle (IntPtr info, IntPtr data, nint size)
{
var gch = GCHandle.FromIntPtr (info);
gch.Free ();
}

#if NET
[UnmanagedCallersOnly]
#else
[MonoPInvokeCallback (typeof (CGDataProviderReleaseDataCallback))]
#endif
private static void ReleaseBuffer (IntPtr info, IntPtr data, nint size)
{
if (data != IntPtr.Zero)
Marshal.FreeHGlobal (data);
}

#if NET
[UnmanagedCallersOnly]
#else
[MonoPInvokeCallback (typeof (CGDataProviderReleaseDataCallback))]
#endif
private static void ReleaseFunc (IntPtr info, IntPtr data, nint size)
{
var gch = GCHandle.FromIntPtr (info);
Expand All @@ -188,7 +207,13 @@ static IntPtr Create (IntPtr memoryBlock, int size, bool ownBuffer)
{
if (!ownBuffer)
memoryBlock = Runtime.CloneMemory (memoryBlock, size);
#if NET
unsafe {
return CGDataProviderCreateWithData (IntPtr.Zero, memoryBlock, size, &ReleaseBuffer);
}
#else
return CGDataProviderCreateWithData (IntPtr.Zero, memoryBlock, size, release_buffer_callback);
#endif
}

public CGDataProvider (IntPtr memoryBlock, int size, bool ownBuffer)
Expand All @@ -202,7 +227,13 @@ static IntPtr Create (IntPtr memoryBlock, int size, Action<IntPtr> releaseMemory
ObjCRuntime.ThrowHelper.ThrowArgumentNullException (nameof (releaseMemoryBlockCallback));

var gch = GCHandle.Alloc (releaseMemoryBlockCallback);
#if NET
unsafe {
return CGDataProviderCreateWithData (GCHandle.ToIntPtr (gch), memoryBlock, size, &ReleaseFunc);
}
#else
return CGDataProviderCreateWithData (GCHandle.ToIntPtr (gch), memoryBlock, size, release_func_callback);
#endif
}

public CGDataProvider (IntPtr memoryBlock, int size, Action<IntPtr> releaseMemoryBlockCallback)
Expand All @@ -221,7 +252,13 @@ static IntPtr Create (byte [] buffer, int offset, int count)

var gch = GCHandle.Alloc (buffer, GCHandleType.Pinned); // This requires a pinned GCHandle, because unsafe code is scoped to the current block, and the address of the byte array will be used after this function returns.
var ptr = gch.AddrOfPinnedObject () + offset;
#if NET
unsafe {
return CGDataProviderCreateWithData (GCHandle.ToIntPtr (gch), ptr, count, &ReleaseGCHandle);
}
#else
return CGDataProviderCreateWithData (GCHandle.ToIntPtr (gch), ptr, count, release_gchandle_callback);
#endif
}

public CGDataProvider (byte [] buffer, int offset, int count)
Expand Down
21 changes: 19 additions & 2 deletions src/CoreGraphics/CGFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,13 @@ public class CGFunction : NativeObject {
unsafe static CGFunction ()
{
cbacks.version = 0;
#if NET
cbacks.evaluate = &EvaluateCallback;
cbacks.release = &ReleaseCallback;
#else
cbacks.evaluate = new CGFunctionEvaluateCallback (EvaluateCallback);
cbacks.release = new CGFunctionReleaseCallback (ReleaseCallback);
#endif
}

#if !NET
Expand Down Expand Up @@ -103,12 +108,17 @@ protected internal override void Release ()
// Apple's documentation says 'float', the header files say 'CGFloat'
unsafe delegate void CGFunctionEvaluateCallback (/* void* */ IntPtr info, /* CGFloat* */ nfloat *data, /* CGFloat* */ nfloat *outData);
delegate void CGFunctionReleaseCallback (IntPtr info);

[StructLayout (LayoutKind.Sequential)]
struct CGFunctionCallbacks {
public /* unsigned int */ uint version;
#if NET
public unsafe delegate* unmanaged<IntPtr, nfloat*, nfloat*, void> evaluate;
public unsafe delegate* unmanaged<IntPtr, void> release;
#else
public CGFunctionEvaluateCallback? evaluate;
public CGFunctionReleaseCallback? release;
#endif
}

[DllImport (Constants.CoreGraphicsLibrary)]
Expand Down Expand Up @@ -136,17 +146,24 @@ public unsafe CGFunction (nfloat []? domain, nfloat []? range, CGFunctionEvaluat
var handle = CGFunctionCreate (GCHandle.ToIntPtr (gch), domain is not null ? domain.Length / 2 : 0, domain, range is not null ? range.Length / 2 : 0, range, ref cbacks);
InitializeHandle (handle);
}

#if NET
[UnmanagedCallersOnly]
#else
#if !MONOMAC
[MonoPInvokeCallback (typeof (CGFunctionReleaseCallback))]
#endif
#endif
static void ReleaseCallback (IntPtr info)
{
GCHandle.FromIntPtr (info).Free ();
}

#if NET
[UnmanagedCallersOnly]
#else
#if !MONOMAC
[MonoPInvokeCallback (typeof (CGFunctionEvaluateCallback))]
#endif
#endif
unsafe static void EvaluateCallback (IntPtr info, nfloat *input, nfloat *output)
{
Expand Down
15 changes: 14 additions & 1 deletion src/CoreGraphics/CGPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -481,9 +481,12 @@ public unsafe bool ContainsPoint (CGPoint point, bool eoFill)
public delegate void ApplierFunction (CGPathElement element);

delegate void CGPathApplierFunction (/* void* */ IntPtr info, /* const CGPathElement* */ IntPtr element);

#if NET
[UnmanagedCallersOnly]
#else
#if !MONOMAC
[MonoPInvokeCallback (typeof (CGPathApplierFunction))]
#endif
#endif
static void ApplierCallback (IntPtr info, IntPtr element_ptr)
{
Expand Down Expand Up @@ -523,12 +526,22 @@ static void ApplierCallback (IntPtr info, IntPtr element_ptr)


[DllImport (Constants.CoreGraphicsLibrary)]
#if NET
extern unsafe static void CGPathApply (/* CGPathRef */ IntPtr path, /* void* */ IntPtr info, delegate* unmanaged<IntPtr, IntPtr, void> function);
#else
extern static void CGPathApply (/* CGPathRef */ IntPtr path, /* void* */ IntPtr info, CGPathApplierFunction function);
#endif

public void Apply (ApplierFunction func)
{
GCHandle gch = GCHandle.Alloc (func);
#if NET
unsafe {
CGPathApply (Handle, GCHandle.ToIntPtr (gch), &ApplierCallback);
}
#else
CGPathApply (Handle, GCHandle.ToIntPtr (gch), ApplierCallback);
#endif
gch.Free ();
}

Expand Down
27 changes: 27 additions & 0 deletions src/CoreGraphics/CGPattern.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,13 @@ public enum CGPatternTiling {
[StructLayout (LayoutKind.Sequential)]
struct CGPatternCallbacks {
internal /* unsigned int */ uint version;
#if NET
internal unsafe delegate* unmanaged<IntPtr, IntPtr, void> draw;
internal unsafe delegate* unmanaged<IntPtr, void> release;
#else
internal DrawPatternCallback draw;
internal ReleaseInfoCallback release;
#endif
}


Expand Down Expand Up @@ -95,11 +100,25 @@ extern static IntPtr CGPatternCreate (/* void* */ IntPtr info, CGRect bounds, CG
/* CGFloat */ nfloat xStep, /* CGFloat */ nfloat yStep, CGPatternTiling tiling, [MarshalAs (UnmanagedType.I1)] bool isColored,
/* const CGPatternCallbacks* */ ref CGPatternCallbacks callbacks);

#if NET
static CGPatternCallbacks callbacks;

static CGPattern () {
unsafe {
callbacks = new CGPatternCallbacks () {
version = 0,
draw = &DrawCallback,
release = &ReleaseCallback,
};
}
}
#else
static CGPatternCallbacks callbacks = new CGPatternCallbacks () {
version = 0,
draw = DrawCallback,
release = ReleaseCallback,
};
#endif
GCHandle gch;

public CGPattern (CGRect bounds, CGAffineTransform matrix, nfloat xStep, nfloat yStep, CGPatternTiling tiling, bool isColored, DrawPattern drawPattern)
Expand All @@ -111,8 +130,12 @@ public CGPattern (CGRect bounds, CGAffineTransform matrix, nfloat xStep, nfloat
Handle = CGPatternCreate (GCHandle.ToIntPtr (gch), bounds, matrix, xStep, yStep, tiling, isColored, ref callbacks);
}

#if NET
[UnmanagedCallersOnly]
#else
#if !MONOMAC
[MonoPInvokeCallback (typeof (DrawPatternCallback))]
#endif
#endif
static void DrawCallback (IntPtr voidptr, IntPtr cgcontextptr)
{
Expand All @@ -123,8 +146,12 @@ static void DrawCallback (IntPtr voidptr, IntPtr cgcontextptr)
}
}

#if NET
[UnmanagedCallersOnly]
#else
#if !MONOMAC
[MonoPInvokeCallback (typeof (ReleaseInfoCallback))]
#endif
#endif
static void ReleaseCallback (IntPtr voidptr)
{
Expand Down
3 changes: 3 additions & 0 deletions tests/common/DotNet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ public static void CompareApps (string old_app, string new_app)
return false; // the .NET runtime will deal with selecting the http handler, no need for us to do anything
case "runtimeconfig.bin":
return false; // this file is present for .NET apps, but not legacy apps.
case "embedded.mobileprovision":
case "CodeResources":
return false; // sometimes we don't sign in .NET when we do in legacy (if there's an empty Entitlements.plist file)
}
var components = v.Split ('/');
Expand Down
Loading

5 comments on commit 105d3eb

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💻 [CI Build] Tests on macOS Mac Catalina (10.15) passed 💻

All tests on macOS Mac Catalina (10.15) passed.

Pipeline on Agent
Hash: 105d3ebf790b46087e13cda0c5a4b85340210fe4 [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ API diff for current PR / commit

Legacy Xamarin (No breaking changes)
  • iOS (no change detected)
  • tvOS (no change detected)
  • watchOS (no change detected)
  • macOS (no change detected)
NET (empty diffs)
  • iOS: (empty diff detected)
  • tvOS: (empty diff detected)
  • MacCatalyst: (empty diff detected)
  • macOS: (empty diff detected)

✅ API diff vs stable

Legacy Xamarin (No breaking changes)
.NET (No breaking changes)
Legacy Xamarin (stable) vs .NET

✅ Generator diff

Generator diff is empty

Pipeline on Agent
Hash: 105d3ebf790b46087e13cda0c5a4b85340210fe4 [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ [CI Build] Tests on macOS M1 - Mac Big Sur (11.5) failed ❌

Failed tests are:

  • monotouch-test

Pipeline on Agent
Hash: 105d3ebf790b46087e13cda0c5a4b85340210fe4 [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📚 [CI Build] Artifacts 📚

Packages generated

View packages

Pipeline on Agent XAMMINI-062.Monterey'
Hash: 105d3ebf790b46087e13cda0c5a4b85340210fe4 [CI build]

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 [CI Build] Test results 🔥

Test results

❌ Tests failed on VSTS: simulator tests

1 tests crashed, 14 tests failed, 213 tests passed.

Failures

❌ cecil tests

🔥 Failed catastrophically on VSTS: simulator tests - cecil (no summary found).

Html Report (VSDrops) Download

❌ introspection tests

1 tests failed, 12 tests passed.
  • introspection/watchOS 32-bits - simulator/Debug (watchOS 6.0): Crashed Known issue: HE0038)

Html Report (VSDrops) Download

❌ monotouch tests

12 tests failed, 11 tests passed.
  • monotouch-test/tvOS - simulator/Debug [dotnet]: Failed
  • monotouch-test/tvOS - simulator/Debug: Failed
  • monotouch-test/tvOS - simulator/Debug (LinkSdk) [dotnet]: Failed
  • monotouch-test/tvOS - simulator/Debug (static registrar) [dotnet]: Failed
  • monotouch-test/tvOS - simulator/Release (all optimizations) [dotnet]: Failed
  • monotouch-test/tvOS - simulator/Debug (LinkSdk): Failed
  • monotouch-test/tvOS - simulator/Debug (static registrar): Failed
  • monotouch-test/tvOS - simulator/Release (all optimizations): Failed
  • monotouch-test/watchOS 32-bits - simulator/Debug: TimedOut
  • monotouch-test/watchOS 32-bits - simulator/Debug (LinkSdk): TimedOut
  • monotouch-test/watchOS 32-bits - simulator/Debug (static registrar): TimedOut
  • monotouch-test/watchOS 32-bits - simulator/Release (all optimizations): TimedOut

Html Report (VSDrops) Download

❌ xtro tests

1 tests failed, 1 tests passed.
  • Xtro/Legacy Xamarin: Failed (Test run failed.)

Html Report (VSDrops) Download

Successes

✅ bcl: All 69 tests passed. Html Report (VSDrops) Download
✅ dotnettests: All 1 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 7 tests passed. Html Report (VSDrops) Download
✅ framework: All 8 tests passed. Html Report (VSDrops) Download
✅ generator: All 2 tests passed. Html Report (VSDrops) Download
✅ interdependent_binding_projects: All 7 tests passed. Html Report (VSDrops) Download
✅ install_source: All 1 tests passed. Html Report (VSDrops) Download
✅ linker: All 65 tests passed. Html Report (VSDrops) Download
✅ mac_binding_project: All 1 tests passed. Html Report (VSDrops) Download
✅ mmp: All 2 tests passed. Html Report (VSDrops) Download
✅ mononative: All 12 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ mtouch: All 1 tests passed. Html Report (VSDrops) Download
✅ xammac: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 8 tests passed. Html Report (VSDrops) Download

Pipeline on Agent
Hash: [CI build]

Please sign in to comment.