CodingStyle: Fixing windows's host warnings

This commit is contained in:
Zoe Roux 2021-09-05 21:36:34 +02:00
parent aef5ce59cb
commit c84baf67a6
8 changed files with 18 additions and 14 deletions

View File

@ -15,7 +15,7 @@
<PropertyGroup> <PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>CS1591;SA1601</NoWarn> <NoWarn>CS1591;SA1600;SA1601</NoWarn>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild> <EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)Kyoo.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)Kyoo.ruleset</CodeAnalysisRuleSet>
<!-- <AnalysisMode>AllEnabledByDefault</AnalysisMode>--> <!-- <AnalysisMode>AllEnabledByDefault</AnalysisMode>-->

View File

@ -24,7 +24,7 @@ namespace Kyoo.Core.Controllers
/// <summary> /// <summary>
/// The Entity Framework's Database handle. /// The Entity Framework's Database handle.
/// </summary> /// </summary>
protected readonly DbContext Database; protected DbContext Database { get; }
/// <summary> /// <summary>
/// The default sort order that will be used for this resource's type. /// The default sort order that will be used for this resource's type.

View File

@ -16,7 +16,8 @@ namespace Kyoo.Core.Api
where T : class, IResource where T : class, IResource
{ {
private readonly IRepository<T> _repository; private readonly IRepository<T> _repository;
protected readonly Uri BaseURL;
protected Uri BaseURL { get; }
public CrudApi(IRepository<T> repository, Uri baseURL) public CrudApi(IRepository<T> repository, Uri baseURL)
{ {

View File

@ -1,8 +1,4 @@
<Project ToolsVersion="Current"> <Project ToolsVersion="Current">
<PropertyGroup>
<IsWindows Condition="$([MSBuild]::IsOSPlatform('Windows'))">true</IsWindows>
</PropertyGroup>
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" /> <Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
<PropertyGroup Condition="$(IsWindows) == true"> <PropertyGroup Condition="$(IsWindows) == true">

View File

@ -14,12 +14,14 @@ namespace Kyoo.Host.WindowsTrait
#else #else
private const string Environment = "Production"; private const string Environment = "Production";
#endif #endif
/// <summary> /// <summary>
/// The main entry point for the application that overrides the default host. /// The main entry point for the application that overrides the default host.
/// It adds a system trait for windows and since the host is build as a windows executable instead of a console /// It adds a system trait for windows and since the host is build as a windows executable instead of a console
/// app, the console is not showed. /// app, the console is not showed.
/// </summary> /// </summary>
/// <param name="args">Command line arguments</param>
/// <returns>A <see cref="Task"/> representing the lifetime of the program.</returns>
public static Task Main(string[] args) public static Task Main(string[] args)
{ {
Application application = new(Environment); Application application = new(Environment);
@ -29,4 +31,4 @@ namespace Kyoo.Host.WindowsTrait
}); });
} }
} }
} }

View File

@ -55,7 +55,7 @@ namespace Kyoo.Host.WindowsTrait
/// <inheritdoc /> /// <inheritdoc />
public void Dispose() public void Dispose()
{ {
System.Windows.Forms.Application.Exit(); Application.Exit();
_thread?.Join(); _thread?.Join();
_thread = null; _thread = null;
} }
@ -92,7 +92,7 @@ namespace Kyoo.Host.WindowsTrait
_options = options; _options = options;
AppDomain.CurrentDomain.ProcessExit += (_, _) => Dispose(); AppDomain.CurrentDomain.ProcessExit += (_, _) => Dispose();
System.Windows.Forms.Application.ApplicationExit += (_, _) => Dispose(); Application.ApplicationExit += (_, _) => Dispose();
_icon = new NotifyIcon _icon = new NotifyIcon
{ {
@ -125,7 +125,7 @@ namespace Kyoo.Host.WindowsTrait
public static void Run(IApplication application, IOptions<BasicOptions> options) public static void Run(IApplication application, IOptions<BasicOptions> options)
{ {
using InternalSystemTrait trait = new(application, options); using InternalSystemTrait trait = new(application, options);
System.Windows.Forms.Application.Run(trait); Application.Run(trait);
} }
/// <inheritdoc /> /// <inheritdoc />

View File

@ -41,6 +41,5 @@
<Rule Id="SA1633" Action="None" /> <!-- FileMustHaveHeader TODO remove this, this is only temporary --> <Rule Id="SA1633" Action="None" /> <!-- FileMustHaveHeader TODO remove this, this is only temporary -->
<Rule Id="SA1629" Action="None" /> <!-- DocumentationTextMustEndWithAPeriod TODO remove this, this is only temporary --> <Rule Id="SA1629" Action="None" /> <!-- DocumentationTextMustEndWithAPeriod TODO remove this, this is only temporary -->
<Rule Id="SA1600" Action="None" /> <!-- ElementsMustBeDocumented TODO remove this, this is only temporary -->
</Rules> </Rules>
</RuleSet> </RuleSet>

View File

@ -1,6 +1,12 @@
{ {
"$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json", "$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
"settings": { "settings": {
"documentationRules": {
"copyrightText": "Copyright (c) {companyName}. All rights reserved.\nLicensed under the {licenseName} license. See {licenseFile} file in the project root for full license information.",
"variables": {
"licenseName": "GPL-3.0",
"licenseFile": "LICENSE"
}
}
} }
} }