Skip to content

Commit e5d1120

Browse files
AOT and x-plat changes (#3203)
* Make AboutPage AOT-friendlier * Fix AOT and x-plat settings path inference
1 parent 971836d commit e5d1120

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

ILSpy/AboutPage.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public static void Display(DecompilerTextView textView)
5454
};
5555
output.WriteLine(Resources.ILSpyVersion + DecompilerVersionInfo.FullVersion);
5656

57-
string prodVersion = System.Diagnostics.FileVersionInfo.GetVersionInfo(typeof(Uri).Assembly.Location).ProductVersion;
57+
string prodVersion = GetDotnetProductVersion();
5858
output.WriteLine(Resources.NETFrameworkVersion + prodVersion);
5959

6060
output.AddUIElement(
@@ -104,6 +104,27 @@ public static void Display(DecompilerTextView textView)
104104
textView.ShowText(output);
105105
}
106106

107+
private static string GetDotnetProductVersion()
108+
{
109+
// In case of AOT .Location is null, we need a fallback for that
110+
string assemblyLocation = typeof(Uri).Assembly.Location;
111+
112+
if (!String.IsNullOrWhiteSpace(assemblyLocation))
113+
{
114+
return System.Diagnostics.FileVersionInfo.GetVersionInfo(assemblyLocation).ProductVersion;
115+
}
116+
else
117+
{
118+
var version = typeof(Object).Assembly.GetName().Version;
119+
if (version != null)
120+
{
121+
return version.ToString();
122+
}
123+
}
124+
125+
return "UNKNOWN";
126+
}
127+
107128
sealed class MyLinkElementGenerator : LinkElementGenerator
108129
{
109130
readonly Uri uri;

ILSpy/ILSpySettingsFilePathProvider.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,16 @@ public string GetSettingsFilePath()
2929
{
3030
if (App.CommandLineArguments.ConfigFile != null)
3131
return App.CommandLineArguments.ConfigFile;
32-
string localPath = Path.Combine(Path.GetDirectoryName(typeof(MainWindow).Assembly.Location), "ILSpy.xml");
33-
if (File.Exists(localPath))
34-
return localPath;
35-
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ICSharpCode\\ILSpy.xml");
32+
33+
var assemblyLocation = typeof(MainWindow).Assembly.Location;
34+
if (!String.IsNullOrWhiteSpace(assemblyLocation))
35+
{
36+
string localPath = Path.Combine(Path.GetDirectoryName(assemblyLocation), "ILSpy.xml");
37+
if (File.Exists(localPath))
38+
return localPath;
39+
}
40+
41+
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ICSharpCode", "ILSpy.xml");
3642
}
3743
}
3844
}

0 commit comments

Comments
 (0)