Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: fix build warnings #7

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Api/Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
<CodeAnalysisTreatWarningsAsErrors>false</CodeAnalysisTreatWarningsAsErrors>
</PropertyGroup>

<!-- Workaround for https://github.com/dotnet/roslyn/issues/41640 -->
<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);CS1591;CS1573</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentValidation.AspNetCore" Version="11.2.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.4">
Expand Down
4 changes: 3 additions & 1 deletion src/Api/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,6 @@
app.UseAuthorization();
app.MapControllers();

app.Run();
app.Run();

public partial class Program { }
6 changes: 6 additions & 0 deletions src/Application/Application.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
<CodeAnalysisTreatWarningsAsErrors>false</CodeAnalysisTreatWarningsAsErrors>
</PropertyGroup>

<!-- Workaround for https://github.com/dotnet/roslyn/issues/41640 -->
<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);CS1591;CS1573</NoWarn>
</PropertyGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Application/Common/AuditableEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ public abstract class AuditableEntity
public DateTime? LastModified { get; set; }

public string? LastModifiedBy { get; set; }
}
}
2 changes: 1 addition & 1 deletion src/Application/Common/Behaviours/PerformanceBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ public async Task<TResponse> Handle(TRequest request, RequestHandlerDelegate<TRe

return response;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ public async Task<TResponse> Handle(TRequest request, RequestHandlerDelegate<TRe
throw;
}
}
}
}
2 changes: 1 addition & 1 deletion src/Application/Common/Behaviours/ValidationBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ public async Task<TResponse> Handle(TRequest request, RequestHandlerDelegate<TRe
}
return await next();
}
}
}
2 changes: 1 addition & 1 deletion src/Application/Common/DomainEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ protected DomainEvent()
}
public bool IsPublished { get; set; }
public DateTimeOffset DateOccurred { get; protected set; } = DateTime.UtcNow;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ public ForbiddenAccessException(string? message, Exception? innerException) : ba
protected ForbiddenAccessException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
}
2 changes: 1 addition & 1 deletion src/Application/Common/Exceptions/NotFoundException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ public NotFoundException(string name, object key)
: base($"Entity '{name}' ({key}) was not found.")
{
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ public UnsupportedColourException(string? message, Exception? innerException) :
protected UnsupportedColourException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
}
}
2 changes: 1 addition & 1 deletion src/Application/Common/Exceptions/ValidationException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ public ValidationException(IEnumerable<ValidationFailure> failures)
}

public IDictionary<string, string[]> Errors { get; }
}
}
2 changes: 1 addition & 1 deletion src/Application/Common/Interfaces/ICsvFileBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ namespace VerticalSliceArchitecture.Application.Common.Interfaces;
public interface ICsvFileBuilder
{
byte[] BuildTodoItemsFile(IEnumerable<TodoItemRecord> records);
}
}
2 changes: 1 addition & 1 deletion src/Application/Common/Interfaces/ICurrentUserService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
public interface ICurrentUserService
{
string? UserId { get; }
}
}
2 changes: 1 addition & 1 deletion src/Application/Common/Interfaces/IDateTime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
public interface IDateTime
{
DateTime Now { get; }
}
}
2 changes: 1 addition & 1 deletion src/Application/Common/Interfaces/IDomainEventService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
public interface IDomainEventService
{
Task Publish(DomainEvent domainEvent);
}
}
2 changes: 1 addition & 1 deletion src/Application/Common/Mappings/IMapFrom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ void Mapping(Profile profile)
{
profile.CreateMap(typeof(T), GetType());
}
}
}
2 changes: 1 addition & 1 deletion src/Application/Common/Mappings/MappingExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ public static Task<List<TDestination>> ProjectToListAsync<TDestination>(this IQu
{
return queryable.ProjectTo<TDestination>(configuration).ToListAsync();
}
}
}
2 changes: 1 addition & 1 deletion src/Application/Common/Mappings/MappingProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ private void ApplyMappingsFromAssembly(Assembly assembly)

}
}
}
}
2 changes: 1 addition & 1 deletion src/Application/Common/Models/DomainEventNotification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ public DomainEventNotification(TDomainEvent domainEvent)
}

