From 399ba1c0100b1d252360bf4a6872a2ab19141813 Mon Sep 17 00:00:00 2001 From: Christoph Wille Date: Sun, 2 Jun 2024 08:49:19 +0200 Subject: [PATCH] Enable certain commands only on Windows (#3217) --- ILSpy/AppEnv/AppEnvironment.cs | 9 +++++++++ ILSpy/Commands/OpenFromGacCommand.cs | 7 +++++++ ILSpy/Options/MiscSettingsPanel.xaml | 2 +- ILSpy/Options/MiscSettingsViewModel.cs | 7 +++++-- 4 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 ILSpy/AppEnv/AppEnvironment.cs diff --git a/ILSpy/AppEnv/AppEnvironment.cs b/ILSpy/AppEnv/AppEnvironment.cs new file mode 100644 index 000000000..15d779f4e --- /dev/null +++ b/ILSpy/AppEnv/AppEnvironment.cs @@ -0,0 +1,9 @@ +using System.Runtime.InteropServices; + +namespace ICSharpCode.ILSpy.AppEnv +{ + public static class AppEnvironment + { + public static bool IsWindows => RuntimeInformation.IsOSPlatform(OSPlatform.Windows); + } +} diff --git a/ILSpy/Commands/OpenFromGacCommand.cs b/ILSpy/Commands/OpenFromGacCommand.cs index 8f72d3b6a..a077ceb9d 100644 --- a/ILSpy/Commands/OpenFromGacCommand.cs +++ b/ILSpy/Commands/OpenFromGacCommand.cs @@ -16,12 +16,19 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. +using ICSharpCode.ILSpy.AppEnv; using ICSharpCode.ILSpy.Properties; + namespace ICSharpCode.ILSpy { [ExportMainMenuCommand(ParentMenuID = nameof(Resources._File), Header = nameof(Resources.OpenFrom_GAC), MenuIcon = "Images/AssemblyListGAC", MenuCategory = nameof(Resources.Open), MenuOrder = 1)] sealed class OpenFromGacCommand : SimpleCommand { + public override bool CanExecute(object parameter) + { + return AppEnvironment.IsWindows; + } + public override void Execute(object parameter) { OpenFromGacDialog dlg = new OpenFromGacDialog(); diff --git a/ILSpy/Options/MiscSettingsPanel.xaml b/ILSpy/Options/MiscSettingsPanel.xaml index 09a9c5485..502f65fcc 100644 --- a/ILSpy/Options/MiscSettingsPanel.xaml +++ b/ILSpy/Options/MiscSettingsPanel.xaml @@ -11,7 +11,7 @@ -