diff --git a/back/.editorconfig b/back/.editorconfig
index fadb28c4..0a9550cc 100644
--- a/back/.editorconfig
+++ b/back/.editorconfig
@@ -91,6 +91,9 @@ resharper_wrap_before_arrow_with_expressions = true
resharper_xmldoc_attribute_indent = align_by_first_attribute
resharper_xmldoc_indent_child_elements = RemoveIndent
resharper_xmldoc_indent_text = RemoveIndent
+# Switch on enum
+dotnet_diagnostic.CS8509.severity=error # missing switch case for named enum value
+dotnet_diagnostic.CS8524.severity=none # missing switch case for unnamed enum value
# Waiting for https://github.com/dotnet/roslyn/issues/44596 to get fixed.
# file_header_template = Kyoo - A portable and vast media library solution.\nCopyright (c) Kyoo.\n\nSee AUTHORS.md and LICENSE file in the project root for full license information.\n\nKyoo is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\nany later version.\n\nKyoo is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with Kyoo. If not, see .
diff --git a/back/src/Directory.Build.props b/back/src/Directory.Build.props
index 9934d2e0..1ba28e73 100644
--- a/back/src/Directory.Build.props
+++ b/back/src/Directory.Build.props
@@ -37,10 +37,6 @@
-
-
-
-
diff --git a/back/src/Kyoo.Abstractions/Models/Exceptions/UnauthorizedException.cs b/back/src/Kyoo.Abstractions/Models/Exceptions/UnauthorizedException.cs
index fc4f5f08..d1d7b339 100644
--- a/back/src/Kyoo.Abstractions/Models/Exceptions/UnauthorizedException.cs
+++ b/back/src/Kyoo.Abstractions/Models/Exceptions/UnauthorizedException.cs
@@ -24,7 +24,9 @@ namespace Kyoo.Abstractions.Models.Exceptions
[Serializable]
public class UnauthorizedException : Exception
{
- public UnauthorizedException() { }
+ public UnauthorizedException()
+ : base("User not authenticated or token invalid.")
+ { }
public UnauthorizedException(string message)
: base(message)
diff --git a/back/src/Kyoo.Core/Controllers/Repositories/WatchStatusRepository.cs b/back/src/Kyoo.Core/Controllers/Repositories/WatchStatusRepository.cs
index c546b6ce..cc2b9478 100644
--- a/back/src/Kyoo.Core/Controllers/Repositories/WatchStatusRepository.cs
+++ b/back/src/Kyoo.Core/Controllers/Repositories/WatchStatusRepository.cs
@@ -19,7 +19,6 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.Linq;
-using System.Linq.Expressions;
using System.Threading.Tasks;
using Kyoo.Abstractions.Controllers;
using Kyoo.Abstractions.Models;
@@ -44,6 +43,12 @@ public class WatchStatusRepository : IWatchStatusRepository
///
public const int MaxWatchPercent = 90;
+ // Those two are defined here because x => WatchingStatus.Watching complies to x => 1
+ // but x => Watching compiles to x => Convert.ToInt(WatchingStatus.Watching)
+ // The second one can be converted to sql wherase the first can't (tries to compare WatchStatus with int).
+ private WatchStatus Watching = WatchStatus.Watching;
+ private WatchStatus Completed = WatchStatus.Completed;
+
private readonly DatabaseContext _database;
private readonly IRepository _episodes;
private readonly IRepository _movies;
@@ -96,7 +101,7 @@ public class WatchStatusRepository : IWatchStatusRepository
PlayedDate = DateTime.UtcNow
};
await _database.MovieWatchStatus.Upsert(ret)
- .UpdateIf(x => !(status == WatchStatus.Watching && x.Status == WatchStatus.Completed))
+ .UpdateIf(x => status != Watching || x.Status != Completed)
.RunAsync();
return ret;
}
@@ -149,7 +154,7 @@ public class WatchStatusRepository : IWatchStatusRepository
PlayedDate = DateTime.UtcNow
};
await _database.ShowWatchStatus.Upsert(ret)
- .UpdateIf(x => !(status == WatchStatus.Watching && x.Status == WatchStatus.Completed))
+ .UpdateIf(x => status != Watching || x.Status != Completed)
.RunAsync();
return ret;
}
@@ -207,7 +212,7 @@ public class WatchStatusRepository : IWatchStatusRepository
PlayedDate = DateTime.UtcNow
};
await _database.EpisodeWatchStatus.Upsert(ret)
- .UpdateIf(x => !(status == WatchStatus.Watching && x.Status == WatchStatus.Completed))
+ .UpdateIf(x => status != Watching || x.Status != Completed)
.RunAsync();
await SetShowStatus(episode.ShowId, userId, WatchStatus.Watching);
return ret;
diff --git a/back/src/Kyoo.Core/ExceptionFilter.cs b/back/src/Kyoo.Core/ExceptionFilter.cs
index 3e5ad9be..66b767a1 100644
--- a/back/src/Kyoo.Core/ExceptionFilter.cs
+++ b/back/src/Kyoo.Core/ExceptionFilter.cs
@@ -62,7 +62,7 @@ namespace Kyoo.Core
context.Result = new ConflictObjectResult(new RequestError("Duplicated item"));
break;
case UnauthorizedException ex:
- context.Result = new UnauthorizedObjectResult(new RequestError(ex.Message ?? "User not authenticated or token invalid."));
+ context.Result = new UnauthorizedObjectResult(new RequestError(ex.Message));
break;
case Exception ex:
_logger.LogError(ex, "Unhandled error");