public TDomainEvent DomainEvent { get; }
}
}
2 changes: 1 addition & 1 deletion src/Application/Common/Models/PaginatedList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ public static async Task<PaginatedList<T>> CreateAsync(IQueryable<T> source, int

return new PaginatedList<T>(items, count, pageNumber, pageSize);
}
}
}
2 changes: 1 addition & 1 deletion src/Application/Common/Models/Result.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ public static Result Failure(IEnumerable<string> errors)
{
return new Result(false, errors);
}
}
}
2 changes: 1 addition & 1 deletion src/Application/Common/Security/AuthorizeAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ public AuthorizeAttribute() { }
/// Gets or sets the policy name that determines access to the resource.
/// </summary>
public string Policy { get; set; } = string.Empty;
}
}
2 changes: 1 addition & 1 deletion src/Application/Common/ValueObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ public override int GetHashCode()
.Select(x => x != null ? x.GetHashCode() : 0)
.Aggregate((x, y) => x ^ y);
}
}
}
2 changes: 1 addition & 1 deletion src/Application/ConfigureServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ public static IServiceCollection AddInfrastructure(this IServiceCollection servi

return services;
}
}
}
2 changes: 1 addition & 1 deletion src/Application/Domain/Todos/TodoItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ public class TodoItemRecord : IMapFrom<TodoItem>
public string? Title { get; set; }

public bool Done { get; set; }
}
}
2 changes: 1 addition & 1 deletion src/Application/Domain/Todos/TodoList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ public class TodoList : AuditableEntity
public Colour Colour { get; set; } = Colour.White;

