Browse Source

Extract WindowsVersionHelper to single location to not spread (and miss) instances of #if NET472

pull/2346/head
Christoph Wille 5 years ago
parent
commit
67e270cdba
  1. 13
      ILSpy/AboutPage.cs
  2. 7
      ILSpy/Commands/CheckForUpdatesCommand.cs
  3. 7
      ILSpy/MainWindow.xaml.cs
  4. 24
      ILSpy/StorePackageHelper.cs

13
ILSpy/AboutPage.cs

@ -35,8 +35,6 @@ using ICSharpCode.Decompiler; @@ -35,8 +35,6 @@ using ICSharpCode.Decompiler;
using ICSharpCode.ILSpy.Properties;
using ICSharpCode.ILSpy.TextView;
using OSVersionHelper;
namespace ICSharpCode.ILSpy
{
[ExportMainMenuCommand(Menu = nameof(Resources._Help), Header = nameof(Resources._About), MenuOrder = 99999)]
@ -62,13 +60,10 @@ namespace ICSharpCode.ILSpy @@ -62,13 +60,10 @@ namespace ICSharpCode.ILSpy
EnableHyperlinks = true
};
output.WriteLine(Resources.ILSpyVersion + RevisionClass.FullVersion);
bool hasPackageIdentity = false;
#if NET472
hasPackageIdentity = WindowsVersionHelper.HasPackageIdentity;
#endif
if (hasPackageIdentity)
if (StorePackageHelper.HasPackageIdentity)
{
output.WriteLine($"Package Name: {WindowsVersionHelper.GetPackageFamilyName()}");
output.WriteLine($"Package Name: {StorePackageHelper.GetPackageFamilyName()}");
}
else
{// if we're running in an MSIX, updates work differently
@ -304,7 +299,7 @@ namespace ICSharpCode.ILSpy @@ -304,7 +299,7 @@ namespace ICSharpCode.ILSpy
UpdateSettings s = new UpdateSettings(spySettings);
// If we're in an MSIX package, updates work differently
if (s.AutomaticUpdateCheckEnabled && !WindowsVersionHelper.HasPackageIdentity)
if (s.AutomaticUpdateCheckEnabled && !StorePackageHelper.HasPackageIdentity)
{
// perform update check if we never did one before;
// or if the last check wasn't in the past 7 days

7
ILSpy/Commands/CheckForUpdatesCommand.cs

@ -19,8 +19,6 @@ @@ -19,8 +19,6 @@
using ICSharpCode.ILSpy.Properties;
using OSVersionHelper;
namespace ICSharpCode.ILSpy
{
[ExportMainMenuCommand(Menu = nameof(Resources._Help), Header = nameof(Resources._CheckUpdates), MenuOrder = 5000)]
@ -28,12 +26,11 @@ namespace ICSharpCode.ILSpy @@ -28,12 +26,11 @@ namespace ICSharpCode.ILSpy
{
public override bool CanExecute(object parameter)
{
#if NET472
if (WindowsVersionHelper.HasPackageIdentity)
if (StorePackageHelper.HasPackageIdentity)
{
return false;
}
#endif
return base.CanExecute(parameter);
}

7
ILSpy/MainWindow.xaml.cs

@ -52,8 +52,6 @@ using ICSharpCode.TreeView; @@ -52,8 +52,6 @@ using ICSharpCode.TreeView;
using Microsoft.Win32;
using OSVersionHelper;
namespace ICSharpCode.ILSpy
{
class MainWindowDataContext
@ -678,13 +676,12 @@ namespace ICSharpCode.ILSpy @@ -678,13 +676,12 @@ namespace ICSharpCode.ILSpy
public async Task ShowMessageIfUpdatesAvailableAsync(ILSpySettings spySettings, bool forceCheck = false)
{
#if NET472
// Don't check for updates if we're in an MSIX since they work differently
if (WindowsVersionHelper.HasPackageIdentity)
if (StorePackageHelper.HasPackageIdentity)
{
return;
}
#endif
string downloadUrl;
if (forceCheck)
{

24
ILSpy/StorePackageHelper.cs

@ -0,0 +1,24 @@ @@ -0,0 +1,24 @@
using OSVersionHelper;
namespace ICSharpCode.ILSpy
{
// The Store package is ever only built for net472
public static class StorePackageHelper
{
public static bool HasPackageIdentity {
get {
#if NET472
return WindowsVersionHelper.HasPackageIdentity;
#endif
return false;
}
}
public static string GetPackageFamilyName()
{
#if NET472
return WindowsVersionHelper.GetPackageFamilyName();
#endif
return "";
}
}
}
Loading…
Cancel
Save