update editorconfig, add analyzers

This commit is contained in:
Cody Robibero 2021-12-13 16:58:05 -07:00
parent c6e0e3414a
commit 2445823c5a
5 changed files with 99 additions and 50 deletions

View File

@ -5,7 +5,6 @@
# Core EditorConfig Options # # Core EditorConfig Options #
############################### ###############################
root = true root = true
# All files # All files
[*] [*]
indent_style = space indent_style = space
@ -14,7 +13,7 @@ charset = utf-8
trim_trailing_whitespace = true trim_trailing_whitespace = true
insert_final_newline = true insert_final_newline = true
end_of_line = lf end_of_line = lf
max_line_length = 9999 max_line_length = off
# YAML indentation # YAML indentation
[*.{yml,yaml}] [*.{yml,yaml}]
@ -27,7 +26,6 @@ indent_size = 2
############################### ###############################
# .NET Coding Conventions # # .NET Coding Conventions #
############################### ###############################
[*.{cs,vb}] [*.{cs,vb}]
# Organize usings # Organize usings
dotnet_sort_system_directives_first = true dotnet_sort_system_directives_first = true
@ -63,7 +61,6 @@ dotnet_style_prefer_conditional_expression_over_return = true:silent
############################### ###############################
# Naming Conventions # # Naming Conventions #
############################### ###############################
# Style Definitions (From Roslyn) # Style Definitions (From Roslyn)
# Non-private static fields are PascalCase # Non-private static fields are PascalCase
@ -138,7 +135,6 @@ dotnet_naming_style.pascal_case_style.capitalization = pascal_case
############################### ###############################
# C# Coding Conventions # # C# Coding Conventions #
############################### ###############################
[*.cs] [*.cs]
# var preferences # var preferences
csharp_style_var_for_built_in_types = true:silent csharp_style_var_for_built_in_types = true:silent
@ -169,7 +165,6 @@ csharp_style_inlined_variable_declaration = true:suggestion
############################### ###############################
# C# Formatting Rules # # C# Formatting Rules #
############################### ###############################
# New line preferences # New line preferences
csharp_new_line_before_open_brace = all csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true csharp_new_line_before_else = true

2
.gitignore vendored
View File

@ -1,3 +1,5 @@
bin/ bin/
obj/ obj/
.vs/ .vs/
.idea/
artifacts

View File

@ -1,21 +1,31 @@
using MediaBrowser.Model.Plugins; using MediaBrowser.Model.Plugins;
namespace Jellyfin.Plugin.Template.Configuration namespace Jellyfin.Plugin.Template.Configuration;
/// <summary>
/// The configuration options.
/// </summary>
public enum SomeOptions
{ {
public enum SomeOptions /// <summary>
{ /// Option one.
/// </summary>
OneOption, OneOption,
/// <summary>
/// Second option.
/// </summary>
AnotherOption AnotherOption
} }
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; }
/// <summary>
/// Plugin configuration.
/// </summary>
public class PluginConfiguration : BasePluginConfiguration
{
/// <summary>
/// Initializes a new instance of the <see cref="PluginConfiguration"/> class.
/// </summary>
public PluginConfiguration() public PluginConfiguration()
{ {
// set default options here // set default options here
@ -24,5 +34,24 @@ namespace Jellyfin.Plugin.Template.Configuration
AnInteger = 2; AnInteger = 2;
AString = "string"; AString = "string";
} }
}
/// <summary>
/// Gets or sets a value indicating whether some true or false setting is enabled..
/// </summary>
public bool TrueFalseSetting { get; set; }
/// <summary>
/// Gets or sets an integer setting.
/// </summary>
public int AnInteger { get; set; }
/// <summary>
/// Gets or sets a string setting.
/// </summary>
public string AString { get; set; }
/// <summary>
/// Gets or sets an enum option.
/// </summary>
public SomeOptions Options { get; set; }
} }

View File

@ -1,15 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net5.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<RootNamespace>Jellyfin.Plugin.Template</RootNamespace> <RootNamespace>Jellyfin.Plugin.Template</RootNamespace>
<AssemblyVersion>1.0.0.0</AssemblyVersion> <AssemblyVersion>1.0.0.0</AssemblyVersion>
<FileVersion>1.0.0.0</FileVersion> <FileVersion>1.0.0.0</FileVersion>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Nullable>enable</Nullable>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
<CodeAnalysisRuleSet>../jellyfin.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Jellyfin.Controller" Version="10.*-*" /> <PackageReference Include="Jellyfin.Controller" Version="10.*-*" />
<PackageReference Include="Jellyfin.Model" Version="10.*-*" /> <PackageReference Include="Jellyfin.Model" Version="10.*-*" />
<PackageReference Include="SerilogAnalyzer" Version="0.15.0" PrivateAssets="All" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.376" PrivateAssets="All" />
<PackageReference Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" PrivateAssets="All" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -1,26 +1,42 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using Jellyfin.Plugin.Template.Configuration; using Jellyfin.Plugin.Template.Configuration;
using MediaBrowser.Common.Configuration; using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Plugins; using MediaBrowser.Common.Plugins;
using MediaBrowser.Model.Plugins; using MediaBrowser.Model.Plugins;
using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Serialization;
namespace Jellyfin.Plugin.Template namespace Jellyfin.Plugin.Template;
/// <summary>
/// The main plugin.
/// </summary>
public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages
{ {
public class Plugin : BasePlugin<PluginConfiguration>, IHasWebPages /// <summary>
{ /// Initializes a new instance of the <see cref="Plugin"/> class.
public override string Name => "Template"; /// </summary>
/// <param name="applicationPaths">Instance of the <see cref="IApplicationPaths"/> interface.</param>
public override Guid Id => Guid.Parse("eb5d7894-8eef-4b36-aa6f-5d124e828ce1"); /// <param name="xmlSerializer">Instance of the <see cref="IXmlSerializer"/> interface.</param>
public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer)
public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer) : base(applicationPaths, xmlSerializer) : base(applicationPaths, xmlSerializer)
{ {
Instance = this; Instance = this;
} }
public static Plugin Instance { get; private set; } /// <inheritdoc />
public override string Name => "Template";
/// <inheritdoc />
public override Guid Id => Guid.Parse("eb5d7894-8eef-4b36-aa6f-5d124e828ce1");
/// <summary>
/// Gets the current plugin instance.
/// </summary>
public static Plugin? Instance { get; private set; }
/// <inheritdoc />
public IEnumerable<PluginPageInfo> GetPages() public IEnumerable<PluginPageInfo> GetPages()
{ {
return new[] return new[]
@ -28,9 +44,8 @@ namespace Jellyfin.Plugin.Template
new PluginPageInfo new PluginPageInfo
{ {
Name = this.Name, Name = this.Name,
EmbeddedResourcePath = string.Format("{0}.Configuration.configPage.html", GetType().Namespace) EmbeddedResourcePath = string.Format(CultureInfo.InvariantCulture, "{0}.Configuration.configPage.html", GetType().Namespace)
} }
}; };
} }
}
} }