From 72c9e22da5987a295e62b1e1dddc226686c918f3 Mon Sep 17 00:00:00 2001 From: Manuel de la Pena Date: Thu, 29 Jul 2021 18:18:58 -0400 Subject: [PATCH 1/4] [FileProvider] Add support for Xcode13 beta 4. --- src/FileProvider/Structs.cs | 18 ++++++++ src/fileprovider.cs | 54 +++++++++++++++++++--- src/frameworks.sources | 3 ++ tests/xtro-sharpie/iOS-FileProvider.todo | 6 --- tests/xtro-sharpie/macOS-FileProvider.todo | 7 --- 5 files changed, 68 insertions(+), 20 deletions(-) create mode 100644 src/FileProvider/Structs.cs delete mode 100644 tests/xtro-sharpie/iOS-FileProvider.todo delete mode 100644 tests/xtro-sharpie/macOS-FileProvider.todo diff --git a/src/FileProvider/Structs.cs b/src/FileProvider/Structs.cs new file mode 100644 index 000000000000..8da96060581d --- /dev/null +++ b/src/FileProvider/Structs.cs @@ -0,0 +1,18 @@ +#if MONOMAC +using System; +using System.Runtime.InteropServices; +using ObjCRuntime; + +namespace FileProvider { + + [NoiOS, NoMacCatalyst, Mac (12,0)] + [StructLayout (LayoutKind.Sequential)] + public struct NSFileProviderTypeAndCreator + { + public uint Type; + + public uint Creator; + } + +} +#endif diff --git a/src/fileprovider.cs b/src/fileprovider.cs index d63d69cf3dce..73ae57433289 100644 --- a/src/fileprovider.cs +++ b/src/fileprovider.cs @@ -182,11 +182,18 @@ enum NSFileProviderError : long { OlderExtensionVersionRunning = -2003, NewerExtensionVersionFound = -2004, CannotSynchronize = -2005, -#if MONOMAC NonEvictableChildren = -2006, UnsyncedEdits = -2007, NonEvictable = -2008, -#endif + } + + [Unavailable (PlatformName.MacCatalyst)] + [NoiOS, Mac (12,0), NoMacCatalyst] + [Native, Advice ("This API is not available when using UIKit on macOS.")] + public enum NSFileProviderDomainRemovalMode : long { + RemoveAll = 0, + PreserveDirtyUserData = 1, + PreserveDownloadedUserData = 2, } [iOS (11,0)] @@ -203,7 +210,7 @@ interface NSFileProviderErrorKeys { [Field ("NSFileProviderErrorNonExistentItemIdentifierKey")] NSString NonExistentItemIdentifierKey { get; } - [NoiOS] + [iOS (15,0)] [Field ("NSFileProviderErrorItemKey")] NSString ItemKey { get; } } @@ -330,6 +337,11 @@ interface NSFileProviderDomain { [Notification] [Field ("NSFileProviderDomainDidChange")] NSString DidChange { get; } + + [NoWatch, NoTV, NoiOS, Mac (12, 0), NoMacCatalyst] + [Advice ("This API is not available when using UIKit on macOS.")] + [NullAllowed, Export ("backingStoreIdentity")] + NSData BackingStoreIdentity { get; } } interface INSFileProviderEnumerationObserver { } @@ -542,6 +554,13 @@ interface NSFileProviderItem { [NoiOS] [NullAllowed, Export ("symlinkTargetPath")] string SymlinkTargetPath { get; } + +#if MONOMAC + [NoiOS, Mac (12, 0), NoMacCatalyst] + [Advice ("This API is not available when using UIKit on macOS.")] + [Export ("typeAndCreator")] + NSFileProviderTypeAndCreator TypeAndCreator { get; } +#endif } [iOS (11,0)] @@ -716,6 +735,12 @@ interface NSFileProviderManager { [return: NullAllowed] NSDictionary GetRunTestingOperations (INSFileProviderTestingOperation[] operations, [NullAllowed] out NSError error); + [NoiOS, Mac (12,0), NoMacCatalyst] + [Async (ResultTypeName = "NSFileProviderRemoveDomainResult")] + [Static] + [Export ("removeDomain:mode:completionHandler:")] + void RemoveDomain (NSFileProviderDomain domain, NSFileProviderDomainRemovalMode mode, Action completionHandler); + } interface INSFileProviderPendingSetEnumerator { } @@ -815,6 +840,8 @@ enum NSFileProviderItemFields : ulong { ContentModificationDate = 1uL << 7, FileSystemFlags = 1uL << 8, ExtendedAttributes = 1uL << 9, + [Mac (12,0) + TypeAndCreator = 1uL << 10, } [Mac (11,0)] @@ -826,9 +853,8 @@ enum NSFileProviderManagerDisconnectionOptions : ulong { Temporary = 1, } - [Mac (11,0)] + [iOS (15,0), Mac (11,0)] [Unavailable (PlatformName.MacCatalyst)][Advice ("This API is not available when using Catalyst on macOS.")] - [NoiOS] [Native][Flags] enum NSFileProviderFileSystemFlags : ulong { @@ -1003,8 +1029,7 @@ interface NSFileProviderDomainState { } [Advice ("This API is not available when using UIKit on macOS.")] - [Unavailable (PlatformName.MacCatalyst)] - [NoWatch, NoTV, NoiOS, Mac (11,3)] + [NoWatch, NoTV, iOS (15,0), Mac (12,0), NoMacCatalyst] [Flags] [Native] public enum NSFileProviderDomainTestingModes : ulong { @@ -1263,4 +1288,19 @@ interface NSFileProviderTestingCollisionResolution : NSFileProviderTestingOperat [Export ("renamedItem")] INSFileProviderItem RenamedItem { get; } } + + [NoWatch, NoTV, NoiOS, Mac (12,0), NoMacCatalyst] + [Protocol, Advice ("This API is not available when using UIKit on macOS.")] + [BaseType (typeof (NSObject))] + interface NSFileProviderUserInteractionSuppressing + { + [Abstract] + [Export ("setInteractionSuppressed:forIdentifier:")] + void SetInteractionSuppressed (bool suppression, string suppressionIdentifier); + + [Abstract] + [Export ("isInteractionSuppressedForIdentifier:")] + bool IsInteractionSuppressed (string suppressionIdentifier); + } + } diff --git a/src/frameworks.sources b/src/frameworks.sources index 1075fe315604..483a47f65f04 100644 --- a/src/frameworks.sources +++ b/src/frameworks.sources @@ -716,6 +716,9 @@ EXTERNALACCESSORY_API_SOURCES = \ # FileProvider +FILEPROVIDER_CORE_SOURCES = \ + FileProvider/Structs.cs \ + FILEPROVIDER_SOURCES = \ FileProvider/Compat.cs \ diff --git a/tests/xtro-sharpie/iOS-FileProvider.todo b/tests/xtro-sharpie/iOS-FileProvider.todo deleted file mode 100644 index 7c8c2c5d1fb7..000000000000 --- a/tests/xtro-sharpie/iOS-FileProvider.todo +++ /dev/null @@ -1,6 +0,0 @@ -!missing-enum! NSFileProviderDomainTestingModes not bound -!missing-enum! NSFileProviderFileSystemFlags not bound -!missing-enum-value! NSFileProviderError native value NSFileProviderErrorNonEvictable = -2008 not bound -!missing-enum-value! NSFileProviderError native value NSFileProviderErrorNonEvictableChildren = -2006 not bound -!missing-enum-value! NSFileProviderError native value NSFileProviderErrorUnsyncedEdits = -2007 not bound -!missing-field! NSFileProviderErrorItemKey not bound diff --git a/tests/xtro-sharpie/macOS-FileProvider.todo b/tests/xtro-sharpie/macOS-FileProvider.todo deleted file mode 100644 index bc1aa0bb4d48..000000000000 --- a/tests/xtro-sharpie/macOS-FileProvider.todo +++ /dev/null @@ -1,7 +0,0 @@ -## appended from unclassified file -!missing-enum! NSFileProviderDomainRemovalMode not bound -!missing-enum-value! NSFileProviderItemFields native value NSFileProviderItemTypeAndCreator = 1024 not bound -!missing-protocol! NSFileProviderUserInteractionSuppressing not bound -!missing-protocol-member! NSFileProviderItem::typeAndCreator not found -!missing-selector! +NSFileProviderManager::removeDomain:mode:completionHandler: not bound -!missing-selector! NSFileProviderDomain::backingStoreIdentity not bound From 611a5f35a56c03333d15fa9e65971b9b908a8177 Mon Sep 17 00:00:00 2001 From: Manuel de la Pena Date: Thu, 29 Jul 2021 15:52:41 -0700 Subject: [PATCH 2/4] Fix compilation. --- src/fileprovider.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fileprovider.cs b/src/fileprovider.cs index 73ae57433289..8cb4b1f28ad3 100644 --- a/src/fileprovider.cs +++ b/src/fileprovider.cs @@ -840,7 +840,7 @@ enum NSFileProviderItemFields : ulong { ContentModificationDate = 1uL << 7, FileSystemFlags = 1uL << 8, ExtendedAttributes = 1uL << 9, - [Mac (12,0) + [Mac (12,0)] TypeAndCreator = 1uL << 10, } From 44602ff457e52a3f6aa5a868d56ac81f9c5058f6 Mon Sep 17 00:00:00 2001 From: Manuel de la Pena Date: Fri, 30 Jul 2021 09:26:25 -0400 Subject: [PATCH 3/4] Apply suggestions from code review Co-authored-by: Rolf Bjarne Kvinge --- src/fileprovider.cs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/fileprovider.cs b/src/fileprovider.cs index 8cb4b1f28ad3..b480190c484a 100644 --- a/src/fileprovider.cs +++ b/src/fileprovider.cs @@ -187,9 +187,8 @@ enum NSFileProviderError : long { NonEvictable = -2008, } - [Unavailable (PlatformName.MacCatalyst)] [NoiOS, Mac (12,0), NoMacCatalyst] - [Native, Advice ("This API is not available when using UIKit on macOS.")] + [Native] public enum NSFileProviderDomainRemovalMode : long { RemoveAll = 0, PreserveDirtyUserData = 1, @@ -339,7 +338,6 @@ interface NSFileProviderDomain { NSString DidChange { get; } [NoWatch, NoTV, NoiOS, Mac (12, 0), NoMacCatalyst] - [Advice ("This API is not available when using UIKit on macOS.")] [NullAllowed, Export ("backingStoreIdentity")] NSData BackingStoreIdentity { get; } } @@ -557,7 +555,6 @@ interface NSFileProviderItem { #if MONOMAC [NoiOS, Mac (12, 0), NoMacCatalyst] - [Advice ("This API is not available when using UIKit on macOS.")] [Export ("typeAndCreator")] NSFileProviderTypeAndCreator TypeAndCreator { get; } #endif @@ -1028,7 +1025,6 @@ interface NSFileProviderDomainState { NSDictionary UserInfo { get; } } - [Advice ("This API is not available when using UIKit on macOS.")] [NoWatch, NoTV, iOS (15,0), Mac (12,0), NoMacCatalyst] [Flags] [Native] @@ -1290,8 +1286,7 @@ interface NSFileProviderTestingCollisionResolution : NSFileProviderTestingOperat } [NoWatch, NoTV, NoiOS, Mac (12,0), NoMacCatalyst] - [Protocol, Advice ("This API is not available when using UIKit on macOS.")] - [BaseType (typeof (NSObject))] + [Protocol] interface NSFileProviderUserInteractionSuppressing { [Abstract] From accf389a810c8f58c517ba9f36fc5b63d19c84cb Mon Sep 17 00:00:00 2001 From: Manuel de la Pena Date: Fri, 30 Jul 2021 12:54:02 -0400 Subject: [PATCH 4/4] Address reviews. --- src/FileProvider/Structs.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/FileProvider/Structs.cs b/src/FileProvider/Structs.cs index 8da96060581d..8dd8ec9c3a56 100644 --- a/src/FileProvider/Structs.cs +++ b/src/FileProvider/Structs.cs @@ -10,8 +10,15 @@ namespace FileProvider { public struct NSFileProviderTypeAndCreator { public uint Type; - public uint Creator; + +#if !COREBUILD + public string GetTypeAsFourCC () + => Runtime.ToFourCCString (Type); + + public string GetCreatorAsFourCC() + => Runtime.ToFourCCString (Creator); +#endif } }