Browse Source

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

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

7
ILSpy/Commands/CheckForUpdatesCommand.cs

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

7
ILSpy/MainWindow.xaml.cs

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

24
ILSpy/StorePackageHelper.cs

@ -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