Free, open-source file converter. Convert 263 formats offline by drag & drop — images, PDF, Word, Excel, PowerPoint, HWP/HWPX, video, audio, e-books and archives. No upload, no Office needed.
C# audio-converteravaloniabatch-conversionconvertercsharpdocument-converterdocx-to-pdfdotnetdrag-and-dropfile-conversionfile-converterheic-converterhwphwpximage-converterlinuxmacospdf-convertervideo-converterwindows
macOS: Filee answers "Convert with Filee" in Finder's right-click menu itself
KnifeLemon4704fe066817
diff --git a/build/build-portable.ps1 b/build/build-portable.ps1index b56f639a..3aa2c007 100644--- a/build/build-portable.ps1+++ b/build/build-portable.ps1@@ -84,6 +84,10 @@ if ($Runtime.StartsWith('osx-')) {}}Invoke-Checked 'Create app icon' { iconutil -c icns $iconset -o (Join-Path $resources 'filee.icns') }+ # Translations of the service title ("Convert with Filee") in Finder's right-click menu.+ foreach ($localization in Get-ChildItem -LiteralPath (Join-Path $root 'installer/macos') -Directory -Filter '*.lproj') {+ Copy-Item -LiteralPath $localization.FullName -Destination $resources -Recurse+ }$entitlements = Join-Path $root 'installer/macos/entitlements.plist'$signOptions = @('--force', '--sign', $SigningIdentity)if ($SigningIdentity -ne '-') { $signOptions += @('--timestamp', '--options', 'runtime') }diff --git a/installer/macos/Info.plist b/installer/macos/Info.plistindex 6b069a3f..9b8e46e8 100644--- a/installer/macos/Info.plist+++ b/installer/macos/Info.plist@@ -14,6 +14,19 @@<key>CFBundleIconFile</key><string>filee.icns</string><key>LSMinimumSystemVersion</key><string>14.0</string><key>NSHighResolutionCapable</key><true/>+ <!-- "Convert with Filee" in Finder's right-click menu, answered by the running Filee (MacOSServicesProvider).+ ServicesMenu.strings in ko.lproj and zh-Hans.lproj translate the title. An empty NSRequiredContext keeps+ the service on by default. -->+ <key>NSServices</key>+ <array>+ <dict>+ <key>NSMenuItem</key><dict><key>default</key><string>Convert with Filee</string></dict>+ <key>NSMessage</key><string>convertFiles</string>+ <key>NSPortName</key><string>Filee</string>+ <key>NSRequiredContext</key><dict/>+ <key>NSSendFileTypes</key><array><string>public.item</string></array>+ </dict>+ </array><key>NSAppleEventsUsageDescription</key><string>Filee reads selected Finder files when you use a conversion shortcut.</string><key>NSInputMonitoringUsageDescription</key><string>Filee detects your conversion shortcut and drag gesture to show the conversion menu.</string></dict>diff --git a/installer/macos/en.lproj/ServicesMenu.strings b/installer/macos/en.lproj/ServicesMenu.stringsnew file mode 100644index 00000000..57716f5c--- /dev/null+++ b/installer/macos/en.lproj/ServicesMenu.strings@@ -0,0 +1,2 @@+/* Finder's right-click menu: the title of Filee's service (NSServices in Info.plist). */+"Convert with Filee" = "Convert with Filee";diff --git a/installer/macos/ko.lproj/ServicesMenu.strings b/installer/macos/ko.lproj/ServicesMenu.stringsnew file mode 100644index 00000000..8d955412--- /dev/null+++ b/installer/macos/ko.lproj/ServicesMenu.strings@@ -0,0 +1,2 @@+/* Finder's right-click menu: the title of Filee's service (NSServices in Info.plist). */+"Convert with Filee" = "Filee로 변환";diff --git a/installer/macos/zh-Hans.lproj/ServicesMenu.strings b/installer/macos/zh-Hans.lproj/ServicesMenu.stringsnew file mode 100644index 00000000..e4e712f2--- /dev/null+++ b/installer/macos/zh-Hans.lproj/ServicesMenu.strings@@ -0,0 +1,2 @@+/* Finder's right-click menu: the title of Filee's service (NSServices in Info.plist). */+"Convert with Filee" = "用 Filee 转换";diff --git a/src/Filee.App/App.axaml.cs b/src/Filee.App/App.axaml.csindex f420dded..1d06c2c3 100644--- a/src/Filee.App/App.axaml.cs+++ b/src/Filee.App/App.axaml.cs@@ -36,6 +36,11 @@ public partial class App : Applicationprivate void Start(IClassicDesktopStyleApplicationLifetime desktop){+ // macOS: "Convert with Filee" in Finder's right-click menu. Registered first, so a service picked while+ // Filee wasn't running is delivered as soon as it starts.+ if (OperatingSystem.IsMacOS())+ Filee.Platform.MacOS.MacOSServicesProvider.Register(files =>+ Dispatcher.UIThread.Post(() => HandleCommandLine(CommandLine.Parse(["--convert", .. files]))));var log = AppHost.Get<ILogger<App>>();var store = AppHost.Get<UserDataStore>();store.Load();diff --git a/src/Filee.App/Assets/i18n/en.json b/src/Filee.App/Assets/i18n/en.jsonindex cb93018f..a6eed637 100644--- a/src/Filee.App/Assets/i18n/en.json+++ b/src/Filee.App/Assets/i18n/en.json@@ -128,9 +128,9 @@"general.start_with_system": "Start Filee when I sign in","general.context_menu": "Show “Convert with Filee” in the Explorer context menu","general.context_menu_label": "Convert with Filee",- "general.context_menu_macos": "Add “Convert with Filee” to Finder Quick Actions",+ "general.context_menu_macos": "Show “Convert with Filee” when you right-click files in Finder","general.context_menu_linux": "Add “Convert with Filee” to the file manager",- "general.integration_macos": "Finder shows the action under Quick Actions or Services. Enable it in System Settings > Keyboard > Keyboard Shortcuts > Services if it is hidden.",+ "general.integration_macos": "Finder shows it in the right-click menu (under Quick Actions or Services when the menu is long). Keep Filee in Applications.","general.integration_linux": "File actions are installed for Thunar, Nautilus, Nemo and Dolphin. Close Thunar before changing or pausing its shortcut, then reopen it to load the change.","general.integration_failed": "Could not apply system integration: {0}","general.modern_menu_hint": "On Windows 11 this entry is under “Show more options”. Filee can also add it to the main menu; Windows asks for administrator permission once.",diff --git a/src/Filee.App/Assets/i18n/ko.json b/src/Filee.App/Assets/i18n/ko.jsonindex fdd406f9..9ede875e 100644--- a/src/Filee.App/Assets/i18n/ko.json+++ b/src/Filee.App/Assets/i18n/ko.json@@ -128,9 +128,9 @@"general.start_with_system": "로그인할 때 Filee 시작","general.context_menu": "탐색기 우클릭 메뉴에 “Filee로 변환” 표시","general.context_menu_label": "Filee로 변환",- "general.context_menu_macos": "Finder 빠른 동작에 “Filee로 변환” 추가",+ "general.context_menu_macos": "Finder에서 파일을 우클릭하면 “Filee로 변환” 표시","general.context_menu_linux": "파일 관리자 메뉴에 “Filee로 변환” 추가",- "general.integration_macos": "Finder의 빠른 동작 또는 서비스에서 사용할 수 있어요. 보이지 않으면 시스템 설정 > 키보드 > 키보드 단축키 > 서비스에서 켜 주세요.",+ "general.integration_macos": "Finder 우클릭 메뉴에 나타나요(메뉴가 길면 빠른 동작 또는 서비스 안에). Filee는 응용 프로그램 폴더에 두세요.","general.integration_linux": "Thunar, Nautilus, Nemo, Dolphin에 파일 동작을 추가해요. Thunar 단축키를 변경하거나 일시정지할 때는 Thunar를 닫은 상태에서 적용한 뒤 다시 열어 주세요.","general.integration_failed": "시스템 연동을 적용하지 못했어요: {0}","general.modern_menu_hint": "Windows 11에서는 이 항목이 “추가 옵션 표시” 안에 있어요. 기본 메뉴에도 추가할 수 있고, 이때 Windows가 관리자 권한을 한 번 요청해요.",diff --git a/src/Filee.App/Assets/i18n/zh-CN.json b/src/Filee.App/Assets/i18n/zh-CN.jsonindex 73229bb1..8172a879 100644--- a/src/Filee.App/Assets/i18n/zh-CN.json+++ b/src/Filee.App/Assets/i18n/zh-CN.json@@ -128,9 +128,9 @@"general.start_with_system": "登录时启动 Filee","general.context_menu": "在资源管理器右键菜单中显示“用 Filee 转换”","general.context_menu_label": "用 Filee 转换",- "general.context_menu_macos": "在 Finder 快速操作中添加“用 Filee 转换”",+ "general.context_menu_macos": "在 Finder 中右键点按文件时显示“用 Filee 转换”","general.context_menu_linux": "在文件管理器菜单中添加“用 Filee 转换”",- "general.integration_macos": "可在 Finder 的快速操作或服务中找到此操作。若未显示,请在系统设置 > 键盘 > 键盘快捷键 > 服务中启用。",+ "general.integration_macos": "Finder 的右键菜单中会出现此项(菜单较长时在“快速操作”或“服务”中)。请将 Filee 保留在“应用程序”文件夹中。","general.integration_linux": "为 Thunar、Nautilus、Nemo 和 Dolphin 安装文件操作。修改或暂停 Thunar 快捷键前请关闭 Thunar,然后重新打开以加载更改。","general.integration_failed": "无法应用系统集成:{0}","general.modern_menu_hint": "在 Windows 11 中,此项位于“显示更多选项”里。Filee 也可以把它添加到主菜单,Windows 会请求一次管理员权限。",diff --git a/src/Filee.Platform.MacOS/MacOSIntegrationFiles.cs b/src/Filee.Platform.MacOS/MacOSIntegrationFiles.csindex de5673d0..94f5a20f 100644--- a/src/Filee.Platform.MacOS/MacOSIntegrationFiles.cs+++ b/src/Filee.Platform.MacOS/MacOSIntegrationFiles.cs@@ -12,61 +12,21 @@ internal static class MacOSIntegrationFiles("RunAtLoad", true),("KeepAlive", false)));- internal static string ServiceInfo(string label) => Plist(Dict(- ("CFBundleName", label),- ("CFBundleIdentifier", "com.filee.app.convert-service"),- ("NSServices", Array(Dict(- ("NSMenuItem", Dict(("default", label))),- ("NSMessage", "runWorkflowAsService"),- ("NSRequiredContext", Dict(("NSApplicationIdentifier", "com.apple.finder"))),- ("NSSendFileTypes", Array("public.item")))))));-- internal static string Workflow(string executablePath) => Plist(Dict(- ("AMDocumentVersion", "2"),- ("actions", Array(Dict(("action", Dict(- ("AMAccepts", Dict(("Container", "List"), ("Optional", false), ("Types", Array("com.apple.cocoa.path")))),- ("AMProvides", Dict(("Container", "List"), ("Types", Array("com.apple.cocoa.string")))),- ("AMApplication", Array("Automator")),- ("AMActionVersion", "2.0.3"),- ("AMParameterProperties", Dict(("COMMAND_STRING", Dict()), ("inputMethod", Dict()), ("shell", Dict()), ("source", Dict()))),- ("ActionBundlePath", "/System/Library/Automator/Run Shell Script.action"),- ("ActionName", "Run Shell Script"),- ("ActionParameters", Dict(- ("COMMAND_STRING", ConversionCommand(executablePath)),- ("CheckedForUserDefaultShell", true),- ("inputMethod", 1),- ("shell", "/bin/sh"),- ("source", ""))),- ("BundleIdentifier", "com.apple.RunShellScript"),- ("Class Name", "RunShellScriptAction"),- ("CanShowWhenRun", false),- ("InputUUID", "E79B8709-D276-4DB2-A0D9-07FDF599774E"),- ("OutputUUID", "09A1D308-CB6C-4EC8-9545-68272C47BA52"),- ("UUID", "ED186538-5D03-4A64-88BD-52FC9A905E4F"),- ("arguments", Dict())))))),- ("connectors", Dict()),- ("workflowMetaData", Dict(- ("serviceApplicationBundleID", "com.apple.finder"),- ("serviceApplicationPath", "/System/Library/CoreServices/Finder.app"),- ("serviceInputTypeIdentifier", "com.apple.Automator.fileSystemObject"),- ("serviceOutputTypeIdentifier", "com.apple.Automator.nothing"),- ("serviceProcessesInput", true),- ("workflowTypeIdentifier", "com.apple.Automator.servicesMenu")))));-- internal static string ConversionCommand(string executablePath)+ /// <summary>+ /// The service's entry in the pbs NSServicesStatus preferences: "bundle id - menu title - message", quoted for+ /// defaults, which reads the key as a property list string.+ /// </summary>+ internal static string ServiceStatusKey =>+ $"\"com.filee.app - {MacOSServicesProvider.MenuItem} - {MacOSServicesProvider.Message}\"";++ /// <summary>On or off in the right-click menu and the Services menu, as System Settings writes it.</summary>+ internal static string ServiceStatus(bool enabled){- const string contents = "/Contents/MacOS/";- var index = executablePath.LastIndexOf(contents, StringComparison.Ordinal);- if (index > 0 && executablePath[..index].EndsWith(".app", StringComparison.OrdinalIgnoreCase))- {- // A fresh process forwards arguments to Filee's running instance; open otherwise discards them.- return $"exec /usr/bin/open -n -a {ShellQuote(executablePath[..index])} --args --convert \"$@\"";- }- return $"exec {ShellQuote(executablePath)} --convert \"$@\"";+ var on = enabled ? 1 : 0;+ return $"{{ \"enabled_context_menu\" = {on}; \"enabled_services_menu\" = {on}; " ++ $"\"presentation_modes\" = {{ \"ContextMenu\" = {on}; \"ServicesMenu\" = {on}; }}; }}";}- private static string ShellQuote(string value) => "'" + value.Replace("'", "'\"'\"'", StringComparison.Ordinal) + "'";-private static string Plist(XElement dictionary) =>"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +new XDocument(diff --git a/src/Filee.Platform.MacOS/MacOSPlatformServices.cs b/src/Filee.Platform.MacOS/MacOSPlatformServices.csindex 6ed44d31..4b838c56 100644--- a/src/Filee.Platform.MacOS/MacOSPlatformServices.cs+++ b/src/Filee.Platform.MacOS/MacOSPlatformServices.cs@@ -69,30 +69,25 @@ public sealed class MacOSPlatformServices : IPlatformServicesFile.WriteAllText(path, MacOSIntegrationFiles.LaunchAgent(executablePath), new UTF8Encoding(false));}+ /// <summary>+ /// Shows or hides Filee's own service in Finder's right-click menu (the same switch as System Settings >+ /// Keyboard > Keyboard Shortcuts > Services), and removes the Automator Quick Action earlier builds installed.+ /// </summary>public void SetContextMenu(bool enabled, string executablePath, string label){- var workflow = Path.Combine(UserLibrary, "Services", "Filee.workflow");- var contents = Path.Combine(workflow, "Contents");- if (enabled)- {- RequireExecutable(executablePath);- Directory.CreateDirectory(contents);- File.WriteAllText(Path.Combine(contents, "Info.plist"), MacOSIntegrationFiles.ServiceInfo(label), new UTF8Encoding(false));- File.WriteAllText(Path.Combine(contents, "document.wflow"), MacOSIntegrationFiles.Workflow(executablePath), new UTF8Encoding(false));- }- else if (Directory.Exists(contents))- {- File.Delete(Path.Combine(contents, "Info.plist"));- File.Delete(Path.Combine(contents, "document.wflow"));- if (!Directory.EnumerateFileSystemEntries(contents).Any())- Directory.Delete(contents);- if (!Directory.EnumerateFileSystemEntries(workflow).Any())- Directory.Delete(workflow);- }-+ RemoveLegacyWorkflow();+ Run("/usr/bin/defaults", ["write", "pbs", "NSServicesStatus", "-dict-add",+ MacOSIntegrationFiles.ServiceStatusKey, MacOSIntegrationFiles.ServiceStatus(enabled)], 10_000);Run("/System/Library/CoreServices/pbs", ["-update"], 10_000);}+ private static void RemoveLegacyWorkflow()+ {+ var workflow = Path.Combine(UserLibrary, "Services", "Filee.workflow");+ if (Directory.Exists(workflow))+ Directory.Delete(workflow, recursive: true);+ }+public ModernContextMenuState GetModernContextMenuState(string executablePath) => ModernContextMenuState.Unsupported;public Task<ModernContextMenuResult> SetModernContextMenuAsync(bool enabled, string executablePath) =>diff --git a/src/Filee.Platform.MacOS/MacOSServicesProvider.cs b/src/Filee.Platform.MacOS/MacOSServicesProvider.csnew file mode 100644index 00000000..36fa706a--- /dev/null+++ b/src/Filee.Platform.MacOS/MacOSServicesProvider.cs@@ -0,0 +1,122 @@+// "Convert with Filee" in Finder's right-click menu, as a service Filee.app provides itself (NSServices in its+// Info.plist). macOS hands the selected files straight to the running Filee: no Automator workflow, no shell, no+// second process. Info.plist names the message (convertFiles) and the port (Filee); this registers the object+// that answers it, an NSObject subclass made at run time with one method, convertFiles:userData:error:.++using System.Runtime.InteropServices;+using System.Runtime.Versioning;++namespace Filee.Platform.MacOS;++[SupportedOSPlatform("macos")]+public static class MacOSServicesProvider+{+ /// <summary>The service's menu title in Info.plist; ServicesMenu.strings in each .lproj translates it.</summary>+ public const string MenuItem = "Convert with Filee";++ /// <summary>The selector macOS sends, without its argument labels (NSMessage in Info.plist).</summary>+ public const string Message = "convertFiles";++ private const string ObjC = "/usr/lib/libobjc.dylib";+ private const string AppKit = "/System/Library/Frameworks/AppKit.framework/AppKit";++ private delegate void ServiceMethod(nint self, nint selector, nint pasteboard, nint userData, nint error);++ // Kept alive for as long as Objective-C may call it.+ private static readonly ServiceMethod Method = ConvertFiles;+ private static Action<IReadOnlyList<string>>? _handler;+ private static nint _provider;++ /// <summary>+ /// Answers the service from now on; <paramref name="handler"/> gets the files (on the main thread). Call it on the+ /// main thread early at start: a service picked while Filee wasn't running is delivered once this is set.+ /// </summary>+ public static void Register(Action<IReadOnlyList<string>> handler)+ {+ _handler = handler;+ if (_provider != 0)+ return;+ NativeLibrary.Load(AppKit);+ var type = objc_getClass("FileeServicesProvider");+ if (type == 0)+ {+ type = objc_allocateClassPair(objc_getClass("NSObject"), "FileeServicesProvider", 0);+ class_addMethod(type, sel_registerName(Message + ":userData:error:"), Marshal.GetFunctionPointerForDelegate(Method), "v@:@@^@");+ objc_registerClassPair(type);+ }+ _provider = Send(Send(type, sel_registerName("alloc")), sel_registerName("init"));+ var application = Send(objc_getClass("NSApplication"), sel_registerName("sharedApplication"));+ SendVoid(application, sel_registerName("setServicesProvider:"), _provider);+ NSUpdateDynamicServices();+ }++ private static void ConvertFiles(nint self, nint selector, nint pasteboard, nint userData, nint error)+ {+ try+ {+ var files = FilesOn(pasteboard);+ if (files.Count > 0)+ _handler?.Invoke(files);+ }+ catch (Exception ex) when (ex is not OutOfMemoryException)+ {+ // An exception must not unwind into Objective-C; the menu item simply does nothing then.+ }+ }++ /// <summary>The file paths on a pasteboard (Finder puts file URLs there).</summary>+ private static List<string> FilesOn(nint pasteboard)+ {+ var files = new List<string>();+ var classes = Send(objc_getClass("NSArray"), sel_registerName("arrayWithObject:"), objc_getClass("NSURL"));+ var urls = Send(pasteboard, sel_registerName("readObjectsForClasses:options:"), classes, 0);+ if (urls == 0)+ return files;+ var count = Send(urls, sel_registerName("count"));+ for (nint index = 0; index < count; index++)+ {+ var url = Send(urls, sel_registerName("objectAtIndex:"), index);+ if (!SendBool(url, sel_registerName("isFileURL")))+ continue;+ var path = Marshal.PtrToStringUTF8(Send(Send(url, sel_registerName("path")), sel_registerName("UTF8String")));+ if (!string.IsNullOrEmpty(path))+ files.Add(path);+ }+ return files;+ }++ [DllImport(ObjC)]+ private static extern nint objc_getClass([MarshalAs(UnmanagedType.LPUTF8Str)] string name);++ [DllImport(ObjC)]+ private static extern nint objc_allocateClassPair(nint superclass, [MarshalAs(UnmanagedType.LPUTF8Str)] string name, nint extraBytes);++ [DllImport(ObjC)]+ private static extern void objc_registerClassPair(nint type);++ [DllImport(ObjC)]+ [return: MarshalAs(UnmanagedType.I1)]+ private static extern bool class_addMethod(nint type, nint selector, nint implementation, [MarshalAs(UnmanagedType.LPUTF8Str)] string types);++ [DllImport(ObjC)]+ private static extern nint sel_registerName([MarshalAs(UnmanagedType.LPUTF8Str)] string name);++ [DllImport(ObjC, EntryPoint = "objc_msgSend")]+ private static extern nint Send(nint receiver, nint selector);++ [DllImport(ObjC, EntryPoint = "objc_msgSend")]+ private static extern nint Send(nint receiver, nint selector, nint argument);++ [DllImport(ObjC, EntryPoint = "objc_msgSend")]+ private static extern nint Send(nint receiver, nint selector, nint first, nint second);++ [DllImport(ObjC, EntryPoint = "objc_msgSend")]+ private static extern void SendVoid(nint receiver, nint selector, nint argument);++ [DllImport(ObjC, EntryPoint = "objc_msgSend")]+ [return: MarshalAs(UnmanagedType.I1)]+ private static extern bool SendBool(nint receiver, nint selector);++ [DllImport(AppKit)]+ private static extern void NSUpdateDynamicServices();+}diff --git a/tests/Filee.Platform.Tests/MacOSIntegrationTests.cs b/tests/Filee.Platform.Tests/MacOSIntegrationTests.csindex 00df686f..693000d4 100644--- a/tests/Filee.Platform.Tests/MacOSIntegrationTests.cs+++ b/tests/Filee.Platform.Tests/MacOSIntegrationTests.cs@@ -17,38 +17,35 @@ public sealed class MacOSIntegrationTests}[Fact]- public void ServiceMenuEscapesLocalizedLabelAndOnlyAcceptsFinderFiles()+ public void ServiceSwitchWritesTheEntrySystemSettingsUses(){- const string label = "Filee로 변환 <빠르게> & 'convert'";- var root = ReadPlist(MacOSIntegrationFiles.ServiceInfo(label));- var service = Property(root, "NSServices").Element("dict")!;- Assert.Equal(label, Property(Property(service, "NSMenuItem"), "default").Value);- Assert.Equal(label, Property(root, "CFBundleName").Value);- Assert.Equal("com.apple.finder", Property(Property(service, "NSRequiredContext"), "NSApplicationIdentifier").Value);- Assert.Equal("public.item", Property(service, "NSSendFileTypes").Element("string")!.Value);+ Assert.Equal("\"com.filee.app - Convert with Filee - convertFiles\"", MacOSIntegrationFiles.ServiceStatusKey);+ Assert.Contains("\"enabled_context_menu\" = 0;", MacOSIntegrationFiles.ServiceStatus(false));+ Assert.Contains("\"ContextMenu\" = 1;", MacOSIntegrationFiles.ServiceStatus(true));}[Fact]- public void QuickActionLaunchesFreshBundleInstanceToForwardArguments()+ public void AppBundleDeclaresTheServiceFileeAnswers(){- const string executable = "/Applications/O'Brien & Friends/Filee.app/Contents/MacOS/Filee";- var workflow = ReadPlist(MacOSIntegrationFiles.Workflow(executable));- var action = Property(Property(workflow, "actions").Element("dict")!, "action");- var parameters = Property(action, "ActionParameters");- Assert.Equal("1", Property(parameters, "inputMethod").Value);- Assert.Equal("/bin/sh", Property(parameters, "shell").Value);- Assert.Equal("exec /usr/bin/open -n -a '/Applications/O'\"'\"'Brien & Friends/Filee.app' --args --convert \"$@\"",- Property(parameters, "COMMAND_STRING").Value);- var metadata = Property(workflow, "workflowMetaData");- Assert.Equal("com.apple.Automator.fileSystemObject", Property(metadata, "serviceInputTypeIdentifier").Value);- Assert.Equal("com.apple.finder", Property(metadata, "serviceApplicationBundleID").Value);+ var installer = Path.Combine(RepositoryRoot(), "installer", "macos");+ var root = ReadPlist(File.ReadAllText(Path.Combine(installer, "Info.plist")));+ var service = Property(root, "NSServices").Element("dict")!;+ Assert.Equal(MacOSServicesProvider.MenuItem, Property(Property(service, "NSMenuItem"), "default").Value);+ Assert.Equal(MacOSServicesProvider.Message, Property(service, "NSMessage").Value);+ Assert.Equal("Filee", Property(service, "NSPortName").Value);+ Assert.Equal("public.item", Property(service, "NSSendFileTypes").Element("string")!.Value);+ // Each translation names the same menu title.+ foreach (var strings in Directory.GetFiles(installer, "ServicesMenu.strings", SearchOption.AllDirectories))+ Assert.StartsWith($"\"{MacOSServicesProvider.MenuItem}\" = ", File.ReadAllLines(strings).Single(l => l.StartsWith('"')));+ Assert.Equal(3, Directory.GetFiles(installer, "ServicesMenu.strings", SearchOption.AllDirectories).Length);}- [Fact]- public void RawExecutableIsQuotedWithoutEvaluatingShellMetacharacters()+ private static string RepositoryRoot(){- Assert.Equal("exec '/tmp/$(touch nope) `echo bad` \"quote\"' --convert \"$@\"",- MacOSIntegrationFiles.ConversionCommand("/tmp/$(touch nope) `echo bad` \"quote\""));+ var folder = new DirectoryInfo(AppContext.BaseDirectory);+ while (folder is not null && !File.Exists(Path.Combine(folder.FullName, "Filee.slnx")))+ folder = folder.Parent;+ return folder?.FullName ?? throw new DirectoryNotFoundException("Filee.slnx not found above the test output.");}[Fact]