Fixing dotnet format on all the code

This commit is contained in:
Zoe Roux 2022-03-27 23:53:20 +02:00
parent 34b06bd2fb
commit 0f06033b42
No known key found for this signature in database
GPG Key ID: 6AA5AE82CCC0D9DD
22 changed files with 65 additions and 49 deletions

View File

@ -14,6 +14,12 @@ indent_style = space
indent_size = 2 indent_size = 2
[*.cs] [*.cs]
csharp_prefer_braces = false
dotnet_diagnostic.IDE0130.severity = none
dotnet_diagnostic.IDE0058.severity = none
dotnet_diagnostic.IDE0046.severity = none
dotnet_diagnostic.CA1848.severity = none
dotnet_diagnostic.CA2007.severity = none
# Sort using and Import directives with System.* appearing first # Sort using and Import directives with System.* appearing first
dotnet_sort_system_directives_first = true dotnet_sort_system_directives_first = true
csharp_using_directive_placement = outside_namespace:warning csharp_using_directive_placement = outside_namespace:warning

View File

@ -28,10 +28,6 @@
<IsOSX Condition="$([MSBuild]::IsOSPlatform('OSX'))">true</IsOSX> <IsOSX Condition="$([MSBuild]::IsOSPlatform('OSX'))">true</IsOSX>
<IsLinux Condition="$([MSBuild]::IsOSPlatform('Linux'))">true</IsLinux> <IsLinux Condition="$([MSBuild]::IsOSPlatform('Linux'))">true</IsLinux>
<!-- TODO the next thing does not work on rider, enabling coding style check by default. -->
<!--<CheckCodingStyle Condition="$(BuildingInsideVisualStudio) == true">true</CheckCodingStyle>-->
<!--<CheckCodingStyle Condition="$(BuildingInsideReSharper) == true">true</CheckCodingStyle>-->
<CheckCodingStyle Condition="$(CheckCodingStyle) == ''">true</CheckCodingStyle> <CheckCodingStyle Condition="$(CheckCodingStyle) == ''">true</CheckCodingStyle>
</PropertyGroup> </PropertyGroup>
@ -48,8 +44,7 @@
</ItemGroup> </ItemGroup>
<PropertyGroup Condition="$(CheckCodingStyle) == true"> <PropertyGroup Condition="$(CheckCodingStyle) == true">
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)../Kyoo.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)../Kyoo.ruleset</CodeAnalysisRuleSet>
<!-- <AnalysisMode>AllEnabledByDefault</AnalysisMode>--> <!-- <AnalysisMode>All</AnalysisMode> -->
</PropertyGroup> </PropertyGroup>
</Project> </Project>

View File

@ -1,4 +1,4 @@
// Kyoo - A portable and vast media library solution. // Kyoo - A portable and vast media library solution.
// Copyright (c) Kyoo. // Copyright (c) Kyoo.
// //
// See AUTHORS.md and LICENSE file in the project root for full license information. // See AUTHORS.md and LICENSE file in the project root for full license information.

View File

@ -1,4 +1,4 @@
// Kyoo - A portable and vast media library solution. // Kyoo - A portable and vast media library solution.
// Copyright (c) Kyoo. // Copyright (c) Kyoo.
// //
// See AUTHORS.md and LICENSE file in the project root for full license information. // See AUTHORS.md and LICENSE file in the project root for full license information.

View File

@ -1,4 +1,4 @@
// Kyoo - A portable and vast media library solution. // Kyoo - A portable and vast media library solution.
// Copyright (c) Kyoo. // Copyright (c) Kyoo.
// //
// See AUTHORS.md and LICENSE file in the project root for full license information. // See AUTHORS.md and LICENSE file in the project root for full license information.

View File

