From b58dcd7396f885690709329b84b523bcffb4e8b9 Mon Sep 17 00:00:00 2001 From: Christoph Wille Date: Mon, 29 Apr 2024 16:05:22 +0200 Subject: [PATCH 1/3] Make AboutPage AOT-friendlier --- ILSpy/AboutPage.cs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/ILSpy/AboutPage.cs b/ILSpy/AboutPage.cs index 1dcef578ab..b796fa3622 100644 --- a/ILSpy/AboutPage.cs +++ b/ILSpy/AboutPage.cs @@ -54,7 +54,7 @@ public static void Display(DecompilerTextView textView) }; output.WriteLine(Resources.ILSpyVersion + DecompilerVersionInfo.FullVersion); - string prodVersion = System.Diagnostics.FileVersionInfo.GetVersionInfo(typeof(Uri).Assembly.Location).ProductVersion; + string prodVersion = GetDotnetProductVersion(); output.WriteLine(Resources.NETFrameworkVersion + prodVersion); output.AddUIElement( @@ -104,6 +104,27 @@ public static void Display(DecompilerTextView textView) textView.ShowText(output); } + private static string GetDotnetProductVersion() + { + // In case of AOT .Location is null, we need a fallback for that + string assemblyLocation = typeof(Uri).Assembly.Location; + + if (!String.IsNullOrWhiteSpace(assemblyLocation)) + { + return System.Diagnostics.FileVersionInfo.GetVersionInfo(assemblyLocation).ProductVersion; + } + else + { + var version = typeof(Object).Assembly.GetName().Version; + if (version != null) + { + return version.ToString(); + } + } + + return "UNKNOWN"; + } + sealed class MyLinkElementGenerator : LinkElementGenerator { readonly Uri uri; From be8e788b372c1d72b6eb2b3c00ebb59b7f9f57bb Mon Sep 17 00:00:00 2001 From: Christoph Wille Date: Mon, 29 Apr 2024 16:10:34 +0200 Subject: [PATCH 2/3] Fix AOT and x-plat settings path inference --- ILSpy/ILSpySettingsFilePathProvider.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ILSpy/ILSpySettingsFilePathProvider.cs b/ILSpy/ILSpySettingsFilePathProvider.cs index 386b9b2baa..c6fde1fb8b 100644 --- a/ILSpy/ILSpySettingsFilePathProvider.cs +++ b/ILSpy/ILSpySettingsFilePathProvider.cs @@ -29,10 +29,16 @@ public string GetSettingsFilePath() { if (App.CommandLineArguments.ConfigFile != null) return App.CommandLineArguments.ConfigFile; - string localPath = Path.Combine(Path.GetDirectoryName(typeof(MainWindow).Assembly.Location), "ILSpy.xml"); - if (File.Exists(localPath)) - return localPath; - return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ICSharpCode\\ILSpy.xml"); + + var assemblyLocation = typeof(MainWindow).Assembly.Location; + if (!String.IsNullOrEmpty(assemblyLocation)) + { + string localPath = Path.Combine(Path.GetDirectoryName(assemblyLocation), "ILSpy.xml"); + if (File.Exists(localPath)) + return localPath; + } + + return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ICSharpCode", "ILSpy.xml"); } } } From 3ace9fa029163dc15872295a15c3763ffc8833b1 Mon Sep 17 00:00:00 2001 From: Christoph Wille Date: Mon, 29 Apr 2024 16:12:47 +0200 Subject: [PATCH 3/3] Use IsNullOrWhiteSpace in all cases --- ILSpy/ILSpySettingsFilePathProvider.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ILSpy/ILSpySettingsFilePathProvider.cs b/ILSpy/ILSpySettingsFilePathProvider.cs index c6fde1fb8b..74bba6c4b2 100644 --- a/ILSpy/ILSpySettingsFilePathProvider.cs +++ b/ILSpy/ILSpySettingsFilePathProvider.cs @@ -31,7 +31,7 @@ public string GetSettingsFilePath() return App.CommandLineArguments.ConfigFile; var assemblyLocation = typeof(MainWindow).Assembly.Location; - if (!String.IsNullOrEmpty(assemblyLocation)) + if (!String.IsNullOrWhiteSpace(assemblyLocation)) { string localPath = Path.Combine(Path.GetDirectoryName(assemblyLocation), "ILSpy.xml"); if (File.Exists(localPath))