From 49dd7cf12cda891c6e18272f81b221398ccc45c8 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sat, 4 Sep 2021 12:13:33 +0200 Subject: [PATCH] EditorConfig: Specifing naming of privates w/ prefix --- .editorconfig | 11 +++++++++- Directory.Build.props | 3 ++- Kyoo.Abstractions/Controllers/IRepository.cs | 3 ++- .../Controllers/IThumbnailsManager.cs | 3 +-- Kyoo.Abstractions/Models/Resources/Episode.cs | 6 ++++-- Kyoo.Abstractions/Models/Resources/Track.cs | 6 +++--- Kyoo.Core/Application.cs | 20 ++++++++++--------- .../Properties/launchSettings.json | 20 +++++++++++++++++++ Kyoo.ruleset | 3 ++- tests/Kyoo.Tests/Utility/MergerTests.cs | 14 ++++--------- 10 files changed, 59 insertions(+), 30 deletions(-) create mode 100644 Kyoo.Host.Console/Properties/launchSettings.json diff --git a/.editorconfig b/.editorconfig index 1f3fbd2d..5f04c144 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,7 +1,7 @@ root = true [*] -charset = utf-8-bom +charset = us-ascii end_of_line = lf trim_trailing_whitespace = true insert_final_newline = true @@ -66,6 +66,15 @@ csharp_indent_switch_labels = true dotnet_style_readonly_field = true:suggestion csharp_preferred_modifier_order = public, private, protected, internal, new, abstract, virtual, sealed, override, static, readonly, extern, unsafe, volatile, async:suggestion dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion +# Naming style +dotnet_naming_symbols.privates.applicable_kinds = property,method,event,delegate +dotnet_naming_symbols.privates.applicable_accessibilities = private +dotnet_naming_style.underscore_pascal.capitalization = pascal_case +dotnet_naming_style.underscore_pascal.required_prefix = _ +dotnet_naming_rule.privates_with_underscore.symbols = privates +dotnet_naming_rule.privates_with_underscore.style = underscore_pascal +dotnet_naming_rule.privates_with_underscore.severity = warning +dotnet_diagnostic.IDE1006.severity = warning # ReSharper properties resharper_align_multiline_binary_expressions_chain = false resharper_csharp_empty_block_style = together_same_line diff --git a/Directory.Build.props b/Directory.Build.props index 5b03be84..69756f48 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,4 +1,4 @@ - + true true @@ -14,6 +14,7 @@ + true $(MSBuildThisFileDirectory)Kyoo.ruleset diff --git a/Kyoo.Abstractions/Controllers/IRepository.cs b/Kyoo.Abstractions/Controllers/IRepository.cs index 2898e9a9..eca3caca 100644 --- a/Kyoo.Abstractions/Controllers/IRepository.cs +++ b/Kyoo.Abstractions/Controllers/IRepository.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq.Expressions; using System.Runtime.InteropServices; @@ -134,6 +134,7 @@ namespace Kyoo.Abstractions.Controllers /// The resource found [ItemNotNull] Task Get(int id); + /// /// Get a resource from it's slug. /// diff --git a/Kyoo.Abstractions/Controllers/IThumbnailsManager.cs b/Kyoo.Abstractions/Controllers/IThumbnailsManager.cs index 51fd8a85..f7b24a35 100644 --- a/Kyoo.Abstractions/Controllers/IThumbnailsManager.cs +++ b/Kyoo.Abstractions/Controllers/IThumbnailsManager.cs @@ -1,4 +1,4 @@ -using System.Threading.Tasks; +using System.Threading.Tasks; using JetBrains.Annotations; using Kyoo.Abstractions.Models; @@ -24,7 +24,6 @@ namespace Kyoo.Abstractions.Controllers Task DownloadImages([NotNull] T item, bool alwaysDownload = false) where T : IThumbnails; - /// /// Retrieve the local path of an image of the given item. /// diff --git a/Kyoo.Abstractions/Models/Resources/Episode.cs b/Kyoo.Abstractions/Models/Resources/Episode.cs index b2d95a45..11af8263 100644 --- a/Kyoo.Abstractions/Models/Resources/Episode.cs +++ b/Kyoo.Abstractions/Models/Resources/Episode.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Text.RegularExpressions; using JetBrains.Annotations; @@ -26,6 +26,7 @@ namespace Kyoo.Abstractions.Models ? GetSlug(ShowID.ToString(), SeasonNumber, EpisodeNumber, AbsoluteNumber) : null; } + [UsedImplicitly] [NotNull] private set { if (value == null) @@ -64,6 +65,7 @@ namespace Kyoo.Abstractions.Models /// The ID of the Show containing this episode. /// [SerializeIgnore] public int ShowID { get; set; } + /// /// The show that contains this episode. This must be explicitly loaded via a call to . /// @@ -73,6 +75,7 @@ namespace Kyoo.Abstractions.Models /// The ID of the Season containing this episode. /// [SerializeIgnore] public int? SeasonID { get; set; } + /// /// The season that contains this episode. /// This must be explicitly loaded via a call to . @@ -138,7 +141,6 @@ namespace Kyoo.Abstractions.Models /// [EditableRelation] [LoadableRelation] public ICollection Tracks { get; set; } - /// /// Get the slug of an episode. /// diff --git a/Kyoo.Abstractions/Models/Resources/Track.cs b/Kyoo.Abstractions/Models/Resources/Track.cs index 64f499bd..280f40e9 100644 --- a/Kyoo.Abstractions/Models/Resources/Track.cs +++ b/Kyoo.Abstractions/Models/Resources/Track.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Globalization; using System.Linq; using System.Text.RegularExpressions; @@ -149,7 +149,7 @@ namespace Kyoo.Abstractions.Models { get { - string language = GetLanguage(Language); + string language = _GetLanguage(Language); if (language == null) return $"Unknown (index: {TrackIndex})"; @@ -167,7 +167,7 @@ namespace Kyoo.Abstractions.Models } // Converting mkv track language to c# system language tag. - private static string GetLanguage(string mkvLanguage) + private static string _GetLanguage(string mkvLanguage) { // TODO delete this and have a real way to get the language string from the ISO-639-2. return mkvLanguage switch diff --git a/Kyoo.Core/Application.cs b/Kyoo.Core/Application.cs index ff3f1c1e..5f4895d0 100644 --- a/Kyoo.Core/Application.cs +++ b/Kyoo.Core/Application.cs @@ -21,8 +21,18 @@ using ILogger = Serilog.ILogger; namespace Kyoo.Core { + /// + /// The main implementation of . + /// Hosts of kyoo (main functions) generally only create a new + /// and return . + /// public class Application : IApplication { + /// + /// The environment in witch Kyoo will run (ether "Production" or "Development"). + /// + private readonly string _environment; + /// /// The path to the data directory. /// @@ -38,17 +48,11 @@ namespace Kyoo.Core /// private CancellationTokenSource _tokenSource; - /// - /// The environment in witch Kyoo will run (ether "Production" or "Development"). - /// - private readonly string _environment; - /// /// The logger used for startup and error messages. /// private ILogger _logger; - /// /// Create a new that will use the specified environment. /// @@ -58,7 +62,6 @@ namespace Kyoo.Core _environment = environment; } - /// /// Start the application with the given console args. /// This is generally called from the Main entrypoint of Kyoo. @@ -122,7 +125,6 @@ namespace Kyoo.Core return _dataDir; } - /// public string GetConfigFile() { @@ -132,7 +134,7 @@ namespace Kyoo.Core /// /// Parse the data directory from environment variables and command line arguments, create it if necessary. /// Set the current directory to said data folder and place a default configuration file if it does not already - /// exists. + /// exists. /// /// The command line arguments /// The current data directory. diff --git a/Kyoo.Host.Console/Properties/launchSettings.json b/Kyoo.Host.Console/Properties/launchSettings.json new file mode 100644 index 00000000..4f354cee --- /dev/null +++ b/Kyoo.Host.Console/Properties/launchSettings.json @@ -0,0 +1,20 @@ +{ + "profiles": { + "Console Host": { + "commandName": "Project", + "launchBrowser": false, + "environmentVariables": { + "KYOO_DATADIR": "./bin/KyooData" + }, + "applicationUrl": "http://localhost:5000" + }, + "Console Host (Browser)": { + "commandName": "Project", + "launchBrowser": true, + "environmentVariables": { + "KYOO_DATADIR": "./bin/KyooData" + }, + "applicationUrl": "http://localhost:5000" + } + } +} diff --git a/Kyoo.ruleset b/Kyoo.ruleset index a4415374..7fafbc2b 100644 --- a/Kyoo.ruleset +++ b/Kyoo.ruleset @@ -1,4 +1,4 @@ - + @@ -10,6 +10,7 @@ + diff --git a/tests/Kyoo.Tests/Utility/MergerTests.cs b/tests/Kyoo.Tests/Utility/MergerTests.cs index 598b2593..9d2bd39d 100644 --- a/tests/Kyoo.Tests/Utility/MergerTests.cs +++ b/tests/Kyoo.Tests/Utility/MergerTests.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; @@ -229,10 +229,7 @@ namespace Kyoo.Tests.Utility public void MergeListTest() { int[] first = { 1 }; - int[] second = { - 3, - 3 - }; + int[] second = { 3, 3 }; int[] ret = Merger.MergeLists(first, second); Assert.Equal(3, ret.Length); @@ -263,10 +260,7 @@ namespace Kyoo.Tests.Utility public void MergeListDuplicateCustomEqualityTest() { int[] first = { 1 }; - int[] second = { - 3, - 2 - }; + int[] second = { 3, 2 }; int[] ret = Merger.MergeLists(first, second, (x, y) => x % 2 == y % 2); Assert.Equal(2, ret.Length); @@ -538,4 +532,4 @@ namespace Kyoo.Tests.Utility Assert.Equal("logo", ret[Images.Logo]); } } -} \ No newline at end of file +}