@ -34,7 +34,8 @@ namespace Kyoo.Abstractions.Models
public int ID { get; set; } public int ID { get; set; }
/// <inheritdoc /> /// <inheritdoc />
[Computed] public string Slug [Computed]
public string Slug
{ {
get get
{ {
@ -45,7 +46,9 @@ namespace Kyoo.Abstractions.Models
: null; : null;
} }
[UsedImplicitly] [NotNull] private set [UsedImplicitly]
[NotNull]
private set
{ {
if (value == null) if (value == null)
throw new ArgumentNullException(nameof(value)); throw new ArgumentNullException(nameof(value));

View File

@ -34,7 +34,8 @@ namespace Kyoo.Abstractions.Models
public int ID { get; set; } public int ID { get; set; }
/// <inheritdoc /> /// <inheritdoc />
[Computed] public string Slug [Computed]
public string Slug
{ {
get get
{ {
@ -43,7 +44,9 @@ namespace Kyoo.Abstractions.Models
return $"{ShowSlug ?? Show?.Slug}-s{SeasonNumber}"; return $"{ShowSlug ?? Show?.Slug}-s{SeasonNumber}";
} }
[UsedImplicitly] [NotNull] private set [UsedImplicitly]
[NotNull]
private set
{ {
Match match = Regex.Match(value ?? string.Empty, @"(?<show>.+)-s(?<season>\d+)"); Match match = Regex.Match(value ?? string.Empty, @"(?<show>.+)-s(?<season>\d+)");

View File

@ -67,7 +67,8 @@ namespace Kyoo.Abstractions.Models
public int ID { get; set; } public int ID { get; set; }
/// <inheritdoc /> /// <inheritdoc />
[Computed] public string Slug [Computed]
public string Slug
{ {
get get
{ {
@ -77,7 +78,8 @@ namespace Kyoo.Abstractions.Models
return $"{episode}.{Language ?? "und"}{index}{(IsForced ? ".forced" : string.Empty)}.{type}"; return $"{episode}.{Language ?? "und"}{index}{(IsForced ? ".forced" : string.Empty)}.{type}";
} }
[UsedImplicitly] private set [UsedImplicitly]
private set
{ {
if (value == null) if (value == null)
throw new ArgumentNullException(nameof(value)); throw new ArgumentNullException(nameof(value));
@ -86,8 +88,10 @@ namespace Kyoo.Abstractions.Models
if (!match.Success) if (!match.Success)
{ {
throw new ArgumentException("Invalid track slug. " + throw new ArgumentException(
"Format: {episodeSlug}.{language}[-{index}][.forced].{type}[.{extension}]"); "Invalid track slug. " +
"Format: {episodeSlug}.{language}[-{index}][.forced].{type}[.{extension}]"
);
} }
_episodeSlug = match.Groups["ep"].Value; _episodeSlug = match.Groups["ep"].Value;
@ -148,7 +152,8 @@ namespace Kyoo.Abstractions.Models
/// <summary> /// <summary>
/// The episode that uses this track. /// The episode that uses this track.
/// </summary> /// </summary>
[LoadableRelation(nameof(EpisodeID))] public Episode Episode [LoadableRelation(nameof(EpisodeID))]
public Episode Episode
{ {
get => _episode; get => _episode;
set set

View File

@ -1,4 +1,4 @@
// Kyoo - A portable and vast media library solution. // Kyoo - A portable and vast media library solution.
// Copyright (c) Kyoo. // Copyright (c) Kyoo.
// //
// See AUTHORS.md and LICENSE file in the project root for full license information. // See AUTHORS.md and LICENSE file in the project root for full license information.

View File

@ -1,4 +1,4 @@
// Kyoo - A portable and vast media library solution. // Kyoo - A portable and vast media library solution.
// Copyright (c) Kyoo. // Copyright (c) Kyoo.
// //
// See AUTHORS.md and LICENSE file in the project root for full license information. // See AUTHORS.md and LICENSE file in the project root for full license information.

View File

@ -1,4 +1,4 @@
// Kyoo - A portable and vast media library solution. // Kyoo - A portable and vast media library solution.
// Copyright (c) Kyoo. // Copyright (c) Kyoo.
// //
// See AUTHORS.md and LICENSE file in the project root for full license information. // See AUTHORS.md and LICENSE file in the project root for full license information.

View File

@ -170,7 +170,7 @@ namespace Kyoo.Utils
Type type = typeof(T); Type type = typeof(T);
IEnumerable<PropertyInfo> properties = type.GetProperties() IEnumerable<PropertyInfo> properties = type.GetProperties()
.Where(x => x.CanRead && x.CanWrite .Where(x => x.CanRead && x.CanWrite
&& Attribute.GetCustomAttribute(x, typeof(NotMergeableAttribute)) == null); && Attribute.GetCustomAttribute(x, typeof(NotMergeableAttribute)) == null);
foreach (PropertyInfo property in properties) foreach (PropertyInfo property in properties)
{ {
@ -221,7 +221,7 @@ namespace Kyoo.Utils
Type type = typeof(T); Type type = typeof(T);
IEnumerable<PropertyInfo> properties = type.GetProperties() IEnumerable<PropertyInfo> properties = type.GetProperties()
.Where(x => x.CanRead && x.CanWrite .Where(x => x.CanRead && x.CanWrite
&& Attribute.GetCustomAttribute(x, typeof(NotMergeableAttribute)) == null); && Attribute.GetCustomAttribute(x, typeof(NotMergeableAttribute)) == null);
if (where != null) if (where != null)
properties = properties.Where(where); properties = properties.Where(where);
@ -293,7 +293,7 @@ namespace Kyoo.Utils
Type type = typeof(T); Type type = typeof(T);
IEnumerable<PropertyInfo> properties = type.GetProperties() IEnumerable<PropertyInfo> properties = type.GetProperties()
.Where(x => x.CanRead && x.CanWrite .Where(x => x.CanRead && x.CanWrite
&& Attribute.GetCustomAttribute(x, typeof(NotMergeableAttribute)) == null); && Attribute.GetCustomAttribute(x, typeof(NotMergeableAttribute)) == null);
if (where != null) if (where != null)
properties = properties.Where(where); properties = properties.Where(where);
@ -325,7 +325,7 @@ namespace Kyoo.Utils
property.SetValue(first, newDictionary); property.SetValue(first, newDictionary);
} }
else if (typeof(IEnumerable).IsAssignableFrom(property.PropertyType) else if (typeof(IEnumerable).IsAssignableFrom(property.PropertyType)
&& property.PropertyType != typeof(string)) && property.PropertyType != typeof(string))
{ {
Type enumerableType = Utility.GetGenericDefinition(property.PropertyType, typeof(IEnumerable<>)) Type enumerableType = Utility.GetGenericDefinition(property.PropertyType, typeof(IEnumerable<>))
.GenericTypeArguments .GenericTypeArguments

View File

@ -43,8 +43,8 @@ namespace Kyoo.Utils
{ {
if (ex == null) if (ex == null)
return false; return false;
return ex.Body is MemberExpression || return ex.Body is MemberExpression
(ex.Body.NodeType == ExpressionType.Convert && ((UnaryExpression)ex.Body).Operand is MemberExpression); || (ex.Body.NodeType == ExpressionType.Convert && ((UnaryExpression)ex.Body).Operand is MemberExpression);
} }
/// <summary> /// <summary>
@ -242,9 +242,12 @@ namespace Kyoo.Utils
.Where(x => x.Name == name) .Where(x => x.Name == name)
.Where(x => x.GetGenericArguments().Length == generics.Length) .Where(x => x.GetGenericArguments().Length == generics.Length)
.Where(x => x.GetParameters().Length == args.Length) .Where(x => x.GetParameters().Length == args.Length)
.IfEmpty(() => throw new ArgumentException($"A method named {name} with " + .IfEmpty(() =>
$"{args.Length} arguments and {generics.Length} generic " + {
$"types could not be found on {type.Name}.")) throw new ArgumentException($"A method named {name} with " +
$"{args.Length} arguments and {generics.Length} generic " +
$"types could not be found on {type.Name}.");
})
// TODO this won't work but I don't know why. // TODO this won't work but I don't know why.
// .Where(x => // .Where(x =>
// { // {

View File

@ -154,12 +154,12 @@ namespace Kyoo.Authentication
return; return;
default: default:
throw new ArgumentException("Multiple non-matching partial permission attribute " + throw new ArgumentException("Multiple non-matching partial permission attribute " +
"are not supported."); "are not supported.");
} }
if (permission == null || kind == null) if (permission == null || kind == null)
{ {
throw new ArgumentException("The permission type or kind is still missing after two partial " + throw new ArgumentException("The permission type or kind is still missing after two partial " +
"permission attributes, this is unsupported."); "permission attributes, this is unsupported.");
} }
} }

View File

@ -163,7 +163,7 @@ namespace Kyoo.Core.Controllers
if (typeof(T).IsAssignableFrom(type)) if (typeof(T).IsAssignableFrom(type))
{ {
throw new InvalidCastException($"The type {typeof(T).Name} is not valid for " + throw new InvalidCastException($"The type {typeof(T).Name} is not valid for " +
$"a resource of type {type.Name}."); $"a resource of type {type.Name}.");
} }
return (T)GetValue(path); return (T)GetValue(path);
} }

View File

@ -73,16 +73,16 @@ namespace Kyoo.Core.Controllers
public Task<Episode> GetOrDefault(int showID, int seasonNumber, int episodeNumber) public Task<Episode> GetOrDefault(int showID, int seasonNumber, int episodeNumber)
{ {
return _database.Episodes.FirstOrDefaultAsync(x => x.ShowID == showID return _database.Episodes.FirstOrDefaultAsync(x => x.ShowID == showID
&& x.SeasonNumber == seasonNumber && x.SeasonNumber == seasonNumber
&& x.EpisodeNumber == episodeNumber); && x.EpisodeNumber == episodeNumber);
} }
/// <inheritdoc /> /// <inheritdoc />
public Task<Episode> GetOrDefault(string showSlug, int seasonNumber, int episodeNumber) public Task<Episode> GetOrDefault(string showSlug, int seasonNumber, int episodeNumber)
{ {
return _database.Episodes.FirstOrDefaultAsync(x => x.Show.Slug == showSlug return _database.Episodes.FirstOrDefaultAsync(x => x.Show.Slug == showSlug
&& x.SeasonNumber == seasonNumber && x.SeasonNumber == seasonNumber
&& x.EpisodeNumber == episodeNumber); && x.EpisodeNumber == episodeNumber);
} }
/// <inheritdoc /> /// <inheritdoc />
@ -107,14 +107,14 @@ namespace Kyoo.Core.Controllers
public Task<Episode> GetAbsolute(int showID, int absoluteNumber) public Task<Episode> GetAbsolute(int showID, int absoluteNumber)
{ {
return _database.Episodes.FirstOrDefaultAsync(x => x.ShowID == showID return _database.Episodes.FirstOrDefaultAsync(x => x.ShowID == showID
&& x.AbsoluteNumber == absoluteNumber); && x.AbsoluteNumber == absoluteNumber);
} }
/// <inheritdoc /> /// <inheritdoc />
public Task<Episode> GetAbsolute(string showSlug, int absoluteNumber) public Task<Episode> GetAbsolute(string showSlug, int absoluteNumber)
{ {
return _database.Episodes.FirstOrDefaultAsync(x => x.Show.Slug == showSlug return _database.Episodes.FirstOrDefaultAsync(x => x.Show.Slug == showSlug
&& x.AbsoluteNumber == absoluteNumber); && x.AbsoluteNumber == absoluteNumber);
} }
/// <inheritdoc /> /// <inheritdoc />

View File

@ -82,14 +82,14 @@ namespace Kyoo.Core.Controllers
public Task<Season> GetOrDefault(int showID, int seasonNumber) public Task<Season> GetOrDefault(int showID, int seasonNumber)
{ {
return _database.Seasons.FirstOrDefaultAsync(x => x.ShowID == showID return _database.Seasons.FirstOrDefaultAsync(x => x.ShowID == showID
&& x.SeasonNumber == seasonNumber); && x.SeasonNumber == seasonNumber);
} }
/// <inheritdoc/> /// <inheritdoc/>
public Task<Season> GetOrDefault(string showSlug, int seasonNumber) public Task<Season> GetOrDefault(string showSlug, int seasonNumber)
{ {
return _database.Seasons.FirstOrDefaultAsync(x => x.Show.Slug == showSlug return _database.Seasons.FirstOrDefaultAsync(x => x.Show.Slug == showSlug
&& x.SeasonNumber == seasonNumber); && x.SeasonNumber == seasonNumber);
} }
/// <inheritdoc/> /// <inheritdoc/>

View File

@ -260,7 +260,7 @@ namespace Kyoo.Core.Controllers
_logger = logger; _logger = logger;
} }
// We use threads so tasks are not always awaited. // We use threads so tasks are not always awaited.
#pragma warning disable 4014 #pragma warning disable 4014
/// <inheritdoc /> /// <inheritdoc />

View File

@ -1,4 +1,4 @@
// Kyoo - A portable and vast media library solution. // Kyoo - A portable and vast media library solution.
// Copyright (c) Kyoo. // Copyright (c) Kyoo.
// //
// See AUTHORS.md and LICENSE file in the project root for full license information. // See AUTHORS.md and LICENSE file in the project root for full license information.

View File

@ -184,8 +184,9 @@ namespace Kyoo.SqLite
/// <inheritdoc /> /// <inheritdoc />
protected override bool IsDuplicateException(Exception ex) protected override bool IsDuplicateException(Exception ex)
{ {
return ex.InnerException is SqliteException { SqliteExtendedErrorCode: 2067 /* SQLITE_CONSTRAINT_UNIQUE */ } return ex.InnerException
or SqliteException { SqliteExtendedErrorCode: 1555 /* SQLITE_CONSTRAINT_PRIMARYKEY */ }; is SqliteException { SqliteExtendedErrorCode: 2067 /* SQLITE_CONSTRAINT_UNIQUE */ }
or SqliteException { SqliteExtendedErrorCode: 1555 /* SQLITE_CONSTRAINT_PRIMARYKEY */ };
} }
/// <inheritdoc /> /// <inheritdoc />

View File

@ -1,4 +1,4 @@
// Kyoo - A portable and vast media library solution. // Kyoo - A portable and vast media library solution.
// Copyright (c) Kyoo. // Copyright (c) Kyoo.
// //
// See AUTHORS.md and LICENSE file in the project root for full license information. // See AUTHORS.md and LICENSE file in the project root for full license information.

View File

@ -180,8 +180,8 @@ namespace Kyoo.Tests
"We Still Don't Know the Name of the Flower We Saw That Day." "We Still Don't Know the Name of the Flower We Saw That Day."
}, },
Overview = "When Yadomi Jinta was a child, he was a central piece in a group of close friends. " + Overview = "When Yadomi Jinta was a child, he was a central piece in a group of close friends. " +
"In time, however, these childhood friends drifted apart, and when they became high " + "In time, however, these childhood friends drifted apart, and when they became high " +
"school students, they had long ceased to think of each other as friends.", "school students, they had long ceased to think of each other as friends.",
Status = Status.Finished, Status = Status.Finished,
StudioID = 1, StudioID = 1,
StartAir = new DateTime(2011, 1, 1), StartAir = new DateTime(2011, 1, 1),
@ -243,7 +243,7 @@ namespace Kyoo.Tests
typeof(Track), typeof(Track),
() => () =>
{ {
Track ret = new() Track ret = new()
{ {
ID = 1, ID = 1,
EpisodeID = 1, EpisodeID = 1,