Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Foundation/Enum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -899,6 +899,8 @@ public enum NSUrlRequestNetworkServiceType : ulong {
Video,
Background,
Voice,
[Mac (10,14)][iOS (12,0)][Watch (5,0)][TV (12,0)]
ResponsiveData,
[Mac (10,12)][iOS (10,0)][Watch (3,0)][TV (10,0)]
CallSignaling = 11,
}
Expand Down
123 changes: 123 additions & 0 deletions src/foundation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2274,18 +2274,52 @@ interface NSKeyedUnarchiverDelegate {
[DisableDefaultCtor]
interface NSKeyedArchiver {

[Watch (4,0), TV (11,0), Mac (10,13), iOS (11,0)]
[Export ("initRequiringSecureCoding:")]
IntPtr Constructor (bool requiresSecureCoding);

// hack so we can decorate the default .ctor with availability attributes
[Deprecated (PlatformName.TvOS, 12, 0, message: "Use 'NSKeyedArchiver (bool)' instead.")]
[Deprecated (PlatformName.WatchOS, 5, 0, message: "Use 'NSKeyedArchiver (bool)' instead.")]
[Deprecated (PlatformName.iOS, 12, 0, message: "Use 'NSKeyedArchiver (bool)' instead.")]
[Deprecated (PlatformName.MacOSX, 10, 14, message: "Use 'NSKeyedArchiver (bool)' instead.")]
[iOS (10,0)][TV (10,0)][Watch (3,0)][Mac (10,12)]
[Export ("init")]
IntPtr Constructor ();

[Deprecated (PlatformName.TvOS, 12, 0, message: "Use 'NSKeyedArchiver (bool)' instead.")]
[Deprecated (PlatformName.WatchOS, 5, 0, message: "Use 'NSKeyedArchiver (bool)' instead.")]
[Deprecated (PlatformName.iOS, 12, 0, message: "Use 'NSKeyedArchiver (bool)' instead.")]
[Deprecated (PlatformName.MacOSX, 10, 14, message: "Use 'NSKeyedArchiver (bool)' instead.")]
[Export ("initForWritingWithMutableData:")]
IntPtr Constructor (NSMutableData data);

[Watch (4,0), TV (11,0), Mac (10,13), iOS (11,0)]
[Static]
[Export ("archivedDataWithRootObject:requiringSecureCoding:error:")]
[return: NullAllowed]
#if XAMCORE_4_0
NSData GetArchivedData (NSObject @object, bool requiresSecureCoding, [NullAllowed] out NSError error);
#else
NSData ArchivedDataWithRootObject (NSObject @object, bool requiresSecureCoding, [NullAllowed] out NSError error);
#endif

[Deprecated (PlatformName.TvOS, 12, 0, message: "Use 'ArchivedDataWithRootObject (NSObject, bool, out NSError)' instead.")]
[Deprecated (PlatformName.WatchOS, 5, 0, message: "Use 'ArchivedDataWithRootObject (NSObject, bool, out NSError)' instead.")]
[Deprecated (PlatformName.iOS, 12, 0, message: "Use 'ArchivedDataWithRootObject (NSObject, bool, out NSError)' instead.")]
[Deprecated (PlatformName.MacOSX, 10, 14, message: "Use 'ArchivedDataWithRootObject (NSObject, bool, out NSError)' instead.")]
[Export ("archivedDataWithRootObject:")]
[Static]
#if XAMCORE_4_0
NSData GetArchivedData (NSObject root);
#else
NSData ArchivedDataWithRootObject (NSObject root);
#endif

[Deprecated (PlatformName.TvOS, 12, 0, message: "Use 'ArchivedDataWithRootObject (NSObject, bool, out NSError)' instead.")]
[Deprecated (PlatformName.WatchOS, 5, 0, message: "Use 'ArchivedDataWithRootObject (NSObject, bool, out NSError)' instead.")]
[Deprecated (PlatformName.iOS, 12, 0, message: "Use 'ArchivedDataWithRootObject (NSObject, bool, out NSError)' instead.")]
[Deprecated (PlatformName.MacOSX, 10, 14, message: "Use 'ArchivedDataWithRootObject (NSObject, bool, out NSError)' instead.")]
[Export ("archiveRootObject:toFile:")]
[Static]
bool ArchiveRootObjectToFile (NSObject root, string file);
Expand Down Expand Up @@ -2332,20 +2366,64 @@ interface NSKeyedArchiver {
// Objective-C exception thrown. Name: NSInvalidArgumentException Reason: *** -[NSKeyedUnarchiver init]: cannot use -init for initialization
[DisableDefaultCtor]
interface NSKeyedUnarchiver {
[Watch (4,0), TV (11,0), Mac (10,13), iOS (11,0)]
[Export ("initForReadingFromData:error:")]
IntPtr Constructor (NSData data, [NullAllowed] out NSError error);

[Watch (4,0), TV (11,0), Mac (10,13), iOS (11,0)]
[Static]
[Export ("unarchivedObjectOfClass:fromData:error:")]
[return: NullAllowed]
NSObject GetUnarchivedObject (Class cls, NSData data, [NullAllowed] out NSError error);

[Watch (4,0), TV (11,0), Mac (10,13), iOS (11,0)]
[Static]
[Wrap ("GetUnarchivedObject (new Class (type), data, out error)")]
[return: NullAllowed]
NSObject GetUnarchivedObject (Type type, NSData data, [NullAllowed] out NSError error);

[Watch (4,0), TV (11,0), Mac (10,13), iOS (11,0)]
[Static]
[Export ("unarchivedObjectOfClasses:fromData:error:")]
[return: NullAllowed]
NSObject GetUnarchivedObject (NSSet<Class> classes, NSData data, [NullAllowed] out NSError error);

[Watch (4,0), TV (11,0), Mac (10,13), iOS (11,0)]
[Static]
[Wrap ("GetUnarchivedObject (new NSSet<Class> (Array.ConvertAll (types, t => new Class (t))), data, out error)")]
[return: NullAllowed]
NSObject GetUnarchivedObject (Type [] types, NSData data, [NullAllowed] out NSError error);

[Export ("initForReadingWithData:")]
[Deprecated (PlatformName.TvOS, 12, 0, message: "Use 'NSKeyedUnarchiver (NSData, out NSError)' instead.")]
[Deprecated (PlatformName.WatchOS, 5, 0, message: "Use 'NSKeyedUnarchiver (NSData, out NSError)' instead.")]
[Deprecated (PlatformName.iOS, 12, 0, message: "Use 'NSKeyedUnarchiver (NSData, out NSError)' instead.")]
[Deprecated (PlatformName.MacOSX, 10, 14, message: "Use 'NSKeyedUnarchiver (NSData, out NSError)' instead.")]
[MarshalNativeExceptions]
IntPtr Constructor (NSData data);

[Static, Export ("unarchiveObjectWithData:")]
[Deprecated (PlatformName.TvOS, 12, 0, message: "Use 'GetUnarchivedObject ()' instead.")]
[Deprecated (PlatformName.WatchOS, 5, 0, message: "Use 'GetUnarchivedObject ()' instead.")]
[Deprecated (PlatformName.iOS, 12, 0, message: "Use 'GetUnarchivedObject ()' instead.")]
[Deprecated (PlatformName.MacOSX, 10, 14, message: "Use 'GetUnarchivedObject ()' instead.")]
[MarshalNativeExceptions]
NSObject UnarchiveObject (NSData data);

[Deprecated (PlatformName.TvOS, 12, 0, message: "Use 'GetUnarchivedObject ()' instead.")]
[Deprecated (PlatformName.WatchOS, 5, 0, message: "Use 'GetUnarchivedObject ()' instead.")]
[Deprecated (PlatformName.iOS, 12, 0, message: "Use 'GetUnarchivedObject ()' instead.")]
[Deprecated (PlatformName.MacOSX, 10, 14, message: "Use 'GetUnarchivedObject ()' instead.")]
[Static, Export ("unarchiveTopLevelObjectWithData:error:")]
[iOS (9,0), Mac(10,11)]
// FIXME: [MarshalNativeExceptions]
NSObject UnarchiveTopLevelObject (NSData data, out NSError error);

[Static, Export ("unarchiveObjectWithFile:")]
[Deprecated (PlatformName.TvOS, 12, 0, message: "Use 'GetUnarchivedObject ()' instead.")]
[Deprecated (PlatformName.WatchOS, 5, 0, message: "Use 'GetUnarchivedObject ()' instead.")]
[Deprecated (PlatformName.iOS, 12, 0, message: "Use 'GetUnarchivedObject ()' instead.")]
[Deprecated (PlatformName.MacOSX, 10, 14, message: "Use 'GetUnarchivedObject ()' instead.")]
[MarshalNativeExceptions]
NSObject UnarchiveFile (string file);

Expand Down Expand Up @@ -5131,6 +5209,26 @@ partial interface NSUserActivity {
[Watch (5,0), NoTV, NoMac, iOS (12,0)]
[NullAllowed, Export ("suggestedInvocationPhrase")]
string SuggestedInvocationPhrase { get; set; }

[Watch (5, 0), NoTV, NoMac, iOS (12, 0)]
[Export ("eligibleForPrediction")]
bool EligibleForPrediction { [Bind ("isEligibleForPrediction")] get; set; }

[Watch (5, 0), NoTV, NoMac, iOS (12, 0)]
[NullAllowed, Export ("persistentIdentifier")]
string PersistentIdentifier { get; set; }

[Watch (5,0), NoTV, NoMac, iOS (12,0)]
[Static]
[Async]
[Export ("deleteSavedUserActivitiesWithPersistentIdentifiers:completionHandler:")]
void DeleteSavedUserActivities (string[] persistentIdentifiers, Action handler);

[Watch (5,0), NoTV, NoMac, iOS (12,0)]
[Static]
[Async]
[Export ("deleteAllSavedUserActivitiesWithCompletionHandler:")]
void DeleteAllSavedUserActivities (Action handler);
}

[iOS (8,0)][Mac (10,10, onlyOn64 : true)] // same as NSUserActivity
Expand Down Expand Up @@ -10619,12 +10717,37 @@ interface NSValueTransformer {
[Field ("NSIsNotNilTransformerName")]
NSString IsNotNilTransformerName { get; }

[Deprecated (PlatformName.TvOS, 12, 0, message: "Use 'SecureUnarchiveFromDataTransformerName' instead.")]
[Deprecated (PlatformName.WatchOS, 5, 0, message: "Use 'SecureUnarchiveFromDataTransformerName' instead.")]
[Deprecated (PlatformName.iOS, 12, 0, message: "Use 'SecureUnarchiveFromDataTransformerName' instead.")]
[Deprecated (PlatformName.MacOSX, 10, 14, message: "Use 'SecureUnarchiveFromDataTransformerName' instead.")]
[Field ("NSUnarchiveFromDataTransformerName")]
NSString UnarchiveFromDataTransformerName { get; }

[Deprecated (PlatformName.TvOS, 12, 0, message: "Use 'SecureUnarchiveFromDataTransformerName' instead.")]
[Deprecated (PlatformName.WatchOS, 5, 0, message: "Use 'SecureUnarchiveFromDataTransformerName' instead.")]
[Deprecated (PlatformName.iOS, 12, 0, message: "Use 'SecureUnarchiveFromDataTransformerName' instead.")]
[Deprecated (PlatformName.MacOSX, 10, 14, message: "Use 'SecureUnarchiveFromDataTransformerName' instead.")]
[Field ("NSKeyedUnarchiveFromDataTransformerName")]
NSString KeyedUnarchiveFromDataTransformerName { get; }

[Watch (5, 0), TV (12, 0), Mac (10, 14, onlyOn64: true), iOS (12, 0)]
[Field ("NSSecureUnarchiveFromDataTransformerName")]
NSString SecureUnarchiveFromDataTransformerName { get; }
}

// Class [] return value is currently broken - https://github.com/xamarin/xamarin-macios/issues/4441
// [Watch (5,0), TV (12,0), Mac (10,14, onlyOn64: true), iOS (12,0)]
// [BaseType (typeof(NSValueTransformer))]
// interface NSSecureUnarchiveFromDataTransformer {
// [Static]
// [Export ("allowedTopLevelClasses", ArgumentSemantic.Copy)]
// Class[] AllowedTopLevelClasses { get; }
//
// [Static]
// [Wrap ("Array.ConvertAll (AllowedTopLevelClasses, c => Class.Lookup (c))")]
// Type [] AllowedTopLevelTypes { get; }
// }

[BaseType (typeof (NSValue))]
// init returns NIL
Expand Down
52 changes: 52 additions & 0 deletions tests/monotouch-test/Foundation/NSKeyedUnarchiverTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using System;
using Foundation;
using NUnit.Framework;
using ObjCRuntime;

namespace MonoTouchFixtures.Foundation
{
[TestFixture]
[Preserve (AllMembers = true)]
public class NSKeyedUnarchiverTest
{
[Test]
public void GetUnarchivedObject_TypeWrappers ()
{
TestRuntime.AssertXcodeVersion (10, 0);

NSDictionary<NSString, NSString> testValues = new NSDictionary<NSString, NSString> ((NSString)"1", (NSString)"a");
NSData data = NSKeyedArchiver.ArchivedDataWithRootObject (testValues, true, out NSError error);
Assert.IsNull (error);

Type dictionaryType = typeof (NSDictionary<NSString, NSString>);
Class dictionaryClass = new Class (dictionaryType);
NSObject o = NSKeyedUnarchiver.GetUnarchivedObject (dictionaryClass, data, out error);
Assert.IsNotNull (o);
Assert.IsNull (error, "GetUnarchivedObject - Class");

o = NSKeyedUnarchiver.GetUnarchivedObject (new NSSet<Class> (new Class [] { dictionaryClass }), data, out error);
Assert.IsNotNull (o);
Assert.IsNull (error, "GetUnarchivedObject - NSSet<Class>");

o = NSKeyedUnarchiver.GetUnarchivedObject (dictionaryType, data, out error);
Assert.IsNotNull (o);
Assert.IsNull (error, "GetUnarchivedObject - Type");

o = NSKeyedUnarchiver.GetUnarchivedObject (new Type [] { dictionaryType }, data, out error);
Assert.IsNotNull (o);
Assert.IsNull (error, "GetUnarchivedObject - Type []");
}

// Class [] return value is currently broken - https://github.com/xamarin/xamarin-macios/issues/4441
//[Test]
//public void DataTransformer_AllowedTopLevelTypes_WrapperTests ()
//{
// TestRuntime.AssertXcodeVersion (10, 0);

// Class [] classes = NSSecureUnarchiveFromDataTransformer.AllowedTopLevelClasses;
// Type [] types = NSSecureUnarchiveFromDataTransformer.AllowedTopLevelTypes;

// Assert.AreEqual (classes.Length, types.Length, "Lengths not equal");
//}
}
}
4 changes: 4 additions & 0 deletions tests/xtro-sharpie/iOS-Foundation.ignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@

## does not exists in iOS as a type - but some API refers to it (messy)
!unknown-type! NSPortMessage bound

## Class [] return value is currently broken - https://github.com/xamarin/xamarin-macios/issues/4441
!missing-selector! +NSSecureUnarchiveFromDataTransformer::allowedTopLevelClasses not bound
!missing-type! NSSecureUnarchiveFromDataTransformer not bound
14 changes: 0 additions & 14 deletions tests/xtro-sharpie/iOS-Foundation.todo
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
!missing-field! NSOwnedPointerMapKeyCallBacks not bound
!missing-field! NSOwnedPointerMapValueCallBacks not bound
!missing-field! NSPointerToStructHashCallBacks not bound
!missing-field! NSSecureUnarchiveFromDataTransformerName not bound
!missing-pinvoke! NSAllHashTableObjects is not bound
!missing-pinvoke! NSAllMapTableKeys is not bound
!missing-pinvoke! NSAllMapTableValues is not bound
Expand Down Expand Up @@ -50,16 +49,3 @@
!missing-pinvoke! NSResetMapTable is not bound
!missing-pinvoke! NSStringFromHashTable is not bound
!missing-pinvoke! NSStringFromMapTable is not bound
!missing-selector! +NSKeyedArchiver::archivedDataWithRootObject:requiringSecureCoding:error: not bound
!missing-selector! +NSKeyedUnarchiver::unarchivedObjectOfClass:fromData:error: not bound
!missing-selector! +NSKeyedUnarchiver::unarchivedObjectOfClasses:fromData:error: not bound
!missing-selector! +NSSecureUnarchiveFromDataTransformer::allowedTopLevelClasses not bound
!missing-selector! +NSUserActivity::deleteAllSavedUserActivitiesWithCompletionHandler: not bound
!missing-selector! +NSUserActivity::deleteSavedUserActivitiesWithPersistentIdentifiers:completionHandler: not bound
!missing-selector! NSKeyedArchiver::initRequiringSecureCoding: not bound
!missing-selector! NSKeyedUnarchiver::initForReadingFromData:error: not bound
!missing-selector! NSUserActivity::isEligibleForPrediction not bound
!missing-selector! NSUserActivity::persistentIdentifier not bound
!missing-selector! NSUserActivity::setEligibleForPrediction: not bound
!missing-selector! NSUserActivity::setPersistentIdentifier: not bound
!missing-type! NSSecureUnarchiveFromDataTransformer not bound
3 changes: 3 additions & 0 deletions tests/xtro-sharpie/macOS-Foundation.ignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
## Only one type currently, which default returns. Currently unneeded unless they extend.
!missing-selector! +NSDistributedNotificationCenter::notificationCenterForType: not bound

## Class [] return value is currently broken - https://github.com/xamarin/xamarin-macios/issues/4441
!missing-selector! +NSSecureUnarchiveFromDataTransformer::allowedTopLevelClasses not bound
!missing-type! NSSecureUnarchiveFromDataTransformer not bound

## unsorted

Expand Down
8 changes: 0 additions & 8 deletions tests/xtro-sharpie/macOS-Foundation.todo

This file was deleted.

3 changes: 3 additions & 0 deletions tests/xtro-sharpie/tvOS-Foundation.ignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
## does not exists in iOS (or tvOS) as a type - but some API refers to it (messy)
!unknown-type! NSPortMessage bound

## Class [] return value is currently broken - https://github.com/xamarin/xamarin-macios/issues/4441
!missing-selector! +NSSecureUnarchiveFromDataTransformer::allowedTopLevelClasses not bound
!missing-type! NSSecureUnarchiveFromDataTransformer not bound

## unsorted

Expand Down
9 changes: 1 addition & 8 deletions tests/xtro-sharpie/tvOS-Foundation.todo
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
!missing-field! NSOwnedPointerMapKeyCallBacks not bound
!missing-field! NSOwnedPointerMapValueCallBacks not bound
!missing-field! NSPointerToStructHashCallBacks not bound
!missing-field! NSSecureUnarchiveFromDataTransformerName not bound
!missing-pinvoke! NSAllHashTableObjects is not bound
!missing-pinvoke! NSAllMapTableKeys is not bound
!missing-pinvoke! NSAllMapTableValues is not bound
Expand Down Expand Up @@ -50,10 +49,4 @@
!missing-pinvoke! NSResetMapTable is not bound
!missing-pinvoke! NSStringFromHashTable is not bound
!missing-pinvoke! NSStringFromMapTable is not bound
!missing-selector! +NSKeyedArchiver::archivedDataWithRootObject:requiringSecureCoding:error: not bound
!missing-selector! +NSKeyedUnarchiver::unarchivedObjectOfClass:fromData:error: not bound
!missing-selector! +NSKeyedUnarchiver::unarchivedObjectOfClasses:fromData:error: not bound
!missing-selector! +NSSecureUnarchiveFromDataTransformer::allowedTopLevelClasses not bound
!missing-selector! NSKeyedArchiver::initRequiringSecureCoding: not bound
!missing-selector! NSKeyedUnarchiver::initForReadingFromData:error: not bound
!missing-type! NSSecureUnarchiveFromDataTransformer not bound

4 changes: 4 additions & 0 deletions tests/xtro-sharpie/watchOS-Foundation.ignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@

## type was not marked as unavailable before Xcode9
!unknown-type! NSUbiquitousKeyValueStore bound

## Class [] return value is currently broken - https://github.com/xamarin/xamarin-macios/issues/4441
!missing-selector! +NSSecureUnarchiveFromDataTransformer::allowedTopLevelClasses not bound
!missing-type! NSSecureUnarchiveFromDataTransformer not bound
15 changes: 1 addition & 14 deletions tests/xtro-sharpie/watchOS-Foundation.todo
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
!missing-field! NSOwnedPointerMapKeyCallBacks not bound
!missing-field! NSOwnedPointerMapValueCallBacks not bound
!missing-field! NSPointerToStructHashCallBacks not bound
!missing-field! NSSecureUnarchiveFromDataTransformerName not bound
!missing-pinvoke! NSAllHashTableObjects is not bound
!missing-pinvoke! NSAllMapTableKeys is not bound
!missing-pinvoke! NSAllMapTableValues is not bound
Expand Down Expand Up @@ -50,16 +49,4 @@
!missing-pinvoke! NSResetMapTable is not bound
!missing-pinvoke! NSStringFromHashTable is not bound
!missing-pinvoke! NSStringFromMapTable is not bound
!missing-selector! +NSKeyedArchiver::archivedDataWithRootObject:requiringSecureCoding:error: not bound
!missing-selector! +NSKeyedUnarchiver::unarchivedObjectOfClass:fromData:error: not bound
!missing-selector! +NSKeyedUnarchiver::unarchivedObjectOfClasses:fromData:error: not bound
!missing-selector! +NSSecureUnarchiveFromDataTransformer::allowedTopLevelClasses not bound
!missing-selector! +NSUserActivity::deleteAllSavedUserActivitiesWithCompletionHandler: not bound
!missing-selector! +NSUserActivity::deleteSavedUserActivitiesWithPersistentIdentifiers:completionHandler: not bound
!missing-selector! NSKeyedArchiver::initRequiringSecureCoding: not bound
!missing-selector! NSKeyedUnarchiver::initForReadingFromData:error: not bound
!missing-selector! NSUserActivity::isEligibleForPrediction not bound
!missing-selector! NSUserActivity::persistentIdentifier not bound
!missing-selector! NSUserActivity::setEligibleForPrediction: not bound
!missing-selector! NSUserActivity::setPersistentIdentifier: not bound
!missing-type! NSSecureUnarchiveFromDataTransformer not bound