public IList<TodoItem> Items { get; private set; } = new List<TodoItem>();
}
}
2 changes: 1 addition & 1 deletion src/Application/Domain/ValueObjects/Colour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ protected override IEnumerable<object> GetEqualityComponents()
{
yield return Code;
}
}
}
8 changes: 1 addition & 7 deletions src/Application/Features/TodoItems/DeleteTodoItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,7 @@ public DeleteTodoItemCommandHandler(ApplicationDbContext context)
public async Task<Unit> Handle(DeleteTodoItemCommand request, CancellationToken cancellationToken)
{
var entity = await _context.TodoItems
.FindAsync(new object[] { request.Id }, cancellationToken);

if (entity == null)
{
throw new NotFoundException(nameof(TodoItem), request.Id);
}

.FindAsync(new object[] { request.Id }, cancellationToken) ?? throw new NotFoundException(nameof(TodoItem), request.Id);
_context.TodoItems.Remove(entity);

entity.DomainEvents.Add(new TodoItemDeletedEvent(entity));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ public Task Handle(DomainEventNotification<TodoItemCompletedEvent> notification,

return Task.CompletedTask;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ public Task Handle(DomainEventNotification<TodoItemCreatedEvent> notification, C

return Task.CompletedTask;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ public class TodoItemBriefDto : IMapFrom<TodoItem>
public string? Title { get; set; }

public bool Done { get; set; }
}
}
7 changes: 1 addition & 6 deletions src/Application/Features/TodoItems/UpdateTodoItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,7 @@ public UpdateTodoItemCommandHandler(ApplicationDbContext context)
public async Task<Unit> Handle(UpdateTodoItemCommand request, CancellationToken cancellationToken)
{
var entity = await _context.TodoItems
.FindAsync(new object[] { request.Id }, cancellationToken);

if (entity == null)
{
throw new NotFoundException(nameof(TodoItem), request.Id);
}
.FindAsync(new object[] { request.Id }, cancellationToken) ?? throw new NotFoundException(nameof(TodoItem), request.Id);

entity.Title = request.Title;
entity.Done = request.Done;
Expand Down
7 changes: 1 addition & 6 deletions src/Application/Features/TodoItems/UpdateTodoItemDetail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,7 @@ public UpdateTodoItemDetailCommandHandler(ApplicationDbContext context)
public async Task<Unit> Handle(UpdateTodoItemDetailCommand request, CancellationToken cancellationToken)
{
var entity = await _context.TodoItems
.FindAsync(new object[] { request.Id }, cancellationToken);

if (entity == null)
{
throw new NotFoundException(nameof(TodoItem), request.Id);
}
.FindAsync(new object[] { request.Id }, cancellationToken) ?? throw new NotFoundException(nameof(TodoItem), request.Id);

entity.ListId = request.ListId;
entity.Priority = request.Priority;
Expand Down
2 changes: 1 addition & 1 deletion src/Application/Features/TodoLists/CreateTodoList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ public async Task<int> Handle(CreateTodoListCommand request, CancellationToken c

return entity.Id;
}
}
}
9 changes: 2 additions & 7 deletions src/Application/Features/TodoLists/DeleteTodoList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,12 @@ public async Task<Unit> Handle(DeleteTodoListCommand request, CancellationToken
{
var entity = await _context.TodoLists
.Where(l => l.Id == request.Id)
.SingleOrDefaultAsync(cancellationToken);

if (entity == null)
{
throw new NotFoundException(nameof(TodoList), request.Id);
}
.SingleOrDefaultAsync(cancellationToken) ?? throw new NotFoundException(nameof(TodoList), request.Id);

_context.TodoLists.Remove(entity);

await _context.SaveChangesAsync(cancellationToken);

return Unit.Value;
}
}
}
2 changes: 1 addition & 1 deletion src/Application/Features/TodoLists/ExportTodos.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ public async Task<ExportTodosVm> Handle(ExportTodosQuery request, CancellationTo

return vm;
}
}
}
2 changes: 1 addition & 1 deletion src/Application/Features/TodoLists/GetTodos.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,4 @@ public async Task<TodosVm> Handle(GetTodosQuery request, CancellationToken cance
.ToListAsync(cancellationToken)
};
}
}
}
9 changes: 2 additions & 7 deletions src/Application/Features/TodoLists/UpdateTodoList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,12 @@ public async Task<Unit> Handle(UpdateTodoListCommand request, CancellationToken
{
var entity = await _context.TodoLists
.FindAsync(new object[] { request.Id }, cancellationToken)
.ConfigureAwait(false);

if (entity == null)
{
throw new NotFoundException(nameof(TodoList), request.Id);
}
.ConfigureAwait(false) ?? throw new NotFoundException(nameof(TodoList), request.Id);

entity.Title = request.Title;

await _context.SaveChangesAsync(cancellationToken);

return Unit.Value;
}
}
}
2 changes: 1 addition & 1 deletion src/Application/Infrastructure/Files/CsvFileBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ public byte[] BuildTodoItemsFile(IEnumerable<TodoItemRecord> records)

return memoryStream.ToArray();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ public TodoItemRecordMap()

Map(m => m.Done).ConvertUsing(c => c.Done ? "Yes" : "No");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ private async Task DispatchEvents(DomainEvent[] events)
await _domainEventService.Publish(@event);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ public static async Task SeedSampleDataAsync(ApplicationDbContext context)
await context.SaveChangesAsync();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ public void Configure(EntityTypeBuilder<TodoItem> builder)
.HasMaxLength(200)
.IsRequired();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ public void Configure(EntityTypeBuilder<TodoList> builder)
builder
.OwnsOne(b => b.Colour);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ protected override void Down(MigrationBuilder migrationBuilder)
name: "TodoLists");
}
}
}
}
2 changes: 1 addition & 1 deletion src/Application/Infrastructure/Services/DateTimeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ namespace VerticalSliceArchitecture.Application.Infrastructure.Services;
public class DateTimeService : IDateTime
{
public DateTime Now => DateTime.Now;
}
}
Loading
Loading