Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SharedWithYouCore] Added support for Xcode 14.1 b3 #16198

Merged
48 changes: 48 additions & 0 deletions src/SharedWithYouCore/SWCollaborationMetadata.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//
// Custom methods for SWCollaborationMetadata
//
// Authors:
// Israel Soto <issoto@microsoft.com>
//
// Copyright 2022 Microsoft Corporation.
//

#nullable enable

using System;
using CoreGraphics;
using CoreFoundation;

#if NET
[UnsupportedOSPlatform ("watchos")]
[UnsupportedOSPlatform ("tvos")]
[SupportedOSPlatform ("macos13.0")]
[SupportedOSPlatform ("ios16.0")]
[SupportedOSPlatform ("maccatalyst16.0")]
#else
[NoWatch, NoTV, Mac (13,0), iOS (16,0), MacCatalyst (16,0)]
#endif
namespace SharedWithYouCore {
public enum SWIdentifierType {
Local,
Collaboration,
}

public partial class SWCollaborationMetadata {
public SWCollaborationMetadata (string localIdentifier) : base (NSObjectFlag.Empty) =>
InitializeHandle (_InitWithLocalIdentifier (localIdentifier), "initWithLocalIdentifier:");

#if NET
[SupportedOSPlatform ("ios16.1")]
[SupportedOSPlatform ("maccatalyst16.1")]
SotoiGhost marked this conversation as resolved.
Show resolved Hide resolved
#else
[iOS (16,1), MacCatalyst (16,1)]
#endif
public SWCollaborationMetadata (string identifier, SWIdentifierType identifierType) : base (NSObjectFlag.Empty) => identifierType switch
{
SWIdentifierType.Local => InitializeHandle (_InitWithLocalIdentifier (identifier), "initWithLocalIdentifier:");
SWIdentifierType.Collaboration => InitializeHandle (_InitWithCollaborationIdentifier (identifier), "initWithCollaborationIdentifier:");
_ => ObjCRuntime.ThrowHelper.ThrowArgumentOutOfRangeException (nameof (identifierType), $"Unknown identifier type: {identifierType}");
}
}
}
8 changes: 7 additions & 1 deletion src/sharedwithyoucore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,14 @@ interface SWCollaborationMetadata : NSSecureCoding, NSCopying, NSMutableCopying
[NullAllowed, Export ("initiatorNameComponents", ArgumentSemantic.Strong)]
NSPersonNameComponents InitiatorNameComponents { get; set; }

[Internal]
[Export ("initWithLocalIdentifier:")]
NativeHandle Constructor (string localIdentifier);
NativeHandle _InitWithLocalIdentifier (string localIdentifier);

[iOS (16,1), MacCatalyst (16,1)]
[Internal]
[Export ("initWithCollaborationIdentifier:")]
NativeHandle _InitWithCollaborationIdentifier (string collaborationIdentifier);
}

[NoWatch, NoTV, Mac (13,0), iOS (16,0), MacCatalyst (16,0)]
Expand Down
3 changes: 3 additions & 0 deletions tests/introspection/ApiSelectorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1231,6 +1231,9 @@ protected virtual bool SkipInit (string selector, MethodBase m)
// NSAppleEventDescriptor
case "initListDescriptor":
case "initRecordDescriptor":
// SharedWithYouCore
case "initWithLocalIdentifier:":
case "initWithCollaborationIdentifier:":
return true;
default:
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//
// Unit tests for SWCollaborationMetadata
//
// Authors:
// Israel Soto <issoto@microsoft.com>
//
// Copyright 2022 Microsoft Corporation.
//

#if !__WATCHOS__ && !__TVOS__

using System;
using Foundation;
using ObjCRuntime;
using SharedWithYouCore;
using NUnit.Framework;
using Xamarin.Utils;

namespace MonoTouchFixtures.SharedWithYouCore {

[TestFixture]
[Preserve (AllMembers = true)]
public class SWCollaborationMetadataTests {

[OneTimeSetUp]
public void Init () => TestRuntime.AssertXcodeVersion (14, 0);

[Test]
public void LocalIdentifierConstructorTest ()
{
// SharedWithYouCore framework seems to work only for devices
TestRuntime.AssertNotSimulator ();

Assert.DoesNotThrow (() => { _ = new SWCollaborationMetadata (Guid.NewGuid ().ToString ()); },
"_InitWithLocalIdentifier");
}

[TestCase (SWIdentifierType.Local, "_InitWithLocalIdentifier")]
[TestCase (SWIdentifierType.Collaboration, "_InitWithCollaborationIdentifier")]
public void IdentifierTypeConstructorTest (SWIdentifierType identifierType, string methodName)
{
// SharedWithYouCore framework seems to work only for devices
TestRuntime.AssertNotSimulator ();

Assert.DoesNotThrow (() => { _ = new SWCollaborationMetadata (Guid.NewGuid ().ToString (), identifierType); },
methodName);
}
}
}

#endif // !__WATCHOS__ && !__TVOS__
1 change: 1 addition & 0 deletions tests/monotouch-test/monotouch-test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@
<Folder Include="WebKit\" />
<Folder Include="NearbyInteraction\" />
<Folder Include="MetricKit\" />
<Folder Include="SharedWithYouCore\" />
</ItemGroup>
<ItemGroup>
<Content Include="AudioToolbox\1.caf" />
Expand Down