From c13fff13584e10d111a1108983caee1f319c03e0 Mon Sep 17 00:00:00 2001 From: Keivan Beigi Date: Sat, 7 Jan 2017 09:59:59 -0800 Subject: [PATCH] Use nameof --- src/NzbDrone.Common/Extensions/DictionaryExtensions.cs | 4 ++-- .../TPL/LimitedConcurrencyLevelTaskScheduler.cs | 2 +- .../QualityAllowedByProfileSpecificationFixture.cs | 4 ++-- .../DecisionEngineTests/QualityUpgradeSpecificationFixture.cs | 2 +- src/NzbDrone.Core.Test/ParserTests/HashedReleaseFixture.cs | 2 +- src/NzbDrone.Core.Test/ParserTests/QualityParserFixture.cs | 4 ++-- src/NzbDrone.Core.Test/Qualities/QualityFixture.cs | 4 ++-- src/NzbDrone.Core/Qualities/Quality.cs | 2 +- src/NzbDrone.Core/RootFolders/RootFolderService.cs | 2 +- src/NzbDrone.Core/Update/InstallUpdateService.cs | 2 +- src/NzbDrone.Update/UpdateApp.cs | 4 ++-- 11 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/NzbDrone.Common/Extensions/DictionaryExtensions.cs b/src/NzbDrone.Common/Extensions/DictionaryExtensions.cs index d14452172..d92005875 100644 --- a/src/NzbDrone.Common/Extensions/DictionaryExtensions.cs +++ b/src/NzbDrone.Common/Extensions/DictionaryExtensions.cs @@ -14,8 +14,8 @@ namespace NzbDrone.Common.Extensions public static Dictionary Merge(this Dictionary first, Dictionary second) { - if (first == null) throw new ArgumentNullException("first"); - if (second == null) throw new ArgumentNullException("second"); + if (first == null) throw new ArgumentNullException(nameof(first)); + if (second == null) throw new ArgumentNullException(nameof(second)); var merged = new Dictionary(); first.ToList().ForEach(kv => merged[kv.Key] = kv.Value); diff --git a/src/NzbDrone.Common/TPL/LimitedConcurrencyLevelTaskScheduler.cs b/src/NzbDrone.Common/TPL/LimitedConcurrencyLevelTaskScheduler.cs index 8e336668e..890ba16df 100644 --- a/src/NzbDrone.Common/TPL/LimitedConcurrencyLevelTaskScheduler.cs +++ b/src/NzbDrone.Common/TPL/LimitedConcurrencyLevelTaskScheduler.cs @@ -25,7 +25,7 @@ namespace NzbDrone.Common.TPL /// The maximum degree of parallelism provided by this scheduler. public LimitedConcurrencyLevelTaskScheduler(int maxDegreeOfParallelism) { - if (maxDegreeOfParallelism < 1) throw new ArgumentOutOfRangeException("maxDegreeOfParallelism"); + if (maxDegreeOfParallelism < 1) throw new ArgumentOutOfRangeException(nameof(maxDegreeOfParallelism)); _maxDegreeOfParallelism = maxDegreeOfParallelism; } diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/QualityAllowedByProfileSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/QualityAllowedByProfileSpecificationFixture.cs index e833cd8d2..207f38225 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/QualityAllowedByProfileSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/QualityAllowedByProfileSpecificationFixture.cs @@ -45,7 +45,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests }; } - [Test, TestCaseSource("AllowedTestCases")] + [Test, TestCaseSource(nameof(AllowedTestCases))] public void should_allow_if_quality_is_defined_in_profile(Quality qualityType) { remoteEpisode.ParsedEpisodeInfo.Quality.Quality = qualityType; @@ -54,7 +54,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests Subject.IsSatisfiedBy(remoteEpisode, null).Accepted.Should().BeTrue(); } - [Test, TestCaseSource("DeniedTestCases")] + [Test, TestCaseSource(nameof(DeniedTestCases))] public void should_not_allow_if_quality_is_not_defined_in_profile(Quality qualityType) { remoteEpisode.ParsedEpisodeInfo.Quality.Quality = qualityType; diff --git a/src/NzbDrone.Core.Test/DecisionEngineTests/QualityUpgradeSpecificationFixture.cs b/src/NzbDrone.Core.Test/DecisionEngineTests/QualityUpgradeSpecificationFixture.cs index 49823c12b..1a4307bd1 100644 --- a/src/NzbDrone.Core.Test/DecisionEngineTests/QualityUpgradeSpecificationFixture.cs +++ b/src/NzbDrone.Core.Test/DecisionEngineTests/QualityUpgradeSpecificationFixture.cs @@ -36,7 +36,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests .Returns(autoDownloadPropers); } - [Test, TestCaseSource("IsUpgradeTestCases")] + [Test, TestCaseSource(nameof(IsUpgradeTestCases))] public void IsUpgradeTest(Quality current, int currentVersion, Quality newQuality, int newVersion, Quality cutoff, bool expected) { GivenAutoDownloadPropers(true); diff --git a/src/NzbDrone.Core.Test/ParserTests/HashedReleaseFixture.cs b/src/NzbDrone.Core.Test/ParserTests/HashedReleaseFixture.cs index 556a14fe8..7f17e1563 100644 --- a/src/NzbDrone.Core.Test/ParserTests/HashedReleaseFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/HashedReleaseFixture.cs @@ -83,7 +83,7 @@ namespace NzbDrone.Core.Test.ParserTests } }; - [Test, TestCaseSource("HashedReleaseParserCases")] + [Test, TestCaseSource(nameof(HashedReleaseParserCases))] public void should_properly_parse_hashed_releases(string path, string title, Quality quality, string releaseGroup) { var result = Parser.Parser.ParsePath(path); diff --git a/src/NzbDrone.Core.Test/ParserTests/QualityParserFixture.cs b/src/NzbDrone.Core.Test/ParserTests/QualityParserFixture.cs index 3eabec7e9..e5a187c5c 100644 --- a/src/NzbDrone.Core.Test/ParserTests/QualityParserFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/QualityParserFixture.cs @@ -238,7 +238,7 @@ namespace NzbDrone.Core.Test.ParserTests ParseAndVerifyQuality(title, Quality.Unknown, proper); } - [Test, TestCaseSource("SelfQualityParserCases")] + [Test, TestCaseSource(nameof(SelfQualityParserCases))] public void parsing_our_own_quality_enum_name(Quality quality) { var fileName = string.Format("My series S01E01 [{0}]", quality.Name); @@ -246,7 +246,7 @@ namespace NzbDrone.Core.Test.ParserTests result.Quality.Should().Be(quality); } - [Test, TestCaseSource("OtherSourceQualityParserCases")] + [Test, TestCaseSource(nameof(OtherSourceQualityParserCases))] public void should_parse_quality_from_other_source(string qualityString, Quality quality) { foreach (var c in new char[] { '-', '.', ' ', '_' }) diff --git a/src/NzbDrone.Core.Test/Qualities/QualityFixture.cs b/src/NzbDrone.Core.Test/Qualities/QualityFixture.cs index a9086a2bf..0087ef3e7 100644 --- a/src/NzbDrone.Core.Test/Qualities/QualityFixture.cs +++ b/src/NzbDrone.Core.Test/Qualities/QualityFixture.cs @@ -47,14 +47,14 @@ namespace NzbDrone.Core.Test.Qualities new object[] {Quality.Bluray2160p, 19}, }; - [Test, TestCaseSource("FromIntCases")] + [Test, TestCaseSource(nameof(FromIntCases))] public void should_be_able_to_convert_int_to_qualityTypes(int source, Quality expected) { var quality = (Quality)source; quality.Should().Be(expected); } - [Test, TestCaseSource("ToIntCases")] + [Test, TestCaseSource(nameof(ToIntCases))] public void should_be_able_to_convert_qualityTypes_to_int(Quality source, int expected) { var i = (int)source; diff --git a/src/NzbDrone.Core/Qualities/Quality.cs b/src/NzbDrone.Core/Qualities/Quality.cs index 6476e5766..d41a05d35 100644 --- a/src/NzbDrone.Core/Qualities/Quality.cs +++ b/src/NzbDrone.Core/Qualities/Quality.cs @@ -134,7 +134,7 @@ namespace NzbDrone.Core.Qualities var quality = AllLookup[id]; if (quality == null) - throw new ArgumentException("ID does not match a known quality", "id"); + throw new ArgumentException("ID does not match a known quality", nameof(id)); return quality; } diff --git a/src/NzbDrone.Core/RootFolders/RootFolderService.cs b/src/NzbDrone.Core/RootFolders/RootFolderService.cs index 851dddc8f..446b13670 100644 --- a/src/NzbDrone.Core/RootFolders/RootFolderService.cs +++ b/src/NzbDrone.Core/RootFolders/RootFolderService.cs @@ -132,7 +132,7 @@ namespace NzbDrone.Core.RootFolders { _logger.Debug("Generating list of unmapped folders"); if (string.IsNullOrEmpty(path)) - throw new ArgumentException("Invalid path provided", "path"); + throw new ArgumentException("Invalid path provided", nameof(path)); var results = new List(); var series = _seriesRepository.All().ToList(); diff --git a/src/NzbDrone.Core/Update/InstallUpdateService.cs b/src/NzbDrone.Core/Update/InstallUpdateService.cs index c4b345fcc..5ca1c31fb 100644 --- a/src/NzbDrone.Core/Update/InstallUpdateService.cs +++ b/src/NzbDrone.Core/Update/InstallUpdateService.cs @@ -50,7 +50,7 @@ namespace NzbDrone.Core.Update { if (configFileProvider == null) { - throw new ArgumentNullException("configFileProvider"); + throw new ArgumentNullException(nameof(configFileProvider)); } _checkUpdateService = checkUpdateService; _appFolderInfo = appFolderInfo; diff --git a/src/NzbDrone.Update/UpdateApp.cs b/src/NzbDrone.Update/UpdateApp.cs index 98e259c9d..eda4f17a5 100644 --- a/src/NzbDrone.Update/UpdateApp.cs +++ b/src/NzbDrone.Update/UpdateApp.cs @@ -62,7 +62,7 @@ namespace NzbDrone.Update { if (args == null || !args.Any()) { - throw new ArgumentOutOfRangeException("args", "args must be specified"); + throw new ArgumentOutOfRangeException(nameof(args), "args must be specified"); } var startupContext = new UpdateStartupContext @@ -101,7 +101,7 @@ namespace NzbDrone.Update int id; if (!int.TryParse(arg, out id) || id <= 0) { - throw new ArgumentOutOfRangeException("arg", "Invalid process ID"); + throw new ArgumentOutOfRangeException(nameof(arg), "Invalid process ID"); } Logger.Debug("NzbDrone process ID: {0}", id);