Browse Source

Make AboutPage AOT-friendlier

pull/3203/head
Christoph Wille 2 years ago
parent
commit
b58dcd7396
  1. 23
      ILSpy/AboutPage.cs

23
ILSpy/AboutPage.cs

@ -54,7 +54,7 @@ namespace ICSharpCode.ILSpy
}; };
output.WriteLine(Resources.ILSpyVersion + DecompilerVersionInfo.FullVersion); 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.WriteLine(Resources.NETFrameworkVersion + prodVersion);
output.AddUIElement( output.AddUIElement(
@ -104,6 +104,27 @@ namespace ICSharpCode.ILSpy
textView.ShowText(output); 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 sealed class MyLinkElementGenerator : LinkElementGenerator
{ {
readonly Uri uri; readonly Uri uri;

Loading…
Cancel
Save