Use nameof
This commit is contained in:
parent
2e36d35815
commit
c13fff1358
|
@ -14,8 +14,8 @@ namespace NzbDrone.Common.Extensions
|
||||||
|
|
||||||
public static Dictionary<T1, T2> Merge<T1, T2>(this Dictionary<T1, T2> first, Dictionary<T1, T2> second)
|
public static Dictionary<T1, T2> Merge<T1, T2>(this Dictionary<T1, T2> first, Dictionary<T1, T2> second)
|
||||||
{
|
{
|
||||||
if (first == null) throw new ArgumentNullException("first");
|
if (first == null) throw new ArgumentNullException(nameof(first));
|
||||||
if (second == null) throw new ArgumentNullException("second");
|
if (second == null) throw new ArgumentNullException(nameof(second));
|
||||||
|
|
||||||
var merged = new Dictionary<T1, T2>();
|
var merged = new Dictionary<T1, T2>();
|
||||||
first.ToList().ForEach(kv => merged[kv.Key] = kv.Value);
|
first.ToList().ForEach(kv => merged[kv.Key] = kv.Value);
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace NzbDrone.Common.TPL
|
||||||
/// <param name="maxDegreeOfParallelism">The maximum degree of parallelism provided by this scheduler.</param>
|
/// <param name="maxDegreeOfParallelism">The maximum degree of parallelism provided by this scheduler.</param>
|
||||||
public LimitedConcurrencyLevelTaskScheduler(int maxDegreeOfParallelism)
|
public LimitedConcurrencyLevelTaskScheduler(int maxDegreeOfParallelism)
|
||||||
{
|
{
|
||||||
if (maxDegreeOfParallelism < 1) throw new ArgumentOutOfRangeException("maxDegreeOfParallelism");
|
if (maxDegreeOfParallelism < 1) throw new ArgumentOutOfRangeException(nameof(maxDegreeOfParallelism));
|
||||||
_maxDegreeOfParallelism = maxDegreeOfParallelism;
|
_maxDegreeOfParallelism = maxDegreeOfParallelism;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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)
|
public void should_allow_if_quality_is_defined_in_profile(Quality qualityType)
|
||||||
{
|
{
|
||||||
remoteEpisode.ParsedEpisodeInfo.Quality.Quality = qualityType;
|
remoteEpisode.ParsedEpisodeInfo.Quality.Quality = qualityType;
|
||||||
|
@ -54,7 +54,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||||
Subject.IsSatisfiedBy(remoteEpisode, null).Accepted.Should().BeTrue();
|
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)
|
public void should_not_allow_if_quality_is_not_defined_in_profile(Quality qualityType)
|
||||||
{
|
{
|
||||||
remoteEpisode.ParsedEpisodeInfo.Quality.Quality = qualityType;
|
remoteEpisode.ParsedEpisodeInfo.Quality.Quality = qualityType;
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace NzbDrone.Core.Test.DecisionEngineTests
|
||||||
.Returns(autoDownloadPropers);
|
.Returns(autoDownloadPropers);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test, TestCaseSource("IsUpgradeTestCases")]
|
[Test, TestCaseSource(nameof(IsUpgradeTestCases))]
|
||||||
public void IsUpgradeTest(Quality current, int currentVersion, Quality newQuality, int newVersion, Quality cutoff, bool expected)
|
public void IsUpgradeTest(Quality current, int currentVersion, Quality newQuality, int newVersion, Quality cutoff, bool expected)
|
||||||
{
|
{
|
||||||
GivenAutoDownloadPropers(true);
|
GivenAutoDownloadPropers(true);
|
||||||
|
|
|
@ -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)
|
public void should_properly_parse_hashed_releases(string path, string title, Quality quality, string releaseGroup)
|
||||||
{
|
{
|
||||||
var result = Parser.Parser.ParsePath(path);
|
var result = Parser.Parser.ParsePath(path);
|
||||||
|
|
|
@ -238,7 +238,7 @@ namespace NzbDrone.Core.Test.ParserTests
|
||||||
ParseAndVerifyQuality(title, Quality.Unknown, proper);
|
ParseAndVerifyQuality(title, Quality.Unknown, proper);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test, TestCaseSource("SelfQualityParserCases")]
|
[Test, TestCaseSource(nameof(SelfQualityParserCases))]
|
||||||
public void parsing_our_own_quality_enum_name(Quality quality)
|
public void parsing_our_own_quality_enum_name(Quality quality)
|
||||||
{
|
{
|
||||||
var fileName = string.Format("My series S01E01 [{0}]", quality.Name);
|
var fileName = string.Format("My series S01E01 [{0}]", quality.Name);
|
||||||
|
@ -246,7 +246,7 @@ namespace NzbDrone.Core.Test.ParserTests
|
||||||
result.Quality.Should().Be(quality);
|
result.Quality.Should().Be(quality);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test, TestCaseSource("OtherSourceQualityParserCases")]
|
[Test, TestCaseSource(nameof(OtherSourceQualityParserCases))]
|
||||||
public void should_parse_quality_from_other_source(string qualityString, Quality quality)
|
public void should_parse_quality_from_other_source(string qualityString, Quality quality)
|
||||||
{
|
{
|
||||||
foreach (var c in new char[] { '-', '.', ' ', '_' })
|
foreach (var c in new char[] { '-', '.', ' ', '_' })
|
||||||
|
|
|
@ -47,14 +47,14 @@ namespace NzbDrone.Core.Test.Qualities
|
||||||
new object[] {Quality.Bluray2160p, 19},
|
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)
|
public void should_be_able_to_convert_int_to_qualityTypes(int source, Quality expected)
|
||||||
{
|
{
|
||||||
var quality = (Quality)source;
|
var quality = (Quality)source;
|
||||||
quality.Should().Be(expected);
|
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)
|
public void should_be_able_to_convert_qualityTypes_to_int(Quality source, int expected)
|
||||||
{
|
{
|
||||||
var i = (int)source;
|
var i = (int)source;
|
||||||
|
|
|
@ -134,7 +134,7 @@ namespace NzbDrone.Core.Qualities
|
||||||
var quality = AllLookup[id];
|
var quality = AllLookup[id];
|
||||||
|
|
||||||
if (quality == null)
|
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;
|
return quality;
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,7 +132,7 @@ namespace NzbDrone.Core.RootFolders
|
||||||
{
|
{
|
||||||
_logger.Debug("Generating list of unmapped folders");
|
_logger.Debug("Generating list of unmapped folders");
|
||||||
if (string.IsNullOrEmpty(path))
|
if (string.IsNullOrEmpty(path))
|
||||||
throw new ArgumentException("Invalid path provided", "path");
|
throw new ArgumentException("Invalid path provided", nameof(path));
|
||||||
|
|
||||||
var results = new List<UnmappedFolder>();
|
var results = new List<UnmappedFolder>();
|
||||||
var series = _seriesRepository.All().ToList();
|
var series = _seriesRepository.All().ToList();
|
||||||
|
|
|
@ -50,7 +50,7 @@ namespace NzbDrone.Core.Update
|
||||||
{
|
{
|
||||||
if (configFileProvider == null)
|
if (configFileProvider == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("configFileProvider");
|
throw new ArgumentNullException(nameof(configFileProvider));
|
||||||
}
|
}
|
||||||
_checkUpdateService = checkUpdateService;
|
_checkUpdateService = checkUpdateService;
|
||||||
_appFolderInfo = appFolderInfo;
|
_appFolderInfo = appFolderInfo;
|
||||||
|
|
|
@ -62,7 +62,7 @@ namespace NzbDrone.Update
|
||||||
{
|
{
|
||||||
if (args == null || !args.Any())
|
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
|
var startupContext = new UpdateStartupContext
|
||||||
|
@ -101,7 +101,7 @@ namespace NzbDrone.Update
|
||||||
int id;
|
int id;
|
||||||
if (!int.TryParse(arg, out id) || id <= 0)
|
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);
|
Logger.Debug("NzbDrone process ID: {0}", id);
|
||||||
|
|
Loading…
Reference in New Issue