From 360827708fae3d50f40c2aff99192415e90170bb Mon Sep 17 00:00:00 2001 From: Bogdan Date: Tue, 23 May 2023 13:52:39 +0300 Subject: [PATCH] Use 'var' instead of explicit type (cherry picked from commit 12374f7f0038e5b25548f5ab3f71122410832393) --- .../AutomationTest.cs | 2 +- .../PageModel/PageBase.cs | 2 +- .../CacheTests/CachedFixture.cs | 10 +++---- .../ConfigFileProviderTest.cs | 10 +++---- .../DirectoryLookupServiceFixture.cs | 6 ++--- .../Http/HttpClientFixture.cs | 4 +-- src/NzbDrone.Common/ArchiveService.cs | 14 +++++----- src/NzbDrone.Common/Disk/OsPath.cs | 6 ++--- .../Extensions/DateTimeExtensions.cs | 4 +-- .../Extensions/IEnumerableExtensions.cs | 4 +-- .../Extensions/LevenstheinExtensions.cs | 8 +++--- .../Extensions/StringExtensions.cs | 4 +-- src/NzbDrone.Common/HashUtil.cs | 6 ++--- .../Http/Dispatchers/ManagedHttpDispatcher.cs | 2 +- src/NzbDrone.Common/Http/HttpUri.cs | 2 +- .../Http/Proxy/HttpProxySettings.cs | 2 +- .../Instrumentation/CleansingJsonVisitor.cs | 4 +-- .../Instrumentation/NzbDroneLogger.cs | 2 +- .../Serializer/Newtonsoft.Json/JsonVisitor.cs | 6 ++--- .../UnderscoreStringEnumConverter.cs | 4 +-- .../System.Text.Json/STJVersionConverter.cs | 2 +- .../LimitedConcurrencyLevelTaskScheduler.cs | 2 +- src/NzbDrone.Console/ConsoleApp.cs | 2 +- .../Datastore/BasicRepositoryFixture.cs | 2 +- src/NzbDrone.Core.Test/FluentTest.cs | 4 +-- .../IndexerTests/PTPTests/PTPFixture.cs | 2 +- .../DatabaseTargetFixture.cs | 2 +- .../Configuration/ConfigFileProvider.cs | 2 +- .../Datastore/BasicRepository.cs | 2 +- .../Datastore/Converters/CommandConverter.cs | 2 +- .../Migration/Framework/SqliteSchemaDumper.cs | 4 +-- .../Download/Clients/Deluge/DelugeProxy.cs | 2 +- .../FreeboxDownloadEncoding.cs | 6 ++--- .../Download/Clients/Nzbget/Nzbget.cs | 2 +- .../Clients/QBittorrent/QBittorrent.cs | 2 +- .../SabnzbdStringArrayConverter.cs | 2 +- .../Download/Extensions/XmlExtensions.cs | 4 +-- src/NzbDrone.Core/Fluent.cs | 10 +++---- .../IndexerStats/IndexerStatisticsService.cs | 2 +- .../IndexerDefinitionUpdateService.cs | 2 +- .../BroadcastheNet/BroadcastheNetParser.cs | 2 +- src/NzbDrone.Core/Indexers/HttpIndexerBase.cs | 2 +- .../Messaging/Commands/CommandExecutor.cs | 6 ++--- .../Messaging/Commands/CommandQueueManager.cs | 2 +- src/NzbDrone.Core/Parser/DateTimeUtil.cs | 2 +- .../Parser/RomanNumerals/RomanNumeral.cs | 10 +++---- .../RomanNumerals/RomanNumeralParser.cs | 26 +++++++++---------- src/NzbDrone.Core/Parser/StringUtil.cs | 4 +-- .../DiskProviderTests/DiskProviderFixture.cs | 2 +- .../ReleaseFileVersionAdapter.cs | 2 +- .../ConcurrencyCounter.cs | 2 +- .../ExceptionVerification.cs | 6 ++--- .../StartNzbDroneService.cs | 6 ++--- .../UpdateEngine/InstallUpdateService.cs | 2 +- .../DiskProviderTests/FreeSpaceFixture.cs | 4 +-- .../Logs/LogFileControllerBase.cs | 2 +- .../Profiles/App/AppProfileSchemaModule.cs | 2 +- .../ClientSchema/SchemaBuilder.cs | 2 +- .../Extensions/RequestExtensions.cs | 8 +++--- .../ServiceInstall/ServiceHelper.cs | 2 +- .../ServiceUninstall/ServiceHelper.cs | 2 +- 61 files changed, 128 insertions(+), 128 deletions(-) diff --git a/src/NzbDrone.Automation.Test/AutomationTest.cs b/src/NzbDrone.Automation.Test/AutomationTest.cs index 4253095b9..ae1bcc5e1 100644 --- a/src/NzbDrone.Automation.Test/AutomationTest.cs +++ b/src/NzbDrone.Automation.Test/AutomationTest.cs @@ -67,7 +67,7 @@ namespace NzbDrone.Automation.Test { try { - Screenshot image = ((ITakesScreenshot)driver).GetScreenshot(); + var image = ((ITakesScreenshot)driver).GetScreenshot(); image.SaveAsFile($"./{name}_test_screenshot.png", ScreenshotImageFormat.Png); } catch (Exception ex) diff --git a/src/NzbDrone.Automation.Test/PageModel/PageBase.cs b/src/NzbDrone.Automation.Test/PageModel/PageBase.cs index 4c9a17581..a32084602 100644 --- a/src/NzbDrone.Automation.Test/PageModel/PageBase.cs +++ b/src/NzbDrone.Automation.Test/PageModel/PageBase.cs @@ -36,7 +36,7 @@ namespace NzbDrone.Automation.Test.PageModel { try { - IWebElement element = d.FindElement(By.ClassName("followingBalls")); + var element = d.FindElement(By.ClassName("followingBalls")); return !element.Displayed; } catch (NoSuchElementException) diff --git a/src/NzbDrone.Common.Test/CacheTests/CachedFixture.cs b/src/NzbDrone.Common.Test/CacheTests/CachedFixture.cs index 7c892047d..bdbd45aca 100644 --- a/src/NzbDrone.Common.Test/CacheTests/CachedFixture.cs +++ b/src/NzbDrone.Common.Test/CacheTests/CachedFixture.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Threading; using FluentAssertions; using NUnit.Framework; @@ -65,9 +65,9 @@ namespace NzbDrone.Common.Test.CacheTests [Test] public void should_store_null() { - int hitCount = 0; + var hitCount = 0; - for (int i = 0; i < 10; i++) + for (var i = 0; i < 10; i++) { _cachedString.Get("key", () => { @@ -83,10 +83,10 @@ namespace NzbDrone.Common.Test.CacheTests [Platform(Exclude = "MacOsX")] public void should_honor_ttl() { - int hitCount = 0; + var hitCount = 0; _cachedString = new Cached(); - for (int i = 0; i < 10; i++) + for (var i = 0; i < 10; i++) { _cachedString.Get("key", () => diff --git a/src/NzbDrone.Common.Test/ConfigFileProviderTest.cs b/src/NzbDrone.Common.Test/ConfigFileProviderTest.cs index 91564beb3..dd32e187d 100644 --- a/src/NzbDrone.Common.Test/ConfigFileProviderTest.cs +++ b/src/NzbDrone.Common.Test/ConfigFileProviderTest.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using FluentAssertions; using Moq; using NUnit.Framework; @@ -142,7 +142,7 @@ namespace NzbDrone.Common.Test [Test] public void SaveDictionary_should_save_proper_value() { - int port = 20555; + var port = 20555; var dic = Subject.GetConfigDictionary(); dic["Port"] = 20555; @@ -155,9 +155,9 @@ namespace NzbDrone.Common.Test [Test] public void SaveDictionary_should_only_save_specified_values() { - int port = 20555; - int origSslPort = 20551; - int sslPort = 20552; + var port = 20555; + var origSslPort = 20551; + var sslPort = 20552; var dic = Subject.GetConfigDictionary(); dic["Port"] = port; diff --git a/src/NzbDrone.Common.Test/DiskTests/DirectoryLookupServiceFixture.cs b/src/NzbDrone.Common.Test/DiskTests/DirectoryLookupServiceFixture.cs index 78aa99f7d..1dc4256ee 100644 --- a/src/NzbDrone.Common.Test/DiskTests/DirectoryLookupServiceFixture.cs +++ b/src/NzbDrone.Common.Test/DiskTests/DirectoryLookupServiceFixture.cs @@ -42,7 +42,7 @@ namespace NzbDrone.Common.Test.DiskTests [Test] public void should_not_contain_recycling_bin_for_root_of_drive() { - string root = @"C:\".AsOsAgnostic(); + var root = @"C:\".AsOsAgnostic(); SetupFolders(root); Mocker.GetMock() @@ -55,7 +55,7 @@ namespace NzbDrone.Common.Test.DiskTests [Test] public void should_not_contain_system_volume_information() { - string root = @"C:\".AsOsAgnostic(); + var root = @"C:\".AsOsAgnostic(); SetupFolders(root); Mocker.GetMock() @@ -68,7 +68,7 @@ namespace NzbDrone.Common.Test.DiskTests [Test] public void should_not_contain_recycling_bin_or_system_volume_information_for_root_of_drive() { - string root = @"C:\".AsOsAgnostic(); + var root = @"C:\".AsOsAgnostic(); SetupFolders(root); Mocker.GetMock() diff --git a/src/NzbDrone.Common.Test/Http/HttpClientFixture.cs b/src/NzbDrone.Common.Test/Http/HttpClientFixture.cs index 9b48e77ca..4181057d6 100644 --- a/src/NzbDrone.Common.Test/Http/HttpClientFixture.cs +++ b/src/NzbDrone.Common.Test/Http/HttpClientFixture.cs @@ -788,7 +788,7 @@ namespace NzbDrone.Common.Test.Http try { // the date is bad in the below - should be 13-Jul-2026 - string malformedCookie = @"__cfduid=d29e686a9d65800021c66faca0a29b4261436890790; expires=Mon, 13-Jul-26 16:19:50 GMT; path=/; HttpOnly"; + var malformedCookie = @"__cfduid=d29e686a9d65800021c66faca0a29b4261436890790; expires=Mon, 13-Jul-26 16:19:50 GMT; path=/; HttpOnly"; var requestSet = new HttpRequestBuilder($"https://{_httpBinHost}/response-headers") .AddQueryParam("Set-Cookie", malformedCookie) .Build(); @@ -822,7 +822,7 @@ namespace NzbDrone.Common.Test.Http { try { - string url = $"https://{_httpBinHost}/response-headers?Set-Cookie={Uri.EscapeDataString(malformedCookie)}"; + var url = $"https://{_httpBinHost}/response-headers?Set-Cookie={Uri.EscapeDataString(malformedCookie)}"; var requestSet = new HttpRequest(url); requestSet.AllowAutoRedirect = false; diff --git a/src/NzbDrone.Common/ArchiveService.cs b/src/NzbDrone.Common/ArchiveService.cs index 2dee4d822..4cd6f6835 100644 --- a/src/NzbDrone.Common/ArchiveService.cs +++ b/src/NzbDrone.Common/ArchiveService.cs @@ -74,17 +74,17 @@ namespace NzbDrone.Common continue; // Ignore directories } - string entryFileName = zipEntry.Name; + var entryFileName = zipEntry.Name; // to remove the folder from the entry:- entryFileName = Path.GetFileName(entryFileName); // Optionally match entrynames against a selection list here to skip as desired. // The unpacked length is available in the zipEntry.Size property. - byte[] buffer = new byte[4096]; // 4K is optimum - Stream zipStream = zipFile.GetInputStream(zipEntry); + var buffer = new byte[4096]; // 4K is optimum + var zipStream = zipFile.GetInputStream(zipEntry); // Manipulate the output filename here as desired. - string fullZipToPath = Path.Combine(destination, entryFileName); - string directoryName = Path.GetDirectoryName(fullZipToPath); + var fullZipToPath = Path.Combine(destination, entryFileName); + var directoryName = Path.GetDirectoryName(fullZipToPath); if (directoryName.Length > 0) { Directory.CreateDirectory(directoryName); @@ -93,7 +93,7 @@ namespace NzbDrone.Common // Unzip file in buffered chunks. This is just as fast as unpacking to a buffer the full size // of the file, but does not waste memory. // The "using" will close the stream even if an exception occurs. - using (FileStream streamWriter = File.Create(fullZipToPath)) + using (var streamWriter = File.Create(fullZipToPath)) { StreamUtils.Copy(zipStream, streamWriter, buffer); } @@ -106,7 +106,7 @@ namespace NzbDrone.Common Stream inStream = File.OpenRead(compressedFile); Stream gzipStream = new GZipInputStream(inStream); - TarArchive tarArchive = TarArchive.CreateInputTarArchive(gzipStream, null); + var tarArchive = TarArchive.CreateInputTarArchive(gzipStream, null); tarArchive.ExtractContents(destination); tarArchive.Close(); diff --git a/src/NzbDrone.Common/Disk/OsPath.cs b/src/NzbDrone.Common/Disk/OsPath.cs index 8d8dcf2f9..f6f01fccf 100644 --- a/src/NzbDrone.Common/Disk/OsPath.cs +++ b/src/NzbDrone.Common/Disk/OsPath.cs @@ -255,7 +255,7 @@ namespace NzbDrone.Common.Disk var stringComparison = (Kind == OsPathKind.Windows || other.Kind == OsPathKind.Windows) ? StringComparison.InvariantCultureIgnoreCase : StringComparison.InvariantCulture; - for (int i = 0; i < leftFragments.Length; i++) + for (var i = 0; i < leftFragments.Length; i++) { if (!string.Equals(leftFragments[i], rightFragments[i], stringComparison)) { @@ -372,12 +372,12 @@ namespace NzbDrone.Common.Disk var newFragments = new List(); - for (int j = i; j < rightFragments.Length; j++) + for (var j = i; j < rightFragments.Length; j++) { newFragments.Add(".."); } - for (int j = i; j < leftFragments.Length; j++) + for (var j = i; j < leftFragments.Length; j++) { newFragments.Add(leftFragments[j]); } diff --git a/src/NzbDrone.Common/Extensions/DateTimeExtensions.cs b/src/NzbDrone.Common/Extensions/DateTimeExtensions.cs index 57f8aac71..69e2e5e17 100644 --- a/src/NzbDrone.Common/Extensions/DateTimeExtensions.cs +++ b/src/NzbDrone.Common/Extensions/DateTimeExtensions.cs @@ -36,14 +36,14 @@ namespace NzbDrone.Common.Extensions public static bool IsValidDate(this string dateTime) { - DateTime.TryParse(dateTime, out DateTime result); + DateTime.TryParse(dateTime, out var result); return !result.Equals(default(DateTime)); } public static bool IsFutureDate(this string dateTime) { - DateTime.TryParse(dateTime, out DateTime result); + DateTime.TryParse(dateTime, out var result); return !result.Equals(default(DateTime)) && result.After(DateTime.Now); } diff --git a/src/NzbDrone.Common/Extensions/IEnumerableExtensions.cs b/src/NzbDrone.Common/Extensions/IEnumerableExtensions.cs index d18e58e51..9e5385593 100644 --- a/src/NzbDrone.Common/Extensions/IEnumerableExtensions.cs +++ b/src/NzbDrone.Common/Extensions/IEnumerableExtensions.cs @@ -126,9 +126,9 @@ namespace NzbDrone.Common.Extensions private static IEnumerable InternalDropLast(IEnumerable source, int n) { - Queue buffer = new Queue(n + 1); + var buffer = new Queue(n + 1); - foreach (T x in source) + foreach (var x in source) { buffer.Enqueue(x); diff --git a/src/NzbDrone.Common/Extensions/LevenstheinExtensions.cs b/src/NzbDrone.Common/Extensions/LevenstheinExtensions.cs index 825525457..eb20ce7b0 100644 --- a/src/NzbDrone.Common/Extensions/LevenstheinExtensions.cs +++ b/src/NzbDrone.Common/Extensions/LevenstheinExtensions.cs @@ -21,7 +21,7 @@ namespace NzbDrone.Common.Extensions return text.Length * costDelete; } - int[] matrix = new int[other.Length + 1]; + var matrix = new int[other.Length + 1]; for (var i = 1; i < matrix.Length; i++) { @@ -30,13 +30,13 @@ namespace NzbDrone.Common.Extensions for (var i = 0; i < text.Length; i++) { - int topLeft = matrix[0]; + var topLeft = matrix[0]; matrix[0] = matrix[0] + costDelete; for (var j = 0; j < other.Length; j++) { - int top = matrix[j]; - int left = matrix[j + 1]; + var top = matrix[j]; + var left = matrix[j + 1]; var sumIns = top + costInsert; var sumDel = left + costDelete; diff --git a/src/NzbDrone.Common/Extensions/StringExtensions.cs b/src/NzbDrone.Common/Extensions/StringExtensions.cs index 495bfc6ac..b36f81c40 100644 --- a/src/NzbDrone.Common/Extensions/StringExtensions.cs +++ b/src/NzbDrone.Common/Extensions/StringExtensions.cs @@ -198,13 +198,13 @@ namespace NzbDrone.Common.Extensions public static string CleanFileName(this string name) { - string result = name; + var result = name; string[] badCharacters = { "\\", "/", "<", ">", "?", "*", ":", "|", "\"" }; string[] goodCharacters = { "+", "+", "", "", "!", "-", "-", "", "" }; result = result.Replace(": ", " - "); - for (int i = 0; i < badCharacters.Length; i++) + for (var i = 0; i < badCharacters.Length; i++) { result = result.Replace(badCharacters[i], goodCharacters[i]); } diff --git a/src/NzbDrone.Common/HashUtil.cs b/src/NzbDrone.Common/HashUtil.cs index 3c9144023..372b875a0 100644 --- a/src/NzbDrone.Common/HashUtil.cs +++ b/src/NzbDrone.Common/HashUtil.cs @@ -8,9 +8,9 @@ namespace NzbDrone.Common { public static string CalculateCrc(string input) { - uint mCrc = 0xffffffff; - byte[] bytes = Encoding.UTF8.GetBytes(input); - foreach (byte myByte in bytes) + var mCrc = 0xffffffff; + var bytes = Encoding.UTF8.GetBytes(input); + foreach (var myByte in bytes) { mCrc ^= (uint)myByte << 24; for (var i = 0; i < 8; i++) diff --git a/src/NzbDrone.Common/Http/Dispatchers/ManagedHttpDispatcher.cs b/src/NzbDrone.Common/Http/Dispatchers/ManagedHttpDispatcher.cs index 098e47288..1530c85e9 100644 --- a/src/NzbDrone.Common/Http/Dispatchers/ManagedHttpDispatcher.cs +++ b/src/NzbDrone.Common/Http/Dispatchers/ManagedHttpDispatcher.cs @@ -127,7 +127,7 @@ namespace NzbDrone.Common.Http.Dispatchers headers.Add(responseMessage.Content.Headers.ToNameValueCollection()); - CookieContainer responseCookies = new CookieContainer(); + var responseCookies = new CookieContainer(); if (responseMessage.Headers.TryGetValues("Set-Cookie", out var cookieHeaders)) { diff --git a/src/NzbDrone.Common/Http/HttpUri.cs b/src/NzbDrone.Common/Http/HttpUri.cs index 45d2b98b5..2277ed60d 100644 --- a/src/NzbDrone.Common/Http/HttpUri.cs +++ b/src/NzbDrone.Common/Http/HttpUri.cs @@ -22,7 +22,7 @@ namespace NzbDrone.Common.Http public HttpUri(string scheme, string host, int? port, string path, string query, string fragment) { - StringBuilder builder = new StringBuilder(); + var builder = new StringBuilder(); if (scheme.IsNotNullOrWhiteSpace()) { diff --git a/src/NzbDrone.Common/Http/Proxy/HttpProxySettings.cs b/src/NzbDrone.Common/Http/Proxy/HttpProxySettings.cs index ef59c9c0f..022d8adee 100644 --- a/src/NzbDrone.Common/Http/Proxy/HttpProxySettings.cs +++ b/src/NzbDrone.Common/Http/Proxy/HttpProxySettings.cs @@ -31,7 +31,7 @@ namespace NzbDrone.Common.Http.Proxy if (!string.IsNullOrWhiteSpace(BypassFilter)) { var hostlist = BypassFilter.Split(','); - for (int i = 0; i < hostlist.Length; i++) + for (var i = 0; i < hostlist.Length; i++) { if (hostlist[i].StartsWith("*")) { diff --git a/src/NzbDrone.Common/Instrumentation/CleansingJsonVisitor.cs b/src/NzbDrone.Common/Instrumentation/CleansingJsonVisitor.cs index 1e32d399f..34df2dff3 100644 --- a/src/NzbDrone.Common/Instrumentation/CleansingJsonVisitor.cs +++ b/src/NzbDrone.Common/Instrumentation/CleansingJsonVisitor.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json.Linq; +using Newtonsoft.Json.Linq; using NzbDrone.Common.Serializer; namespace NzbDrone.Common.Instrumentation @@ -16,7 +16,7 @@ namespace NzbDrone.Common.Instrumentation } } - foreach (JToken token in json) + foreach (var token in json) { Visit(token); } diff --git a/src/NzbDrone.Common/Instrumentation/NzbDroneLogger.cs b/src/NzbDrone.Common/Instrumentation/NzbDroneLogger.cs index 7d8cfaf83..2493e35cf 100644 --- a/src/NzbDrone.Common/Instrumentation/NzbDroneLogger.cs +++ b/src/NzbDrone.Common/Instrumentation/NzbDroneLogger.cs @@ -94,7 +94,7 @@ namespace NzbDrone.Common.Instrumentation private static void RegisterDebugger() { - DebuggerTarget target = new DebuggerTarget(); + var target = new DebuggerTarget(); target.Name = "debuggerLogger"; target.Layout = "[${level}] [${threadid}] ${logger}: ${message} ${onexception:inner=${newline}${newline}[v${assembly-version}] ${exception:format=ToString}${newline}${exception:format=Data}${newline}}"; diff --git a/src/NzbDrone.Common/Serializer/Newtonsoft.Json/JsonVisitor.cs b/src/NzbDrone.Common/Serializer/Newtonsoft.Json/JsonVisitor.cs index 0e69a0ae0..093de5b99 100644 --- a/src/NzbDrone.Common/Serializer/Newtonsoft.Json/JsonVisitor.cs +++ b/src/NzbDrone.Common/Serializer/Newtonsoft.Json/JsonVisitor.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json.Linq; +using Newtonsoft.Json.Linq; namespace NzbDrone.Common.Serializer { @@ -60,7 +60,7 @@ namespace NzbDrone.Common.Serializer public virtual void Visit(JArray json) { - foreach (JToken token in json) + foreach (var token in json) { Visit(token); } @@ -72,7 +72,7 @@ namespace NzbDrone.Common.Serializer public virtual void Visit(JObject json) { - foreach (JProperty property in json.Properties()) + foreach (var property in json.Properties()) { Visit(property); } diff --git a/src/NzbDrone.Common/Serializer/Newtonsoft.Json/UnderscoreStringEnumConverter.cs b/src/NzbDrone.Common/Serializer/Newtonsoft.Json/UnderscoreStringEnumConverter.cs index 772f5640c..b202253b6 100644 --- a/src/NzbDrone.Common/Serializer/Newtonsoft.Json/UnderscoreStringEnumConverter.cs +++ b/src/NzbDrone.Common/Serializer/Newtonsoft.Json/UnderscoreStringEnumConverter.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Text; using Newtonsoft.Json; @@ -42,7 +42,7 @@ namespace NzbDrone.Common.Serializer var enumText = value.ToString(); var builder = new StringBuilder(enumText.Length + 4); builder.Append(char.ToLower(enumText[0])); - for (int i = 1; i < enumText.Length; i++) + for (var i = 1; i < enumText.Length; i++) { if (char.IsUpper(enumText[i])) { diff --git a/src/NzbDrone.Common/Serializer/System.Text.Json/STJVersionConverter.cs b/src/NzbDrone.Common/Serializer/System.Text.Json/STJVersionConverter.cs index 70ad492c3..6fd024f7d 100644 --- a/src/NzbDrone.Common/Serializer/System.Text.Json/STJVersionConverter.cs +++ b/src/NzbDrone.Common/Serializer/System.Text.Json/STJVersionConverter.cs @@ -18,7 +18,7 @@ namespace NzbDrone.Common.Serializer { try { - Version v = new Version(reader.GetString()); + var v = new Version(reader.GetString()); return v; } catch (Exception) diff --git a/src/NzbDrone.Common/TPL/LimitedConcurrencyLevelTaskScheduler.cs b/src/NzbDrone.Common/TPL/LimitedConcurrencyLevelTaskScheduler.cs index a6137486b..ba9d804d3 100644 --- a/src/NzbDrone.Common/TPL/LimitedConcurrencyLevelTaskScheduler.cs +++ b/src/NzbDrone.Common/TPL/LimitedConcurrencyLevelTaskScheduler.cs @@ -137,7 +137,7 @@ namespace NzbDrone.Common.TPL /// An enumerable of the tasks currently scheduled. protected sealed override IEnumerable GetScheduledTasks() { - bool lockTaken = false; + var lockTaken = false; try { Monitor.TryEnter(_tasks, ref lockTaken); diff --git a/src/NzbDrone.Console/ConsoleApp.cs b/src/NzbDrone.Console/ConsoleApp.cs index cff2fd254..8f284d003 100644 --- a/src/NzbDrone.Console/ConsoleApp.cs +++ b/src/NzbDrone.Console/ConsoleApp.cs @@ -110,7 +110,7 @@ namespace NzbDrone.Console } System.Console.WriteLine("Non-recoverable failure, waiting for user intervention..."); - for (int i = 0; i < 3600; i++) + for (var i = 0; i < 3600; i++) { System.Threading.Thread.Sleep(1000); if (!System.Console.IsInputRedirected && System.Console.KeyAvailable) diff --git a/src/NzbDrone.Core.Test/Datastore/BasicRepositoryFixture.cs b/src/NzbDrone.Core.Test/Datastore/BasicRepositoryFixture.cs index 9f0cf4b92..8070f9fda 100644 --- a/src/NzbDrone.Core.Test/Datastore/BasicRepositoryFixture.cs +++ b/src/NzbDrone.Core.Test/Datastore/BasicRepositoryFixture.cs @@ -197,7 +197,7 @@ namespace NzbDrone.Core.Test.Datastore Subject.SetFields(_basicList, x => x.Interval); - for (int i = 0; i < _basicList.Count; i++) + for (var i = 0; i < _basicList.Count; i++) { _basicList[i].LastExecution = executionBackup[i]; } diff --git a/src/NzbDrone.Core.Test/FluentTest.cs b/src/NzbDrone.Core.Test/FluentTest.cs index a17f142e3..1747c44f2 100644 --- a/src/NzbDrone.Core.Test/FluentTest.cs +++ b/src/NzbDrone.Core.Test/FluentTest.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Text; using FluentAssertions; @@ -57,7 +57,7 @@ namespace NzbDrone.Core.Test [Test] public void ToBestDateTime_DayOfWeek() { - for (int i = 2; i < 7; i++) + for (var i = 2; i < 7; i++) { var dateTime = DateTime.Today.AddDays(i); diff --git a/src/NzbDrone.Core.Test/IndexerTests/PTPTests/PTPFixture.cs b/src/NzbDrone.Core.Test/IndexerTests/PTPTests/PTPFixture.cs index c27972e0f..307585d29 100644 --- a/src/NzbDrone.Core.Test/IndexerTests/PTPTests/PTPFixture.cs +++ b/src/NzbDrone.Core.Test/IndexerTests/PTPTests/PTPFixture.cs @@ -33,7 +33,7 @@ namespace NzbDrone.Core.Test.IndexerTests.PTPTests { var authResponse = new PassThePopcornAuthResponse { Result = "Ok" }; - System.IO.StringWriter authStream = new System.IO.StringWriter(); + var authStream = new System.IO.StringWriter(); Json.Serialize(authResponse, authStream); var responseJson = ReadAllText(fileName); diff --git a/src/NzbDrone.Core.Test/InstrumentationTests/DatabaseTargetFixture.cs b/src/NzbDrone.Core.Test/InstrumentationTests/DatabaseTargetFixture.cs index 705ebf767..738f4c2bc 100644 --- a/src/NzbDrone.Core.Test/InstrumentationTests/DatabaseTargetFixture.cs +++ b/src/NzbDrone.Core.Test/InstrumentationTests/DatabaseTargetFixture.cs @@ -47,7 +47,7 @@ namespace NzbDrone.Core.Test.InstrumentationTests public void write_long_log() { var message = string.Empty; - for (int i = 0; i < 100; i++) + for (var i = 0; i < 100; i++) { message += Guid.NewGuid(); } diff --git a/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs b/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs index 127a5325b..c2731e084 100644 --- a/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs +++ b/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs @@ -144,7 +144,7 @@ namespace NzbDrone.Core.Configuration { const string defaultValue = "*"; - string bindAddress = GetValue("BindAddress", defaultValue); + var bindAddress = GetValue("BindAddress", defaultValue); if (string.IsNullOrWhiteSpace(bindAddress)) { return defaultValue; diff --git a/src/NzbDrone.Core/Datastore/BasicRepository.cs b/src/NzbDrone.Core/Datastore/BasicRepository.cs index 659a69e7f..8e1b92b77 100644 --- a/src/NzbDrone.Core/Datastore/BasicRepository.cs +++ b/src/NzbDrone.Core/Datastore/BasicRepository.cs @@ -196,7 +196,7 @@ namespace NzbDrone.Core.Datastore using (var conn = _database.OpenConnection()) { - using (IDbTransaction tran = conn.BeginTransaction(IsolationLevel.ReadCommitted)) + using (var tran = conn.BeginTransaction(IsolationLevel.ReadCommitted)) { foreach (var model in models) { diff --git a/src/NzbDrone.Core/Datastore/Converters/CommandConverter.cs b/src/NzbDrone.Core/Datastore/Converters/CommandConverter.cs index e2f77c6f0..790464f3f 100644 --- a/src/NzbDrone.Core/Datastore/Converters/CommandConverter.cs +++ b/src/NzbDrone.Core/Datastore/Converters/CommandConverter.cs @@ -18,7 +18,7 @@ namespace NzbDrone.Core.Datastore.Converters } string contract; - using (JsonDocument body = JsonDocument.Parse(stringValue)) + using (var body = JsonDocument.Parse(stringValue)) { contract = body.RootElement.GetProperty("name").GetString(); } diff --git a/src/NzbDrone.Core/Datastore/Migration/Framework/SqliteSchemaDumper.cs b/src/NzbDrone.Core/Datastore/Migration/Framework/SqliteSchemaDumper.cs index 4ae4e6e68..d0a661751 100644 --- a/src/NzbDrone.Core/Datastore/Migration/Framework/SqliteSchemaDumper.cs +++ b/src/NzbDrone.Core/Datastore/Migration/Framework/SqliteSchemaDumper.cs @@ -201,7 +201,7 @@ namespace NzbDrone.Core.Datastore.Migration.Framework public virtual IList ReadDbSchema() { - IList tables = ReadTables(); + var tables = ReadTables(); foreach (var table in tables) { table.Indexes = ReadIndexes(table.SchemaName, table.Name); @@ -264,7 +264,7 @@ namespace NzbDrone.Core.Datastore.Migration.Framework protected virtual IList ReadIndexes(string schemaName, string tableName) { var sqlCommand = string.Format(@"SELECT type, name, sql FROM sqlite_master WHERE tbl_name = '{0}' AND type = 'index' AND name NOT LIKE 'sqlite_auto%';", tableName); - DataTable table = Read(sqlCommand).Tables[0]; + var table = Read(sqlCommand).Tables[0]; IList indexes = new List(); diff --git a/src/NzbDrone.Core/Download/Clients/Deluge/DelugeProxy.cs b/src/NzbDrone.Core/Download/Clients/Deluge/DelugeProxy.cs index 6396052c3..77b3d1b3d 100644 --- a/src/NzbDrone.Core/Download/Clients/Deluge/DelugeProxy.cs +++ b/src/NzbDrone.Core/Download/Clients/Deluge/DelugeProxy.cs @@ -203,7 +203,7 @@ namespace NzbDrone.Core.Download.Clients.Deluge private JsonRpcRequestBuilder BuildRequest(DelugeSettings settings) { - string url = HttpRequestBuilder.BuildBaseUrl(settings.UseSsl, settings.Host, settings.Port, settings.UrlBase); + var url = HttpRequestBuilder.BuildBaseUrl(settings.UseSsl, settings.Host, settings.Port, settings.UrlBase); var requestBuilder = new JsonRpcRequestBuilder(url); requestBuilder.LogResponseContent = true; diff --git a/src/NzbDrone.Core/Download/Clients/FreeboxDownload/FreeboxDownloadEncoding.cs b/src/NzbDrone.Core/Download/Clients/FreeboxDownload/FreeboxDownloadEncoding.cs index 0e12570aa..7c1ef310b 100644 --- a/src/NzbDrone.Core/Download/Clients/FreeboxDownload/FreeboxDownloadEncoding.cs +++ b/src/NzbDrone.Core/Download/Clients/FreeboxDownload/FreeboxDownloadEncoding.cs @@ -1,4 +1,4 @@ -namespace NzbDrone.Core.Download.Clients.FreeboxDownload +namespace NzbDrone.Core.Download.Clients.FreeboxDownload { public static class EncodingForBase64 { @@ -9,7 +9,7 @@ return null; } - byte[] textAsBytes = System.Text.Encoding.UTF8.GetBytes(text); + var textAsBytes = System.Text.Encoding.UTF8.GetBytes(text); return System.Convert.ToBase64String(textAsBytes); } @@ -20,7 +20,7 @@ return null; } - byte[] textAsBytes = System.Convert.FromBase64String(encodedText); + var textAsBytes = System.Convert.FromBase64String(encodedText); return System.Text.Encoding.UTF8.GetString(textAsBytes); } } diff --git a/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs b/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs index 958b9efde..b286bf922 100644 --- a/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs +++ b/src/NzbDrone.Core/Download/Clients/Nzbget/Nzbget.cs @@ -70,7 +70,7 @@ namespace NzbDrone.Core.Download.Clients.Nzbget protected IEnumerable GetCategories(Dictionary config) { - for (int i = 1; i < 100; i++) + for (var i = 1; i < 100; i++) { var name = config.GetValueOrDefault("Category" + i + ".Name"); diff --git a/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs b/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs index 95dd9e30b..edc9b2fd4 100644 --- a/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs +++ b/src/NzbDrone.Core/Download/Clients/QBittorrent/QBittorrent.cs @@ -257,7 +257,7 @@ namespace NzbDrone.Core.Download.Clients.QBittorrent return null; } - Dictionary labels = Proxy.GetLabels(Settings); + var labels = Proxy.GetLabels(Settings); foreach (var category in Categories) { diff --git a/src/NzbDrone.Core/Download/Clients/Sabnzbd/JsonConverters/SabnzbdStringArrayConverter.cs b/src/NzbDrone.Core/Download/Clients/Sabnzbd/JsonConverters/SabnzbdStringArrayConverter.cs index bca2353a1..b5ab193ce 100644 --- a/src/NzbDrone.Core/Download/Clients/Sabnzbd/JsonConverters/SabnzbdStringArrayConverter.cs +++ b/src/NzbDrone.Core/Download/Clients/Sabnzbd/JsonConverters/SabnzbdStringArrayConverter.cs @@ -14,7 +14,7 @@ namespace NzbDrone.Core.Download.Clients.Sabnzbd.JsonConverters var stringArray = (string[])value; writer.WriteStartArray(); - for (int i = 0; i < stringArray.Length; i++) + for (var i = 0; i < stringArray.Length; i++) { writer.WriteValue(stringArray[i]); } diff --git a/src/NzbDrone.Core/Download/Extensions/XmlExtensions.cs b/src/NzbDrone.Core/Download/Extensions/XmlExtensions.cs index bce66c8bc..b4571d6e8 100644 --- a/src/NzbDrone.Core/Download/Extensions/XmlExtensions.cs +++ b/src/NzbDrone.Core/Download/Extensions/XmlExtensions.cs @@ -32,13 +32,13 @@ namespace NzbDrone.Core.Download.Extensions public static long ElementAsLong(this XElement element, XName name) { var el = element.Element(name); - return long.TryParse(el?.Value, out long value) ? value : default; + return long.TryParse(el?.Value, out var value) ? value : default; } public static int ElementAsInt(this XElement element, XName name) { var el = element.Element(name); - return int.TryParse(el?.Value, out int value) ? value : default(int); + return int.TryParse(el?.Value, out var value) ? value : default(int); } public static int GetIntResponse(this XDocument document) diff --git a/src/NzbDrone.Core/Fluent.cs b/src/NzbDrone.Core/Fluent.cs index cc507b242..37a775e96 100644 --- a/src/NzbDrone.Core/Fluent.cs +++ b/src/NzbDrone.Core/Fluent.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -95,17 +95,17 @@ namespace NzbDrone.Core } var cs = s.ToCharArray(); - int length = 0; - int i = 0; + var length = 0; + var i = 0; while (i < cs.Length) { - int charSize = 1; + var charSize = 1; if (i < (cs.Length - 1) && char.IsSurrogate(cs[i])) { charSize = 2; } - int byteSize = Encoding.UTF8.GetByteCount(cs, i, charSize); + var byteSize = Encoding.UTF8.GetByteCount(cs, i, charSize); if ((byteSize + length) <= maxLength) { i = i + charSize; diff --git a/src/NzbDrone.Core/IndexerStats/IndexerStatisticsService.cs b/src/NzbDrone.Core/IndexerStats/IndexerStatisticsService.cs index e0a9bace7..e5274bee7 100644 --- a/src/NzbDrone.Core/IndexerStats/IndexerStatisticsService.cs +++ b/src/NzbDrone.Core/IndexerStats/IndexerStatisticsService.cs @@ -54,7 +54,7 @@ namespace NzbDrone.Core.IndexerStats var sortedEvents = indexer.OrderBy(v => v.Date) .ThenBy(v => v.Id) .ToArray(); - int temp = 0; + var temp = 0; var elapsedTimeEvents = sortedEvents.Where(h => int.TryParse(h.Data.GetValueOrDefault("elapsedTime"), out temp)) .Select(h => temp); diff --git a/src/NzbDrone.Core/IndexerVersions/IndexerDefinitionUpdateService.cs b/src/NzbDrone.Core/IndexerVersions/IndexerDefinitionUpdateService.cs index 7f0c82811..6b2c4dc91 100644 --- a/src/NzbDrone.Core/IndexerVersions/IndexerDefinitionUpdateService.cs +++ b/src/NzbDrone.Core/IndexerVersions/IndexerDefinitionUpdateService.cs @@ -293,7 +293,7 @@ namespace NzbDrone.Core.IndexerVersions _httpClient.DownloadFile($"https://indexers.prowlarr.com/{DEFINITION_BRANCH}/{DEFINITION_VERSION}/package.zip", saveFile); - using (ZipArchive archive = ZipFile.OpenRead(saveFile)) + using (var archive = ZipFile.OpenRead(saveFile)) { archive.ExtractToDirectory(definitionsFolder, true); } diff --git a/src/NzbDrone.Core/Indexers/Definitions/BroadcastheNet/BroadcastheNetParser.cs b/src/NzbDrone.Core/Indexers/Definitions/BroadcastheNet/BroadcastheNetParser.cs index 242c51a27..d06bef210 100644 --- a/src/NzbDrone.Core/Indexers/Definitions/BroadcastheNet/BroadcastheNetParser.cs +++ b/src/NzbDrone.Core/Indexers/Definitions/BroadcastheNet/BroadcastheNetParser.cs @@ -60,7 +60,7 @@ namespace NzbDrone.Core.Indexers.BroadcastheNet throw new IndexerException(indexerResponse, "Indexer API returned an internal server error"); } - JsonRpcResponse jsonResponse = new HttpResponse>(indexerHttpResponse).Resource; + var jsonResponse = new HttpResponse>(indexerHttpResponse).Resource; if (jsonResponse.Error != null || jsonResponse.Result == null) { diff --git a/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs b/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs index bb0615fb2..81c6f396a 100644 --- a/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs +++ b/src/NzbDrone.Core/Indexers/HttpIndexerBase.cs @@ -276,7 +276,7 @@ namespace NzbDrone.Core.Indexers var pageableRequestChain = pageableRequestChainSelector(generator); - for (int i = 0; i < pageableRequestChain.Tiers; i++) + for (var i = 0; i < pageableRequestChain.Tiers; i++) { var pageableRequests = pageableRequestChain.GetTier(i); diff --git a/src/NzbDrone.Core/Messaging/Commands/CommandExecutor.cs b/src/NzbDrone.Core/Messaging/Commands/CommandExecutor.cs index 05b031a6a..45b3fd2e3 100644 --- a/src/NzbDrone.Core/Messaging/Commands/CommandExecutor.cs +++ b/src/NzbDrone.Core/Messaging/Commands/CommandExecutor.cs @@ -129,8 +129,8 @@ namespace NzbDrone.Core.Messaging.Commands _cancellationTokenSource = new CancellationTokenSource(); var envLimit = Environment.GetEnvironmentVariable("THREAD_LIMIT") ?? $"{THREAD_LIMIT}"; - int threadLimit = THREAD_LIMIT; - if (int.TryParse(envLimit, out int parsedLimit)) + var threadLimit = THREAD_LIMIT; + if (int.TryParse(envLimit, out var parsedLimit)) { threadLimit = parsedLimit; } @@ -140,7 +140,7 @@ namespace NzbDrone.Core.Messaging.Commands _logger.Info("Starting {} threads for tasks.", threadLimit); - for (int i = 0; i < threadLimit + 1; i++) + for (var i = 0; i < threadLimit + 1; i++) { var thread = new Thread(ExecuteCommands); thread.Start(); diff --git a/src/NzbDrone.Core/Messaging/Commands/CommandQueueManager.cs b/src/NzbDrone.Core/Messaging/Commands/CommandQueueManager.cs index 44edc9009..12ce4cb06 100644 --- a/src/NzbDrone.Core/Messaging/Commands/CommandQueueManager.cs +++ b/src/NzbDrone.Core/Messaging/Commands/CommandQueueManager.cs @@ -138,7 +138,7 @@ namespace NzbDrone.Core.Messaging.Commands public CommandModel Push(string commandName, DateTime? lastExecutionTime, DateTime? lastStartTime, CommandPriority priority = CommandPriority.Normal, CommandTrigger trigger = CommandTrigger.Unspecified) { - dynamic command = GetCommand(commandName); + var command = GetCommand(commandName); command.LastExecutionTime = lastExecutionTime; command.LastStartTime = lastStartTime; command.Trigger = trigger; diff --git a/src/NzbDrone.Core/Parser/DateTimeUtil.cs b/src/NzbDrone.Core/Parser/DateTimeUtil.cs index a69cbcd24..71f243c66 100644 --- a/src/NzbDrone.Core/Parser/DateTimeUtil.cs +++ b/src/NzbDrone.Core/Parser/DateTimeUtil.cs @@ -109,7 +109,7 @@ namespace NzbDrone.Core.Parser DateTimeRoutines.DateTimeFormat.USDate; if (DateTimeRoutines.TryParseDateOrTime( - str, dtFormat, out DateTimeRoutines.ParsedDateTime dt)) + str, dtFormat, out var dt)) { return dt.DateTime; } diff --git a/src/NzbDrone.Core/Parser/RomanNumerals/RomanNumeral.cs b/src/NzbDrone.Core/Parser/RomanNumerals/RomanNumeral.cs index ff3f03596..19795c643 100644 --- a/src/NzbDrone.Core/Parser/RomanNumerals/RomanNumeral.cs +++ b/src/NzbDrone.Core/Parser/RomanNumerals/RomanNumeral.cs @@ -95,9 +95,9 @@ namespace NzbDrone.Core.Parser.RomanNumerals } text = text.ToUpper(); - int len = 0; + var len = 0; - for (int i = 0; i < 3; i++) + for (var i = 0; i < 3; i++) { if (text.StartsWith(Thousands[i])) { @@ -113,7 +113,7 @@ namespace NzbDrone.Core.Parser.RomanNumerals len = 0; } - for (int i = 0; i < 9; i++) + for (var i = 0; i < 9; i++) { if (text.StartsWith(Hundreds[i])) { @@ -129,7 +129,7 @@ namespace NzbDrone.Core.Parser.RomanNumerals len = 0; } - for (int i = 0; i < 9; i++) + for (var i = 0; i < 9; i++) { if (text.StartsWith(Tens[i])) { @@ -145,7 +145,7 @@ namespace NzbDrone.Core.Parser.RomanNumerals len = 0; } - for (int i = 0; i < 9; i++) + for (var i = 0; i < 9; i++) { if (text.StartsWith(Units[i])) { diff --git a/src/NzbDrone.Core/Parser/RomanNumerals/RomanNumeralParser.cs b/src/NzbDrone.Core/Parser/RomanNumerals/RomanNumeralParser.cs index a898fc174..4ca73cf12 100644 --- a/src/NzbDrone.Core/Parser/RomanNumerals/RomanNumeralParser.cs +++ b/src/NzbDrone.Core/Parser/RomanNumerals/RomanNumeralParser.cs @@ -26,32 +26,32 @@ namespace NzbDrone.Core.Parser.RomanNumerals _arabicRomanNumeralsMapping = new HashSet(); _simpleArabicNumeralMappings = new Dictionary(); - foreach (int arabicNumeral in Enumerable.Range(1, DICTIONARY_PREPOPULATION_SIZE + 1)) + foreach (var arabicNumeral in Enumerable.Range(1, DICTIONARY_PREPOPULATION_SIZE + 1)) { GenerateRomanNumerals(arabicNumeral, out var romanNumeralAsString, out var arabicNumeralAsString); - ArabicRomanNumeral arm = new ArabicRomanNumeral(arabicNumeral, arabicNumeralAsString, romanNumeralAsString); + var arm = new ArabicRomanNumeral(arabicNumeral, arabicNumeralAsString, romanNumeralAsString); _arabicRomanNumeralsMapping.Add(arm); - SimpleArabicNumeral sam = new SimpleArabicNumeral(arabicNumeral); - SimpleRomanNumeral srm = new SimpleRomanNumeral(romanNumeralAsString); + var sam = new SimpleArabicNumeral(arabicNumeral); + var srm = new SimpleRomanNumeral(romanNumeralAsString); _simpleArabicNumeralMappings.Add(sam, srm); } } private static void GenerateRomanNumerals(int arabicNumeral, out string romanNumeral, out string arabicNumeralAsString) { - RomanNumeral romanNumeralObject = new RomanNumeral(arabicNumeral); + var romanNumeralObject = new RomanNumeral(arabicNumeral); romanNumeral = romanNumeralObject.ToRomanNumeral(); arabicNumeralAsString = Convert.ToString(arabicNumeral); } private static HashSet GenerateAdditionalMappings(int offset, int length) { - HashSet additionalArabicRomanNumerals = new HashSet(); - foreach (int arabicNumeral in Enumerable.Range(offset, length)) + var additionalArabicRomanNumerals = new HashSet(); + foreach (var arabicNumeral in Enumerable.Range(offset, length)) { GenerateRomanNumerals(arabicNumeral, out var romanNumeral, out var arabicNumeralAsString); - ArabicRomanNumeral arm = new ArabicRomanNumeral(arabicNumeral, arabicNumeralAsString, romanNumeral); + var arm = new ArabicRomanNumeral(arabicNumeral, arabicNumeralAsString, romanNumeral); additionalArabicRomanNumerals.Add(arm); } @@ -78,7 +78,7 @@ namespace NzbDrone.Core.Parser.RomanNumerals return new HashSet(_arabicRomanNumeralsMapping.Take(upToArabicNumber)); } - HashSet largerMapping = GenerateAdditionalMappings(DICTIONARY_PREPOPULATION_SIZE + 1, upToArabicNumber); + var largerMapping = GenerateAdditionalMappings(DICTIONARY_PREPOPULATION_SIZE + 1, upToArabicNumber); _arabicRomanNumeralsMapping = (HashSet)_arabicRomanNumeralsMapping.Union(largerMapping); } @@ -123,12 +123,12 @@ namespace NzbDrone.Core.Parser.RomanNumerals private static Dictionary GenerateAdditionalSimpleNumerals(int offset, int length) { - Dictionary moreNumerals = new Dictionary(); - foreach (int arabicNumeral in Enumerable.Range(offset, length)) + var moreNumerals = new Dictionary(); + foreach (var arabicNumeral in Enumerable.Range(offset, length)) { GenerateRomanNumerals(arabicNumeral, out var romanNumeral, out _); - SimpleArabicNumeral san = new SimpleArabicNumeral(arabicNumeral); - SimpleRomanNumeral srn = new SimpleRomanNumeral(romanNumeral); + var san = new SimpleArabicNumeral(arabicNumeral); + var srn = new SimpleRomanNumeral(romanNumeral); moreNumerals.Add(san, srn); } diff --git a/src/NzbDrone.Core/Parser/StringUtil.cs b/src/NzbDrone.Core/Parser/StringUtil.cs index cb30cff06..7fb5fab65 100644 --- a/src/NzbDrone.Core/Parser/StringUtil.cs +++ b/src/NzbDrone.Core/Parser/StringUtil.cs @@ -20,7 +20,7 @@ namespace NzbDrone.Core.Parser public static string CleanFileName(string name, bool replace = true) { - string result = name; + var result = name; string[] badCharacters = { "\\", "/", "<", ">", "?", "*", ":", "|", "\"" }; string[] goodCharacters = { "+", "+", "", "", "!", "-", "-", "", "" }; @@ -30,7 +30,7 @@ namespace NzbDrone.Core.Parser result = result.Replace(": ", " - "); } - for (int i = 0; i < badCharacters.Length; i++) + for (var i = 0; i < badCharacters.Length; i++) { result = result.Replace(badCharacters[i], replace ? goodCharacters[i] : string.Empty); } diff --git a/src/NzbDrone.Mono.Test/DiskProviderTests/DiskProviderFixture.cs b/src/NzbDrone.Mono.Test/DiskProviderTests/DiskProviderFixture.cs index 25a02fd43..a09a68a98 100644 --- a/src/NzbDrone.Mono.Test/DiskProviderTests/DiskProviderFixture.cs +++ b/src/NzbDrone.Mono.Test/DiskProviderTests/DiskProviderFixture.cs @@ -58,7 +58,7 @@ namespace NzbDrone.Mono.Test.DiskProviderTests { // Remove Write permissions, we're still owner so we can clean it up, but we'll have to do that explicitly. Syscall.stat(path, out var stat); - FilePermissions mode = stat.st_mode; + var mode = stat.st_mode; if (writable) { diff --git a/src/NzbDrone.Mono/EnvironmentInfo/VersionAdapters/ReleaseFileVersionAdapter.cs b/src/NzbDrone.Mono/EnvironmentInfo/VersionAdapters/ReleaseFileVersionAdapter.cs index 78dcceec6..9347176b2 100644 --- a/src/NzbDrone.Mono/EnvironmentInfo/VersionAdapters/ReleaseFileVersionAdapter.cs +++ b/src/NzbDrone.Mono/EnvironmentInfo/VersionAdapters/ReleaseFileVersionAdapter.cs @@ -28,7 +28,7 @@ namespace NzbDrone.Mono.EnvironmentInfo.VersionAdapters var fullName = ""; var version = ""; - bool success = false; + var success = false; foreach (var releaseFile in releaseFiles) { diff --git a/src/NzbDrone.Test.Common/ConcurrencyCounter.cs b/src/NzbDrone.Test.Common/ConcurrencyCounter.cs index f3c12023f..a6a07118b 100644 --- a/src/NzbDrone.Test.Common/ConcurrencyCounter.cs +++ b/src/NzbDrone.Test.Common/ConcurrencyCounter.cs @@ -27,7 +27,7 @@ namespace NzbDrone.Test.Common public int Start() { - int threadId = Environment.CurrentManagedThreadId; + var threadId = Environment.CurrentManagedThreadId; lock (_mutex) { _threads[threadId] = 1; diff --git a/src/NzbDrone.Test.Common/ExceptionVerification.cs b/src/NzbDrone.Test.Common/ExceptionVerification.cs index bcf417434..413769fd9 100644 --- a/src/NzbDrone.Test.Common/ExceptionVerification.cs +++ b/src/NzbDrone.Test.Common/ExceptionVerification.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Threading; @@ -44,10 +44,10 @@ namespace NzbDrone.Test.Common private static string GetLogsString(IEnumerable logs) { - string errors = ""; + var errors = ""; foreach (var log in logs) { - string exception = ""; + var exception = ""; if (log.Exception != null) { exception = string.Format("[{0}: {1}]", log.Exception.GetType(), log.Exception.Message); diff --git a/src/NzbDrone.Update.Test/StartNzbDroneService.cs b/src/NzbDrone.Update.Test/StartNzbDroneService.cs index ac59a5a1a..5d24080da 100644 --- a/src/NzbDrone.Update.Test/StartNzbDroneService.cs +++ b/src/NzbDrone.Update.Test/StartNzbDroneService.cs @@ -17,7 +17,7 @@ namespace NzbDrone.Update.Test [Test] public void should_start_service_if_app_type_was_serivce() { - string targetFolder = "c:\\Prowlarr\\".AsOsAgnostic(); + var targetFolder = "c:\\Prowlarr\\".AsOsAgnostic(); Subject.Start(AppType.Service, targetFolder); @@ -27,8 +27,8 @@ namespace NzbDrone.Update.Test [Test] public void should_start_console_if_app_type_was_service_but_start_failed_because_of_permissions() { - string targetFolder = "c:\\Prowlarr\\".AsOsAgnostic(); - string targetProcess = "c:\\Prowlarr\\Prowlarr.Console".AsOsAgnostic().ProcessNameToExe(); + var targetFolder = "c:\\Prowlarr\\".AsOsAgnostic(); + var targetProcess = "c:\\Prowlarr\\Prowlarr.Console".AsOsAgnostic().ProcessNameToExe(); Mocker.GetMock().Setup(c => c.Start(ServiceProvider.SERVICE_NAME)).Throws(new InvalidOperationException()); diff --git a/src/NzbDrone.Update/UpdateEngine/InstallUpdateService.cs b/src/NzbDrone.Update/UpdateEngine/InstallUpdateService.cs index 497f3a394..1b2f4d90d 100644 --- a/src/NzbDrone.Update/UpdateEngine/InstallUpdateService.cs +++ b/src/NzbDrone.Update/UpdateEngine/InstallUpdateService.cs @@ -152,7 +152,7 @@ namespace NzbDrone.Update.UpdateEngine _terminateNzbDrone.Terminate(processId); _logger.Info("Waiting for external auto-restart."); - for (int i = 0; i < 10; i++) + for (var i = 0; i < 10; i++) { System.Threading.Thread.Sleep(1000); diff --git a/src/NzbDrone.Windows.Test/DiskProviderTests/FreeSpaceFixture.cs b/src/NzbDrone.Windows.Test/DiskProviderTests/FreeSpaceFixture.cs index fdb0b0988..1cda90713 100644 --- a/src/NzbDrone.Windows.Test/DiskProviderTests/FreeSpaceFixture.cs +++ b/src/NzbDrone.Windows.Test/DiskProviderTests/FreeSpaceFixture.cs @@ -1,4 +1,4 @@ -using System.IO; +using System.IO; using FluentAssertions; using NUnit.Framework; using NzbDrone.Common.Test.DiskTests; @@ -19,7 +19,7 @@ namespace NzbDrone.Windows.Test.DiskProviderTests public void should_throw_if_drive_doesnt_exist() { // Find a drive that doesn't exist. - for (char driveletter = 'Z'; driveletter > 'D'; driveletter--) + for (var driveletter = 'Z'; driveletter > 'D'; driveletter--) { if (new DriveInfo(driveletter.ToString()).IsReady) { diff --git a/src/Prowlarr.Api.V1/Logs/LogFileControllerBase.cs b/src/Prowlarr.Api.V1/Logs/LogFileControllerBase.cs index a662a049c..b5414beb9 100644 --- a/src/Prowlarr.Api.V1/Logs/LogFileControllerBase.cs +++ b/src/Prowlarr.Api.V1/Logs/LogFileControllerBase.cs @@ -32,7 +32,7 @@ namespace Prowlarr.Api.V1.Logs var files = GetLogFiles().ToList(); - for (int i = 0; i < files.Count; i++) + for (var i = 0; i < files.Count; i++) { var file = files[i]; var filename = Path.GetFileName(file); diff --git a/src/Prowlarr.Api.V1/Profiles/App/AppProfileSchemaModule.cs b/src/Prowlarr.Api.V1/Profiles/App/AppProfileSchemaModule.cs index 9eafed370..9383d795f 100644 --- a/src/Prowlarr.Api.V1/Profiles/App/AppProfileSchemaModule.cs +++ b/src/Prowlarr.Api.V1/Profiles/App/AppProfileSchemaModule.cs @@ -17,7 +17,7 @@ namespace Prowlarr.Api.V1.Profiles.App [HttpGet] public AppProfileResource GetSchema() { - AppSyncProfile qualityProfile = _profileService.GetDefaultProfile(string.Empty); + var qualityProfile = _profileService.GetDefaultProfile(string.Empty); return qualityProfile.ToResource(); } diff --git a/src/Prowlarr.Http/ClientSchema/SchemaBuilder.cs b/src/Prowlarr.Http/ClientSchema/SchemaBuilder.cs index 698a7ffc8..3f36760af 100644 --- a/src/Prowlarr.Http/ClientSchema/SchemaBuilder.cs +++ b/src/Prowlarr.Http/ClientSchema/SchemaBuilder.cs @@ -72,7 +72,7 @@ namespace Prowlarr.Http.ClientSchema result = GetFieldMapping(type, "", v => v); // Renumber al the field Orders since nested settings will have dupe Orders. - for (int i = 0; i < result.Length; i++) + for (var i = 0; i < result.Length; i++) { result[i].Field.Order = i; } diff --git a/src/Prowlarr.Http/Extensions/RequestExtensions.cs b/src/Prowlarr.Http/Extensions/RequestExtensions.cs index 792c9a63b..bb7a0af5f 100644 --- a/src/Prowlarr.Http/Extensions/RequestExtensions.cs +++ b/src/Prowlarr.Http/Extensions/RequestExtensions.cs @@ -139,13 +139,13 @@ namespace Prowlarr.Http.Extensions public static string GetHostName(this HttpRequest request) { - string ip = request.GetRemoteIP(); + var ip = request.GetRemoteIP(); try { - IPAddress myIP = IPAddress.Parse(ip); - IPHostEntry getIPHost = Dns.GetHostEntry(myIP); - List compName = getIPHost.HostName.ToString().Split('.').ToList(); + var myIP = IPAddress.Parse(ip); + var getIPHost = Dns.GetHostEntry(myIP); + var compName = getIPHost.HostName.ToString().Split('.').ToList(); return compName.First(); } catch diff --git a/src/ServiceHelpers/ServiceInstall/ServiceHelper.cs b/src/ServiceHelpers/ServiceInstall/ServiceHelper.cs index 4c4901bc9..629d10b13 100644 --- a/src/ServiceHelpers/ServiceInstall/ServiceHelper.cs +++ b/src/ServiceHelpers/ServiceInstall/ServiceHelper.cs @@ -12,7 +12,7 @@ namespace ServiceInstall private static bool IsAnAdministrator() { - WindowsPrincipal principal = new WindowsPrincipal(WindowsIdentity.GetCurrent()); + var principal = new WindowsPrincipal(WindowsIdentity.GetCurrent()); return principal.IsInRole(WindowsBuiltInRole.Administrator); } diff --git a/src/ServiceHelpers/ServiceUninstall/ServiceHelper.cs b/src/ServiceHelpers/ServiceUninstall/ServiceHelper.cs index 01bb06d2b..28efd343f 100644 --- a/src/ServiceHelpers/ServiceUninstall/ServiceHelper.cs +++ b/src/ServiceHelpers/ServiceUninstall/ServiceHelper.cs @@ -12,7 +12,7 @@ namespace ServiceUninstall private static bool IsAnAdministrator() { - WindowsPrincipal principal = new WindowsPrincipal(WindowsIdentity.GetCurrent()); + var principal = new WindowsPrincipal(WindowsIdentity.GetCurrent()); return principal.IsInRole(WindowsBuiltInRole.Administrator); }