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

[CoreServices] Add support for Xcode 15. #18919

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
78 changes: 78 additions & 0 deletions src/CoreServices/LaunchServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,18 @@ public static class LaunchServices

#if NET
[SupportedOSPlatform ("macos")]
[ObsoletedOSPlatform ("macos14.0")]
#else
[Deprecated (PlatformName.MacOSX, 14, 0)]
#endif
[DllImport (Constants.CoreServicesLibrary)]
static extern IntPtr LSCopyDefaultApplicationURLForURL (IntPtr inUrl, LSRoles inRole, /*out*/ IntPtr outError);

#if NET
[SupportedOSPlatform ("macos")]
[ObsoletedOSPlatform ("macos14.0")]
#else
[Deprecated (PlatformName.MacOSX, 14, 0)]
#endif
public static NSUrl? GetDefaultApplicationUrlForUrl (NSUrl url, LSRoles roles = LSRoles.All)
{
Expand All @@ -114,12 +120,18 @@ public static class LaunchServices

#if NET
[SupportedOSPlatform ("macos")]
[ObsoletedOSPlatform ("macos14.0")]
#else
[Deprecated (PlatformName.MacOSX, 14, 0)]
#endif
[DllImport (Constants.CoreServicesLibrary)]
static extern IntPtr LSCopyDefaultApplicationURLForContentType (IntPtr inContentType, LSRoles inRole, /*out*/ IntPtr outError);

#if NET
[SupportedOSPlatform ("macos")]
[ObsoletedOSPlatform ("macos14.0")]
#else
[Deprecated (PlatformName.MacOSX, 14, 0)]
#endif
public static NSUrl? GetDefaultApplicationUrlForContentType (string contentType, LSRoles roles = LSRoles.All)
{
Expand All @@ -131,9 +143,21 @@ public static class LaunchServices
);
}

#if NET
[SupportedOSPlatform ("macos")]
[ObsoletedOSPlatform ("macos14.0")]
#else
[Deprecated (PlatformName.MacOSX, 14, 0)]
#endif
[DllImport (Constants.CoreServicesLibrary)]
static extern IntPtr LSCopyApplicationURLsForURL (IntPtr inUrl, LSRoles inRole);

#if NET
[SupportedOSPlatform ("macos")]
[ObsoletedOSPlatform ("macos14.0")]
#else
[Deprecated (PlatformName.MacOSX, 14, 0)]
#endif
public static NSUrl [] GetApplicationUrlsForUrl (NSUrl url, LSRoles roles = LSRoles.All)
{
if (url is null)
Expand Down Expand Up @@ -172,12 +196,18 @@ public static bool CanUrlAcceptUrl (NSUrl itemUrl, NSUrl targetUrl,

#if NET
[SupportedOSPlatform ("macos")]
[ObsoletedOSPlatform ("macos14.0")]
#else
[Deprecated (PlatformName.MacOSX, 14, 0)]
#endif
[DllImport (Constants.CoreServicesLibrary)]
static extern IntPtr LSCopyApplicationURLsForBundleIdentifier (IntPtr inBundleIdentifier, /*out*/ IntPtr outError);

#if NET
[SupportedOSPlatform ("macos")]
[ObsoletedOSPlatform ("macos14.0")]
#else
[Deprecated (PlatformName.MacOSX, 14, 0)]
#endif
public static NSUrl [] GetApplicationUrlsForBundleIdentifier (string bundleIdentifier)
{
Expand Down Expand Up @@ -234,9 +264,21 @@ public static LSResult Register (NSUrl url, bool update)

#region Working with Role Handlers

#if NET
[SupportedOSPlatform ("macos")]
[ObsoletedOSPlatform ("macos14.0")]
#else
[Deprecated (PlatformName.MacOSX, 14, 0)]
#endif
[DllImport (Constants.CoreServicesLibrary)]
static extern IntPtr LSCopyAllRoleHandlersForContentType (IntPtr inContentType, LSRoles inRole);

#if NET
[SupportedOSPlatform ("macos")]
[ObsoletedOSPlatform ("macos14.0")]
#else
[Deprecated (PlatformName.MacOSX, 14, 0)]
#endif
public static string?[]? GetAllRoleHandlersForContentType (string contentType, LSRoles roles = LSRoles.All)
{
if (contentType is null)
Expand All @@ -247,9 +289,21 @@ public static LSResult Register (NSUrl url, bool update)
);
}

#if NET
[SupportedOSPlatform ("macos")]
[ObsoletedOSPlatform ("macos14.0")]
#else
[Deprecated (PlatformName.MacOSX, 14, 0)]
#endif
[DllImport (Constants.CoreServicesLibrary)]
static extern IntPtr LSCopyDefaultRoleHandlerForContentType (IntPtr inContentType, LSRoles inRole);

#if NET
[SupportedOSPlatform ("macos")]
[ObsoletedOSPlatform ("macos14.0")]
#else
[Deprecated (PlatformName.MacOSX, 14, 0)]
#endif
public static string GetDefaultRoleHandlerForContentType (string contentType, LSRoles roles = LSRoles.All)
{
if (contentType is null)
Expand All @@ -260,10 +314,22 @@ public static string GetDefaultRoleHandlerForContentType (string contentType, LS
);
}

#if NET
[SupportedOSPlatform ("macos")]
[ObsoletedOSPlatform ("macos14.0")]
#else
[Deprecated (PlatformName.MacOSX, 14, 0)]
#endif
[DllImport (Constants.CoreServicesLibrary)]
static extern LSResult LSSetDefaultRoleHandlerForContentType (IntPtr inContentType,
LSRoles inRole, IntPtr inHandlerBundleID);

#if NET
[SupportedOSPlatform ("macos")]
[ObsoletedOSPlatform ("macos14.0")]
#else
[Deprecated (PlatformName.MacOSX, 14, 0)]
#endif
// NOTE: intentionally swapped handlerBundleId and roles parameters for a nicer API
public static LSResult SetDefaultRoleHandlerForContentType (string contentType, string handlerBundleId,
LSRoles roles = LSRoles.All)
Expand Down Expand Up @@ -330,9 +396,21 @@ public static string GetDefaultHandlerForUrlScheme (string urlScheme)
);
}

#if NET
[SupportedOSPlatform ("macos")]
[ObsoletedOSPlatform ("macos14.0")]
#else
[Deprecated (PlatformName.MacOSX, 14, 0)]
#endif
[DllImport (Constants.CoreServicesLibrary)]
static extern LSResult LSSetDefaultHandlerForURLScheme (IntPtr inUrlScheme, IntPtr inHandlerBundleId);

#if NET
[SupportedOSPlatform ("macos")]
[ObsoletedOSPlatform ("macos14.0")]
#else
[Deprecated (PlatformName.MacOSX, 14, 0)]
#endif
public static LSResult SetDefaultHandlerForUrlScheme (string urlScheme, string handlerBundleId)
{
if (urlScheme is null)
Expand Down

This file was deleted.

8 changes: 0 additions & 8 deletions tests/xtro-sharpie/macOS-CoreServices.todo

This file was deleted.