Fixes typos and replaces LINQ conversions with collection expressions

This commit is contained in:
BinaryAlley committed 2026-08-09 00:19:28 -07:00
1 parent adadec7f3b
commit 74e9030a18
75 files changed
+113 -113

No files matched your search

@@ -20,6 +20,6 @@ public interface IDomainEventsQueue
/// </summary>
/// <param name="domainEvent">When this method returns, contains the domain event removed from the queue, or the default value of <see cref="IDomainEvent"/> if the queue is empty.
/// </param>
/// <returns><see langword="true"/> if a domain event was successfuly dequeued, <see langword="false"/> otherwise.</returns>
/// <returns><see langword="true"/> if a domain event was successfully dequeued, <see langword="false"/> otherwise.</returns>
bool TryDequeue(out IDomainEvent domainEvent);
}
@@ -18,7 +18,7 @@ public static class GenreDtoMapping
/// </summary>
/// <param name="dto">The DTO to be converted.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly converted <see cref="Genre"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully converted <see cref="Genre"/>, or an error message.
/// </returns>
public static ErrorOr<Genre> ToDomainEntity(this GenreDto dto)
{
@@ -41,7 +41,7 @@ public static class GenreEntityMapping
/// </summary>
/// <param name="repositoryEntity">The repository entity to be converted.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly converted <see cref="Genre"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully converted <see cref="Genre"/>, or an error message.
/// </returns>
public static ErrorOr<Genre> ToDomainEntity(this GenreEntity repositoryEntity)
{
@@ -18,7 +18,7 @@ public static class TagDtoMapping
/// </summary>
/// <param name="dto">The DTO to be converted.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly converted <see cref="Tag"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully converted <see cref="Tag"/>, or an error message.
/// </returns>
public static ErrorOr<Tag> ToDomainEntity(this TagDto dto)
{
@@ -41,7 +41,7 @@ public static class TagEntityMapping
/// </summary>
/// <param name="repositoryEntity">The repository entity to be converted.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly converted <see cref="Tag"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully converted <see cref="Tag"/>, or an error message.
/// </returns>
public static ErrorOr<Tag> ToDomainEntity(this TagEntity repositoryEntity)
{
@@ -30,7 +30,7 @@ public static class BookEntityMapping
/// </summary>
/// <param name="repositoryEntity">The repository entity to be converted.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly converted <see cref="Book"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully converted <see cref="Book"/>, or an error message.
/// </returns>
public static ErrorOr<Book> ToDomainEntity(this BookEntity repositoryEntity)
{
@@ -20,7 +20,7 @@ public static class BookRatingDtoMapping
/// </summary>
/// <param name="dto">The DTO to be converted.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly converted <see cref="BookRating"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully converted <see cref="BookRating"/>, or an error message.
/// </returns>
public static ErrorOr<BookRating> ToDomainEntity(this BookRatingDto dto)
{
@@ -46,7 +46,7 @@ public static class BookRatingEntityMapping
/// </summary>
/// <param name="repositoryEntity">The repository entity to be converted.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly converted <see cref="BookRating"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully converted <see cref="BookRating"/>, or an error message.
/// </returns>
public static ErrorOr<BookRating> ToDomainEntity(this BookRatingEntity repositoryEntity)
{
@@ -19,7 +19,7 @@ public static class IsbnDtoMapping
/// </summary>
/// <param name="dto">The DTO to be converted.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly converted <see cref="Isbn"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully converted <see cref="Isbn"/>, or an error message.
/// </returns>
public static ErrorOr<Isbn> ToDomainEntity(this IsbnDto dto)
{
@@ -42,7 +42,7 @@ public static class IsbnEntityMapping
/// </summary>
/// <param name="repositoryEntity">The repository entity to be converted.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly converted <see cref="Isbn"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully converted <see cref="Isbn"/>, or an error message.
/// </returns>
public static ErrorOr<Isbn> ToDomainEntity(this IsbnEntity repositoryEntity)
{
@@ -44,7 +44,7 @@ public class AddRoleCommandHandler : IRequestHandler<AddRoleCommand, ErrorOr<Rol
/// <param name="request">The request to be handled.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="RoleResponse"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="RoleResponse"/>, or an error message.
/// </returns>
public async ValueTask<ErrorOr<RolePermissionsResponse>> Handle(AddRoleCommand request, CancellationToken cancellationToken)
{
@@ -44,7 +44,7 @@ public class UpdateRoleCommandHandler : IRequestHandler<UpdateRoleCommand, Error
/// <param name="request">The request to be handled.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly updated <see cref="RoleResponse"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully updated <see cref="RoleResponse"/>, or an error message.
/// </returns>
public async ValueTask<ErrorOr<RolePermissionsResponse>> Handle(UpdateRoleCommand request, CancellationToken cancellationToken)
{
@@ -66,7 +66,7 @@ public class SetupApplicationCommandHandler : IRequestHandler<SetupApplicationCo
/// <param name="request">The request to be handled.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="RegistrationResponse"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="RegistrationResponse"/>, or an error message.
/// </returns>
public async ValueTask<ErrorOr<RegistrationResponse>> Handle(SetupApplicationCommand request, CancellationToken cancellationToken)
{
@@ -47,7 +47,7 @@ public class GetEnabledLibrariesQueryHandler : IRequestHandler<GetEnabledLibrari
/// <param name="request">The request to be handled.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="LibraryResponse"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="LibraryResponse"/>, or an error message.
/// </returns>
public async ValueTask<ErrorOr<LibraryResponse[]>> Handle(GetEnabledLibrariesQuery request, CancellationToken cancellationToken)
{
@@ -63,9 +63,9 @@ public class GetEnabledLibrariesQueryHandler : IRequestHandler<GetEnabledLibrari
else
{
// for regular users, only take the libraries that belong to them
LibraryResponse[] userEnabledLibraries = getEnabledLibrariesResult.Value
LibraryResponse[] userEnabledLibraries = [.. getEnabledLibrariesResult.Value
.Where(library => library.UserId == _currentUserService.UserId)
.Select(library => library.ToResponse()).ToArray();
.Select(library => library.ToResponse())];
return ErrorOrFactory.From(userEnabledLibraries);
}
@@ -47,7 +47,7 @@ public class GetLibrariesQueryHandler : IRequestHandler<GetLibrariesQuery, Error
/// <param name="request">The request to be handled.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="LibraryResponse"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="LibraryResponse"/>, or an error message.
/// </returns>
public async ValueTask<ErrorOr<LibraryResponse[]>> Handle(GetLibrariesQuery request, CancellationToken cancellationToken)
{
@@ -63,9 +63,9 @@ public class GetLibrariesQueryHandler : IRequestHandler<GetLibrariesQuery, Error
else
{
// for regular users, only take the libraries that belong to them
LibraryResponse[] userLibraries = getLibrariesResult.Value
LibraryResponse[] userLibraries = [.. getLibrariesResult.Value
.Where(library => library.UserId == _currentUserService.UserId)
.Select(library => library.ToResponse()).ToArray();
.Select(library => library.ToResponse())];
return ErrorOrFactory.From(userLibraries);
}
@@ -48,7 +48,7 @@ public class GetLibraryQueryHandler : IRequestHandler<GetLibraryQuery, ErrorOr<L
/// <param name="request">The request to be handled.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="LibraryResponse"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="LibraryResponse"/>, or an error message.
/// </returns>
public async ValueTask<ErrorOr<LibraryResponse>> Handle(GetLibraryQuery request, CancellationToken cancellationToken)
{
@@ -54,7 +54,7 @@ public class GetRunningLibraryScansQueryHandler : IRequestHandler<GetRunningLibr
/// <param name="request">The request to be handled.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="MediaLibraryScanProgress"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="MediaLibraryScanProgress"/>, or an error message.
/// </returns>
public async ValueTask<ErrorOr<IEnumerable<MediaLibraryScanProgressResponse>>> Handle(GetRunningLibraryScansQuery request, CancellationToken cancellationToken)
{
@@ -68,7 +68,7 @@ public class GetRunningLibraryScansQueryHandler : IRequestHandler<GetRunningLibr
LibraryScanEntity[] userRunningRepositoryLibraryScans = [];
// admins can see all libraries
if (!await _authorizationService.IsInRoleAsync(_currentUserService.UserId!.Value, "Admin", cancellationToken).ConfigureAwait(false))
userRunningRepositoryLibraryScans = getRunningScansResult.Value.ToArray();
userRunningRepositoryLibraryScans = [.. getRunningScansResult.Value];
else // for regular users, only take the libraries that belong to them
userRunningRepositoryLibraryScans = getRunningScansResult.Value
.Where(libraryScan => libraryScan.UserId == _currentUserService.UserId).ToArray();
@@ -45,7 +45,7 @@ public class AddBookCommandHandler : IRequestHandler<AddBookCommand, ErrorOr<Boo
/// <param name="request">The request to be handled.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="BookResponse"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="BookResponse"/>, or an error message.
/// </returns>
public async ValueTask<ErrorOr<BookResponse>> Handle(AddBookCommand request, CancellationToken cancellationToken)
{
@@ -67,29 +67,29 @@ public class AddBookCommandHandler : IRequestHandler<AddBookCommand, ErrorOr<Boo
Optional<BookRatingSource>.FromNullable(rating.Source.HasValue ? (BookRatingSource)(int)rating.Source : (BookRatingSource?)null),
Optional<int>.FromNullable(rating.VoteCount)));
// check if any of the results contain errors
List<Error> errors = domainRatingsResult.Where(ratingResult => ratingResult.IsError).SelectMany(ratingResult => ratingResult.Errors).ToList();
List<Error> errors = [.. domainRatingsResult.Where(ratingResult => ratingResult.IsError).SelectMany(ratingResult => ratingResult.Errors)];
if (errors.Count != 0) // if there are errors, return them
return errors;
List<BookRating> domainRatings = domainRatingsResult.Select(rating => rating.Value).ToList();
List<BookRating> domainRatings = [.. domainRatingsResult.Select(rating => rating.Value)];
List<ErrorOr<Genre>> domainGenresResult = request.Metadata!.Genres!.ConvertAll(genre => Genre.Create(genre.Name!));
errors = domainGenresResult.Where(genreResult => genreResult.IsError).SelectMany(genreResult => genreResult.Errors).ToList();
errors = [.. domainGenresResult.Where(genreResult => genreResult.IsError).SelectMany(genreResult => genreResult.Errors)];
if (errors.Count != 0)
return errors;
List<Genre> domainGenres = domainGenresResult.Select(genre => genre.Value).ToList();
List<Genre> domainGenres = [.. domainGenresResult.Select(genre => genre.Value)];
List<ErrorOr<Tag>> domainTagsResult = request.Metadata.Tags!.ConvertAll(tag => Tag.Create(tag.Name!));
errors = domainTagsResult.Where(tagResult => tagResult.IsError).SelectMany(tagResult => tagResult.Errors).ToList();
errors = [.. domainTagsResult.Where(tagResult => tagResult.IsError).SelectMany(tagResult => tagResult.Errors)];
if (errors.Count != 0)
return errors;
List<Tag> domainTags = domainTagsResult.Select(tag => tag.Value).ToList();
List<Tag> domainTags = [.. domainTagsResult.Select(tag => tag.Value)];
List<ErrorOr<Isbn>> domainIsbnsResult = request.ISBNs!.ConvertAll(isbn => Isbn.Create(isbn.Value!, (IsbnFormat)(int)isbn.Format!));
errors = domainIsbnsResult.Where(isbnResult => isbnResult.IsError).SelectMany(isbnResult => isbnResult.Errors).ToList();
errors = [.. domainIsbnsResult.Where(isbnResult => isbnResult.IsError).SelectMany(isbnResult => isbnResult.Errors)];
if (errors.Count != 0)
return errors;
List<Isbn> domainIsbns = domainIsbnsResult.Select(isbn => isbn.Value).ToList();
List<Isbn> domainIsbns = [.. domainIsbnsResult.Select(isbn => isbn.Value)];
ErrorOr<ReleaseInfo> releaseInfoResult = ReleaseInfo.Create(
Optional<DateOnly>.FromNullable(request.Metadata.ReleaseInfo!.OriginalReleaseDate),
@@ -41,7 +41,7 @@ public class ChangePasswordCommandHandler : IRequestHandler<ChangePasswordComman
/// <param name="request">The request to be handled.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="ChangePasswordResponse"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="ChangePasswordResponse"/>, or an error message.
/// </returns>
public async ValueTask<ErrorOr<ChangePasswordResponse>> Handle(ChangePasswordCommand request, CancellationToken cancellationToken)
{
@@ -50,7 +50,7 @@ public class RecoverPasswordCommandHandler : IRequestHandler<RecoverPasswordComm
/// <param name="request">The request to be handled.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="RecoverPasswordResponse"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="RecoverPasswordResponse"/>, or an error message.
/// </returns>
public async ValueTask<ErrorOr<RecoverPasswordResponse>> Handle(RecoverPasswordCommand request, CancellationToken cancellationToken)
{
@@ -59,7 +59,7 @@ public class RegisterUserCommandHandler : IRequestHandler<RegisterUserCommand, E
/// <param name="request">The request to be handled.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="RegistrationResponse"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="RegistrationResponse"/>, or an error message.
/// </returns>
public async ValueTask<ErrorOr<RegistrationResponse>> Handle(RegisterUserCommand request, CancellationToken cancellationToken)
{
@@ -59,7 +59,7 @@ public class LoginUserQueryHandler : IRequestHandler<LoginUserQuery, ErrorOr<Log
/// <param name="request">The request to be handled.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly created <see cref="LoginResponse"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully created <see cref="LoginResponse"/>, or an error message.
/// </returns>
public async ValueTask<ErrorOr<LoginResponse>> Handle(LoginUserQuery request, CancellationToken cancellationToken)
{
@@ -48,7 +48,7 @@ public class UpdateUserRoleAndPermissionsCommandHandler : IRequestHandler<Update
/// <param name="request">The request to be handled.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>
/// An <see cref="ErrorOr{TValue}"/> containing either a successfuly updated <see cref="RoleResponse"/>, or an error message.
/// An <see cref="ErrorOr{TValue}"/> containing either a successfully updated <see cref="RoleResponse"/>, or an error message.
/// </returns>
public async ValueTask<ErrorOr<AuthorizationResponse>> Handle(UpdateUserRoleAndPermissionsCommand request, CancellationToken cancellationToken)
{