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

[CoreSpotlight] Add support for Xcode 14 beta 1,2 & 3 #15532

Merged
merged 4 commits into from
Jul 19, 2022
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
134 changes: 134 additions & 0 deletions src/corespotlight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ interface CSSearchableIndex {
[Export ("deleteAllSearchableItemsWithCompletionHandler:")]
[Async]
void DeleteAll ([NullAllowed] Action<NSError> completionHandler);

// from interface CSExternalProvider (CSSearchableIndex)

[Async (ResultTypeName="CSSearchableIndexBundleDataResult")]
[NoTV, iOS (16,0), Mac (13,0), MacCatalyst (16,0)]
[Export ("provideDataForBundle:identifier:type:completionHandler:")]
void ProvideData (string bundle, string identifier, string type, Action<NSData, NSError> completionHandler);
}

delegate void CSSearchableIndexFetchHandler (NSData clientState, NSError error);
Expand Down Expand Up @@ -1074,6 +1081,11 @@ interface CSSearchQuery {
[Export ("initWithQueryString:attributes:")]
NativeHandle Constructor (string queryString, [NullAllowed] string[] attributes);

[Mac (13,0), iOS (16,0), MacCatalyst (16,0)]
[Export ("initWithQueryString:queryContext:")]
[DesignatedInitializer]
NativeHandle Constructor (string queryString, CSSearchQueryContext queryContext);

[Export ("cancelled")]
bool Cancelled { [Bind ("isCancelled")] get; }

Expand Down Expand Up @@ -1105,4 +1117,126 @@ interface CSImportExtension : NSExtensionRequestHandling
bool Update (CSSearchableItemAttributeSet attributes, NSUrl contentUrl, [NullAllowed] out NSError error);
}

[NoTV, Mac (13,0), iOS (16,0), MacCatalyst (16,0)]
[BaseType (typeof (CSSearchQuery))]
[DisableDefaultCtor]
interface CSUserQuery
{
[Export ("initWithUserQueryString:queryContext:")]
[DesignatedInitializer]
NativeHandle Constructor ([NullAllowed] string userQueryString, CSUserQueryContext queryContext);

[Export ("foundSuggestionCount")]
nint FoundSuggestionCount { get; }

[NullAllowed, Export ("foundSuggestionsHandler", ArgumentSemantic.Copy)]
Action<NSArray<CSSuggestion>> FoundSuggestionsHandler { get; set; }

[Export ("start")]
void Start ();

[Export ("cancel")]
void Cancel ();
}

[NoTV, Mac (13,0), iOS (16,0), MacCatalyst (16,0)]
[BaseType (typeof (CSSearchQueryContext))]
[DisableDefaultCtor]
interface CSUserQueryContext
mandel-macaque marked this conversation as resolved.
Show resolved Hide resolved
{
[Static]
[Export ("userQueryContext")]
CSUserQueryContext UserQueryContext { get; }

[Static]
[Export ("userQueryContextWithCurrentSuggestion:")]
CSUserQueryContext Create ([NullAllowed] CSSuggestion currentSuggestion);

[Export ("maxSuggestionCount")]
nint MaxSuggestionCount { get; set; }
}

[NoTV, Mac (13,0), iOS (16,0), MacCatalyst (16,0)]
[BaseType (typeof (CSUserQueryContext))]
[DisableDefaultCtor]
interface CSTopHitQueryContext
mandel-macaque marked this conversation as resolved.
Show resolved Hide resolved
{
[Static]
[Export ("topHitQueryContext")]
CSTopHitQueryContext TopHitQueryContext { get; }

[Static]
[Export ("topHitQueryContextWithCurrentSuggestion:")]
CSTopHitQueryContext Create ([NullAllowed] CSSuggestion currentSuggestion);

[Export ("maxItemCount")]
nint MaxItemCount { get; set; }
}

[NoTV, Mac (13,0), iOS (16,0), MacCatalyst (16,0)]
[BaseType (typeof (CSUserQuery))]
[DisableDefaultCtor]
interface CSTopHitQuery
{
[Export ("initWithUserQueryString:queryContext:")]
[DesignatedInitializer]
NativeHandle Constructor ([NullAllowed] string userQueryString, CSTopHitQueryContext queryContext);
}

[NoTV, Mac (13,0), iOS (16,0), MacCatalyst (16,0)]
[BaseType (typeof (NSObject))]
[DisableDefaultCtor]
interface CSSuggestion : NSSecureCoding, NSCopying
mandel-macaque marked this conversation as resolved.
Show resolved Hide resolved
{

[Field ("CSSuggestionHighlightAttributeName")]
NSString HighlightAttributeName { get; }

[Export ("localizedAttributedSuggestion")]
NSAttributedString LocalizedAttributedSuggestion { get; }

[Export ("suggestionKind")]
CSSuggestionKind SuggestionKind { get; }

[Export ("compare:")]
NSComparisonResult Compare (CSSuggestion other);
}

[NoTV, Mac (13,0), iOS (16,0), MacCatalyst (16,0)]
[BaseType (typeof (NSObject))]
interface CSSearchQueryContext : NSSecureCoding, NSCopying
{
[NullAllowed, Export ("fetchAttributes", ArgumentSemantic.Strong)]
string[] FetchAttributes { get; set; }

[NullAllowed, Export ("protectionClasses", ArgumentSemantic.Strong)]
string[] ProtectionClasses { get; set; }

[NullAllowed, Export ("filterQueries", ArgumentSemantic.Copy)]
string[] FilterQueries { get; set; }

[NullAllowed, Export ("keyboardLanguage", ArgumentSemantic.Strong)]
string KeyboardLanguage { get; set; }

[Export ("sourceOptions", ArgumentSemantic.Assign)]
CSSearchQuerySourceOptions SourceOptions { get; set; }
}

[NoTV, Mac (13,0), iOS (16,0), MacCatalyst (16,0)]
[Native]
public enum CSSearchQuerySourceOptions : long
{
Default = 0,
AllowMail = 1L << 0,
}

[NoTV, Mac (10,13), iOS (16,0), MacCatalyst (16,0)]
[Native]
public enum CSSuggestionKind : long
{
None,
Custom,
Default,
}
Comment on lines +1225 to +1240
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Not a fan of having these at the bottom of the file, we usually put them at the top but I won't die on a hill for this.

Copy link
Member Author

Choose a reason for hiding this comment

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

There are no enums in this file but this ones ;) I can move them, I'm not to bordered to be honest.


}
39 changes: 0 additions & 39 deletions tests/xtro-sharpie/api-annotations-dotnet/iOS-CoreSpotlight.todo

This file was deleted.

39 changes: 0 additions & 39 deletions tests/xtro-sharpie/api-annotations-dotnet/macOS-CoreSpotlight.todo

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# framework is not present on tvOS as of xcode 14.0
!missing-enum! CSSuggestionKind not bound

This file was deleted.

39 changes: 0 additions & 39 deletions tests/xtro-sharpie/iOS-CoreSpotlight.todo

This file was deleted.

39 changes: 0 additions & 39 deletions tests/xtro-sharpie/macOS-CoreSpotlight.todo

This file was deleted.

2 changes: 2 additions & 0 deletions tests/xtro-sharpie/tvOS-CoreSpotlight.ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# framework is not present on tvOS as of xcode 14.0
!missing-enum! CSSuggestionKind not bound
1 change: 0 additions & 1 deletion tests/xtro-sharpie/tvOS-CoreSpotlight.todo

This file was deleted.