From b466530e084de057e585645f19e5ef11b20307b2 Mon Sep 17 00:00:00 2001 From: Qstick Date: Sat, 5 Sep 2020 01:13:17 -0400 Subject: [PATCH] Remove Dotnet Framework Version Checks [common] --- .../Checks/DotnetVersionCheckFixture.cs | 78 ------------------- .../HealthCheck/Checks/DotnetVersionCheck.cs | 64 --------------- 2 files changed, 142 deletions(-) delete mode 100644 src/NzbDrone.Core.Test/HealthCheck/Checks/DotnetVersionCheckFixture.cs delete mode 100644 src/NzbDrone.Core/HealthCheck/Checks/DotnetVersionCheck.cs diff --git a/src/NzbDrone.Core.Test/HealthCheck/Checks/DotnetVersionCheckFixture.cs b/src/NzbDrone.Core.Test/HealthCheck/Checks/DotnetVersionCheckFixture.cs deleted file mode 100644 index d6caec81a..000000000 --- a/src/NzbDrone.Core.Test/HealthCheck/Checks/DotnetVersionCheckFixture.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System; -using Moq; -using NUnit.Framework; -using NzbDrone.Common.EnvironmentInfo; -using NzbDrone.Core.HealthCheck.Checks; -using NzbDrone.Core.Localization; -using NzbDrone.Core.Test.Framework; - -namespace NzbDrone.Core.Test.HealthCheck.Checks -{ - [TestFixture] - public class DotnetVersionCheckFixture : CoreTest - { - [SetUp] - public void Setup() - { - Mocker.GetMock() - .Setup(s => s.GetLocalizedString(It.IsAny())) - .Returns("Some Warning Message"); - } - - private void GivenOutput(string version) - { - WindowsOnly(); - - Mocker.GetMock() - .SetupGet(s => s.Version) - .Returns(new Version(version)); - } - - [TestCase("4.7.2")] - [TestCase("4.8")] - public void should_return_ok(string version) - { - GivenOutput(version); - - Subject.Check().ShouldBeOk(); - } - - [TestCase("4.6.2")] - [TestCase("4.7")] - [TestCase("4.7.1")] - public void should_return_notice(string version) - { - if (PlatformInfo.IsDotNet) - { - GivenOutput(version); - - Subject.Check().ShouldBeNotice(); - } - } - - [TestCase("4.5")] - [TestCase("4.5.2")] - [TestCase("4.6.1")] - public void should_return_error(string version) - { - if (PlatformInfo.IsDotNet) - { - GivenOutput(version); - - Subject.Check().ShouldBeError(); - } - } - - [Test] - public void should_return_ok_for_net462_on_Win1511() - { - Mocker.GetMock() - .SetupGet(v => v.Version) - .Returns("10.0.14392"); - - GivenOutput("4.6.2"); - - Subject.Check().ShouldBeOk(); - } - } -} diff --git a/src/NzbDrone.Core/HealthCheck/Checks/DotnetVersionCheck.cs b/src/NzbDrone.Core/HealthCheck/Checks/DotnetVersionCheck.cs deleted file mode 100644 index 14564e250..000000000 --- a/src/NzbDrone.Core/HealthCheck/Checks/DotnetVersionCheck.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System; -using NLog; -using NzbDrone.Common.EnvironmentInfo; -using NzbDrone.Core.Localization; - -namespace NzbDrone.Core.HealthCheck.Checks -{ - public class DotnetVersionCheck : HealthCheckBase - { - private readonly IPlatformInfo _platformInfo; - private readonly IOsInfo _osInfo; - private readonly Logger _logger; - - public DotnetVersionCheck(IPlatformInfo platformInfo, IOsInfo osInfo, ILocalizationService localizationService, Logger logger) - : base(localizationService) - { - _platformInfo = platformInfo; - _osInfo = osInfo; - _logger = logger; - } - - public override HealthCheck Check() - { - if (!PlatformInfo.IsDotNet) - { - return new HealthCheck(GetType()); - } - - var dotnetVersion = _platformInfo.Version; - - // Target .Net version, which would allow us to increase our target framework - var targetVersion = new Version("4.7.2"); - if (Version.TryParse(_osInfo.Version, out var osVersion) && osVersion < new Version("10.0.14393")) - { - // Windows 10 LTSB 1511 and before do not support 4.7.x - targetVersion = new Version("4.6.2"); - } - - if (dotnetVersion >= targetVersion) - { - _logger.Debug("Dotnet version is {0} or better: {1}", targetVersion, dotnetVersion); - return new HealthCheck(GetType()); - } - - // Supported .net version but below our desired target - var stableVersion = new Version("4.6.2"); - if (dotnetVersion >= stableVersion) - { - _logger.Debug("Dotnet version is {0} or better: {1}", stableVersion, dotnetVersion); - return new HealthCheck(GetType(), - HealthCheckResult.Notice, - string.Format(_localizationService.GetLocalizedString("DotNetVersionCheckNotRecommendedMessage"), dotnetVersion, targetVersion), - "#currently-installed-net-framework-is-supported-but-upgrading-is-recommended"); - } - - return new HealthCheck(GetType(), - HealthCheckResult.Error, - string.Format(_localizationService.GetLocalizedString("DotNetVersionCheckOldUnsupportedMessage"), dotnetVersion, targetVersion), - "#currently-installed-net-framework-is-old-and-unsupported"); - } - - public override bool CheckOnSchedule => false; - } -}