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,28 +1,57 @@
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.
OneOption, /// </summary>
AnotherOption OneOption,
}
public class PluginConfiguration : BasePluginConfiguration /// <summary>
{ /// Second option.
// store configurable settings your plugin might need /// </summary>
public bool TrueFalseSetting { get; set; } AnotherOption
public int AnInteger { get; set; } }
public string AString { get; set; }
public SomeOptions Options { get; set; } /// <summary>
/// Plugin configuration.
public PluginConfiguration() /// </summary>
{ public class PluginConfiguration : BasePluginConfiguration
// set default options here {
Options = SomeOptions.AnotherOption; /// <summary>
TrueFalseSetting = true; /// Initializes a new instance of the <see cref="PluginConfiguration"/> class.
AnInteger = 2; /// </summary>
AString = "string"; public PluginConfiguration()
} {
} // set default options here
Options = SomeOptions.AnotherOption;
TrueFalseSetting = true;
AnInteger = 2;
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,36 +1,51 @@
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.
/// </summary>
/// <param name="applicationPaths">Instance of the <see cref="IApplicationPaths"/> interface.</param>
/// <param name="xmlSerializer">Instance of the <see cref="IXmlSerializer"/> interface.</param>
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"); /// <inheritdoc />
public override string Name => "Template";
public Plugin(IApplicationPaths applicationPaths, IXmlSerializer xmlSerializer) : base(applicationPaths, xmlSerializer) /// <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()
{
return new[]
{ {
Instance = this; new PluginPageInfo
}
public static Plugin Instance { get; private set; }
public IEnumerable<PluginPageInfo> GetPages()
{
return new[]
{ {
new PluginPageInfo Name = this.Name,
{ EmbeddedResourcePath = string.Format(CultureInfo.InvariantCulture, "{0}.Configuration.configPage.html", GetType().Namespace)
Name = this.Name, }
EmbeddedResourcePath = string.Format("{0}.Configuration.configPage.html", GetType().Namespace) };
}
};
}
} }
} }