From 2445823c5af39bffb1667c873c1a96b1289189bc Mon Sep 17 00:00:00 2001 From: Cody Robibero Date: Mon, 13 Dec 2021 16:58:05 -0700 Subject: [PATCH 1/2] update editorconfig, add analyzers --- .editorconfig | 7 +- .gitignore | 2 + .../Configuration/PluginConfiguration.cs | 75 +++++++++++++------ .../Jellyfin.Plugin.Template.csproj | 10 ++- Jellyfin.Plugin.Template/Plugin.cs | 55 +++++++++----- 5 files changed, 99 insertions(+), 50 deletions(-) diff --git a/.editorconfig b/.editorconfig index b87ad18..b84e563 100644 --- a/.editorconfig +++ b/.editorconfig @@ -5,7 +5,6 @@ # Core EditorConfig Options # ############################### root = true - # All files [*] indent_style = space @@ -14,7 +13,7 @@ charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true end_of_line = lf -max_line_length = 9999 +max_line_length = off # YAML indentation [*.{yml,yaml}] @@ -27,7 +26,6 @@ indent_size = 2 ############################### # .NET Coding Conventions # ############################### - [*.{cs,vb}] # Organize usings dotnet_sort_system_directives_first = true @@ -63,7 +61,6 @@ dotnet_style_prefer_conditional_expression_over_return = true:silent ############################### # Naming Conventions # ############################### - # Style Definitions (From Roslyn) # Non-private static fields are PascalCase @@ -138,7 +135,6 @@ dotnet_naming_style.pascal_case_style.capitalization = pascal_case ############################### # C# Coding Conventions # ############################### - [*.cs] # var preferences csharp_style_var_for_built_in_types = true:silent @@ -169,7 +165,6 @@ csharp_style_inlined_variable_declaration = true:suggestion ############################### # C# Formatting Rules # ############################### - # New line preferences csharp_new_line_before_open_brace = all csharp_new_line_before_else = true diff --git a/.gitignore b/.gitignore index 03c9b93..0b72c24 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ bin/ obj/ .vs/ +.idea/ +artifacts diff --git a/Jellyfin.Plugin.Template/Configuration/PluginConfiguration.cs b/Jellyfin.Plugin.Template/Configuration/PluginConfiguration.cs index 5ea6277..564e6bf 100644 --- a/Jellyfin.Plugin.Template/Configuration/PluginConfiguration.cs +++ b/Jellyfin.Plugin.Template/Configuration/PluginConfiguration.cs @@ -1,28 +1,57 @@ using MediaBrowser.Model.Plugins; -namespace Jellyfin.Plugin.Template.Configuration +namespace Jellyfin.Plugin.Template.Configuration; + +/// +/// The configuration options. +/// +public enum SomeOptions { - public enum SomeOptions - { - OneOption, - AnotherOption - } + /// + /// Option one. + /// + OneOption, - public class PluginConfiguration : BasePluginConfiguration - { - // store configurable settings your plugin might need - public bool TrueFalseSetting { get; set; } - public int AnInteger { get; set; } - public string AString { get; set; } - public SomeOptions Options { get; set; } - - public PluginConfiguration() - { - // set default options here - Options = SomeOptions.AnotherOption; - TrueFalseSetting = true; - AnInteger = 2; - AString = "string"; - } - } + /// + /// Second option. + /// + AnotherOption +} + +/// +/// Plugin configuration. +/// +public class PluginConfiguration : BasePluginConfiguration +{ + /// + /// Initializes a new instance of the class. + /// + public PluginConfiguration() + { + // set default options here + Options = SomeOptions.AnotherOption; + TrueFalseSetting = true; + AnInteger = 2; + AString = "string"; + } + + /// + /// Gets or sets a value indicating whether some true or false setting is enabled.. + /// + public bool TrueFalseSetting { get; set; } + + /// + /// Gets or sets an integer setting. + /// + public int AnInteger { get; set; } + + /// + /// Gets or sets a string setting. + /// + public string AString { get; set; } + + /// + /// Gets or sets an enum option. + /// + public SomeOptions Options { get; set; } } diff --git a/Jellyfin.Plugin.Template/Jellyfin.Plugin.Template.csproj b/Jellyfin.Plugin.Template/Jellyfin.Plugin.Template.csproj index 5e75639..3933e18 100644 --- a/Jellyfin.Plugin.Template/Jellyfin.Plugin.Template.csproj +++ b/Jellyfin.Plugin.Template/Jellyfin.Plugin.Template.csproj @@ -1,15 +1,23 @@ - net5.0 + net6.0 Jellyfin.Plugin.Template 1.0.0.0 1.0.0.0 + true + true + enable + AllEnabledByDefault + ../jellyfin.ruleset + + + diff --git a/Jellyfin.Plugin.Template/Plugin.cs b/Jellyfin.Plugin.Template/Plugin.cs index 74ead75..b55d995 100644 --- a/Jellyfin.Plugin.Template/Plugin.cs +++ b/Jellyfin.Plugin.Template/Plugin.cs @@ -1,36 +1,51 @@ using System; using System.Collections.Generic; +using System.Globalization; using Jellyfin.Plugin.Template.Configuration; using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Plugins; using MediaBrowser.Model.Plugins; using MediaBrowser.Model.Serialization; -namespace Jellyfin.Plugin.Template +namespace Jellyfin.Plugin.Template; + +/// +/// The main plugin. +/// +public class Plugin : BasePlugin, IHasWebPages { - public class Plugin : BasePlugin, IHasWebPages + /// + /// Initializes a new instance of the class. + /// + /// Instance of the interface. + /// Instance of the interface. + public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer) + : base(applicationPaths, xmlSerializer) { - public override string Name => "Template"; + Instance = this; + } - public override Guid Id => Guid.Parse("eb5d7894-8eef-4b36-aa6f-5d124e828ce1"); + /// + public override string Name => "Template"; - public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer) : base(applicationPaths, xmlSerializer) + /// + public override Guid Id => Guid.Parse("eb5d7894-8eef-4b36-aa6f-5d124e828ce1"); + + /// + /// Gets the current plugin instance. + /// + public static Plugin? Instance { get; private set; } + + /// + public IEnumerable GetPages() + { + return new[] { - Instance = this; - } - - public static Plugin Instance { get; private set; } - - public IEnumerable GetPages() - { - return new[] + new PluginPageInfo { - new PluginPageInfo - { - Name = this.Name, - EmbeddedResourcePath = string.Format("{0}.Configuration.configPage.html", GetType().Namespace) - } - }; - } + Name = this.Name, + EmbeddedResourcePath = string.Format(CultureInfo.InvariantCulture, "{0}.Configuration.configPage.html", GetType().Namespace) + } + }; } } From 7cc0743a937dd56a8248f49f1b594bbe14cfd1fc Mon Sep 17 00:00:00 2001 From: Cody Robibero Date: Tue, 14 Dec 2021 07:44:50 -0700 Subject: [PATCH 2/2] update ci, actually add ruleset --- .github/dependabot.yml | 33 ++++---- .github/workflows/build-dotnet.yml | 29 ++++--- .github/workflows/codeql-analysis.yml | 7 +- .github/workflows/test-dotnet.yml | 31 ++++++++ jellyfin.ruleset | 108 ++++++++++++++++++++++++++ 5 files changed, 182 insertions(+), 26 deletions(-) create mode 100644 .github/workflows/test-dotnet.yml create mode 100644 jellyfin.ruleset diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 982bc1a..325dec4 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,26 +1,29 @@ version: 2 updates: # Fetch and update latest `nuget` pkgs - - package-ecosystem: "nuget" - directory: "/" + - package-ecosystem: nuget + directory: / schedule: - interval: "daily" - time: "00:00" + interval: weekly open-pull-requests-limit: 10 + labels: + - chore + - dependency + - nuget commit-message: - prefix: "chore" - include: "scope" + prefix: chore + include: scope # Fetch and update latest `github-actions` pkgs - - package-ecosystem: "github-actions" - directory: "/" + - package-ecosystem: github-actions + directory: / schedule: - interval: "weekly" - time: "00:00" - labels: - - "skip-changelog" + interval: monthly open-pull-requests-limit: 10 + labels: + - ci + - dependency + - github_actions commit-message: - prefix: "ci" - include: "scope" - + prefix: ci + include: scope diff --git a/.github/workflows/build-dotnet.yml b/.github/workflows/build-dotnet.yml index fdbbe0d..744748a 100644 --- a/.github/workflows/build-dotnet.yml +++ b/.github/workflows/build-dotnet.yml @@ -1,10 +1,14 @@ -name: Test Build Plugin +name: Build Plugin on: push: branches: [ master ] + paths-ignore: + - '**/*.md' pull_request: branches: [ master ] + paths-ignore: + - '**/*.md' jobs: build: @@ -12,16 +16,21 @@ jobs: steps: - uses: actions/checkout@v2 - - name: "Setup .NET Core" + - name: Setup .NET uses: actions/setup-dotnet@v1 with: - dotnet-version: "5.0.x" + dotnet-version: 6.0.x - - name: "Install dependencies" - run: dotnet restore + - name: Build Jellyfin Plugin + uses: oddstr13/jellyfin-plugin-repository-manager@v0.4.2 + id: jprm + with: + dotnet-target: net6.0 - - name: "Build" - run: dotnet build --configuration Release --no-restore - - - name: "Test" - run: dotnet test --no-restore --verbosity normal + - name: Upload Artifact + uses: actions/upload-artifact@v2 + with: + name: build-artifact + retention-days: 30 + if-no-files-found: error + path: ${{ steps.jprm.outputs.artifact }} diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index c6ee551..206225a 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -3,8 +3,12 @@ name: Run CodeQL on: push: branches: [ master ] + paths-ignore: + - '**/*.md' pull_request: branches: [ master ] + paths-ignore: + - '**/*.md' schedule: - cron: '24 2 * * 4' @@ -12,6 +16,7 @@ jobs: analyze: name: Analyze runs-on: ubuntu-latest + if: github.repository == 'jellyfin/jellyfin-plugin-template' strategy: fail-fast: false @@ -25,7 +30,7 @@ jobs: - name: Setup .NET Core uses: actions/setup-dotnet@v1 with: - dotnet-version: 5.0.x + dotnet-version: 6.0.x - name: Initialize CodeQL uses: github/codeql-action/init@v1 diff --git a/.github/workflows/test-dotnet.yml b/.github/workflows/test-dotnet.yml new file mode 100644 index 0000000..a3f5bc9 --- /dev/null +++ b/.github/workflows/test-dotnet.yml @@ -0,0 +1,31 @@ +name: Test Plugin + +on: + push: + branches: [ master ] + paths-ignore: + - '**/*.md' + pull_request: + branches: [ master ] + paths-ignore: + - '**/*.md' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Setup .NET Core + uses: actions/setup-dotnet@v1 + with: + dotnet-version: 6.0.x + + - name: Install dependencies + run: dotnet restore + + - name: Build + run: dotnet build --configuration Release --no-restore + + - name: Test + run: dotnet test --no-restore --verbosity normal diff --git a/jellyfin.ruleset b/jellyfin.ruleset new file mode 100644 index 0000000..8af791c --- /dev/null +++ b/jellyfin.ruleset @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +