Skip to content

Commit 3630214

Browse files
committed
refactor: fix build warnings
1 parent 2ad4532 commit 3630214

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+62
-74
lines changed

src/Api/Api.csproj

+6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313
<CodeAnalysisTreatWarningsAsErrors>false</CodeAnalysisTreatWarningsAsErrors>
1414
</PropertyGroup>
1515

16+
<!-- Workaround for https://github.com/dotnet/roslyn/issues/41640 -->
17+
<PropertyGroup>
18+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
19+
<NoWarn>$(NoWarn);CS1591;CS1573</NoWarn>
20+
</PropertyGroup>
21+
1622
<ItemGroup>
1723
<PackageReference Include="FluentValidation.AspNetCore" Version="11.2.2" />
1824
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.4">

src/Api/Program.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,6 @@
5555
app.UseAuthorization();
5656
app.MapControllers();
5757

58-
app.Run();
58+
app.Run();
59+
60+
public partial class Program { }

src/Application/Application.csproj

+6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212
<CodeAnalysisTreatWarningsAsErrors>false</CodeAnalysisTreatWarningsAsErrors>
1313
</PropertyGroup>
1414

15+
<!-- Workaround for https://github.com/dotnet/roslyn/issues/41640 -->
16+
<PropertyGroup>
17+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
18+
<NoWarn>$(NoWarn);CS1591;CS1573</NoWarn>
19+
</PropertyGroup>
20+
1521
<ItemGroup>
1622
<FrameworkReference Include="Microsoft.AspNetCore.App" />
1723
</ItemGroup>

src/Application/Common/AuditableEntity.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ public abstract class AuditableEntity
99
public DateTime? LastModified { get; set; }
1010

1111
public string? LastModifiedBy { get; set; }
12-
}
12+
}

src/Application/Common/Behaviours/PerformanceBehaviour.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ public async Task<TResponse> Handle(TRequest request, RequestHandlerDelegate<TRe
4545

4646
return response;
4747
}
48-
}
48+
}

src/Application/Common/Behaviours/UnhandledExceptionBehaviour.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ public async Task<TResponse> Handle(TRequest request, RequestHandlerDelegate<TRe
2828
throw;
2929
}
3030
}
31-
}
31+
}

src/Application/Common/Behaviours/ValidationBehaviour.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ public async Task<TResponse> Handle(TRequest request, RequestHandlerDelegate<TRe
3232
}
3333
return await next();
3434
}
35-
}
35+
}

src/Application/Common/DomainEvent.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ protected DomainEvent()
1313
}
1414
public bool IsPublished { get; set; }
1515
public DateTimeOffset DateOccurred { get; protected set; } = DateTime.UtcNow;
16-
}
16+
}

src/Application/Common/Exceptions/ForbiddenAccessException.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ public ForbiddenAccessException(string? message, Exception? innerException) : ba
1717
protected ForbiddenAccessException(SerializationInfo info, StreamingContext context) : base(info, context)
1818
{
1919
}
20-
}
20+
}

src/Application/Common/Exceptions/NotFoundException.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ public NotFoundException(string name, object key)
2121
: base($"Entity '{name}' ({key}) was not found.")
2222
{
2323
}
24-
}
24+
}

src/Application/Common/Exceptions/UnsupportedColourException.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ public UnsupportedColourException(string? message, Exception? innerException) :
2020
protected UnsupportedColourException(SerializationInfo info, StreamingContext context) : base(info, context)
2121
{
2222
}
23-
}
23+
}

src/Application/Common/Exceptions/ValidationException.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ public ValidationException(IEnumerable<ValidationFailure> failures)
1919
}
2020

2121
public IDictionary<string, string[]> Errors { get; }
22-
}
22+
}

src/Application/Common/Interfaces/ICsvFileBuilder.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ namespace VerticalSliceArchitecture.Application.Common.Interfaces;
55
public interface ICsvFileBuilder
66
{
77
byte[] BuildTodoItemsFile(IEnumerable<TodoItemRecord> records);
8-
}
8+
}

src/Application/Common/Interfaces/ICurrentUserService.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
public interface ICurrentUserService
44
{
55
string? UserId { get; }
6-
}
6+
}

src/Application/Common/Interfaces/IDateTime.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
public interface IDateTime
44
{
55
DateTime Now { get; }
6-
}
6+
}

src/Application/Common/Interfaces/IDomainEventService.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
public interface IDomainEventService
44
{
55
Task Publish(DomainEvent domainEvent);
6-
}
6+
}

src/Application/Common/Mappings/IMapFrom.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ void Mapping(Profile profile)
88
{
99
profile.CreateMap(typeof(T), GetType());
1010
}
11-
}
11+
}

src/Application/Common/Mappings/MappingExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ public static Task<List<TDestination>> ProjectToListAsync<TDestination>(this IQu
1818
{
1919
return queryable.ProjectTo<TDestination>(configuration).ToListAsync();
2020
}
21-
}
21+
}

src/Application/Common/Mappings/MappingProfile.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ private void ApplyMappingsFromAssembly(Assembly assembly)
2929

3030
}
3131
}
32-
}
32+
}

src/Application/Common/Models/DomainEventNotification.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ public DomainEventNotification(TDomainEvent domainEvent)
1010
}
1111

1212
public TDomainEvent DomainEvent { get; }
13-
}
13+
}

src/Application/Common/Models/PaginatedList.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ public static async Task<PaginatedList<T>> CreateAsync(IQueryable<T> source, int
2828

2929
return new PaginatedList<T>(items, count, pageNumber, pageSize);
3030
}
31-
}
31+
}

src/Application/Common/Models/Result.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ public static Result Failure(IEnumerable<string> errors)
2121
{
2222
return new Result(false, errors);
2323
}
24-
}
24+
}

src/Application/Common/Security/AuthorizeAttribute.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ public AuthorizeAttribute() { }
2020
/// Gets or sets the policy name that determines access to the resource.
2121
/// </summary>
2222
public string Policy { get; set; } = string.Empty;
23-
}
23+
}

src/Application/Common/ValueObject.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ public override int GetHashCode()
3939
.Select(x => x != null ? x.GetHashCode() : 0)
4040
.Aggregate((x, y) => x ^ y);
4141
}
42-
}
42+
}

src/Application/ConfigureServices.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,4 @@ public static IServiceCollection AddInfrastructure(this IServiceCollection servi
5555

5656
return services;
5757
}
58-
}
58+
}

src/Application/Domain/Todos/TodoItem.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@ public class TodoItemRecord : IMapFrom<TodoItem>
6060
public string? Title { get; set; }
6161

6262
public bool Done { get; set; }
63-
}
63+
}

src/Application/Domain/Todos/TodoList.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ public class TodoList : AuditableEntity
1212
public Colour Colour { get; set; } = Colour.White;
1313

1414
public IList<TodoItem> Items { get; private set; } = new List<TodoItem>();
15-
}
15+
}

src/Application/Domain/ValueObjects/Colour.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,4 @@ protected override IEnumerable<object> GetEqualityComponents()
7777
{
7878
yield return Code;
7979
}
80-
}
80+
}

src/Application/Features/TodoItems/DeleteTodoItem.cs

+1-7
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,7 @@ public DeleteTodoItemCommandHandler(ApplicationDbContext context)
3737
public async Task<Unit> Handle(DeleteTodoItemCommand request, CancellationToken cancellationToken)
3838
{
3939
var entity = await _context.TodoItems
40-
.FindAsync(new object[] { request.Id }, cancellationToken);
41-
42-
if (entity == null)
43-
{
44-
throw new NotFoundException(nameof(TodoItem), request.Id);
45-
}
46-
40+
.FindAsync(new object[] { request.Id }, cancellationToken) ?? throw new NotFoundException(nameof(TodoItem), request.Id);
4741
_context.TodoItems.Remove(entity);
4842

4943
entity.DomainEvents.Add(new TodoItemDeletedEvent(entity));

src/Application/Features/TodoItems/EventHandlers/TodoItemCompletedEventHandler.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ public Task Handle(DomainEventNotification<TodoItemCompletedEvent> notification,
2424

2525
return Task.CompletedTask;
2626
}
27-
}
27+
}

src/Application/Features/TodoItems/EventHandlers/TodoItemCreatedEventHandler.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ public Task Handle(DomainEventNotification<TodoItemCreatedEvent> notification, C
2323

2424
return Task.CompletedTask;
2525
}
26-
}
26+
}

src/Application/Features/TodoItems/GetTodoItemsWithPagination.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,4 @@ public class TodoItemBriefDto : IMapFrom<TodoItem>
7676
public string? Title { get; set; }
7777

7878
public bool Done { get; set; }
79-
}
79+
}

src/Application/Features/TodoItems/UpdateTodoItem.cs

+1-6
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,7 @@ public UpdateTodoItemCommandHandler(ApplicationDbContext context)
5858
public async Task<Unit> Handle(UpdateTodoItemCommand request, CancellationToken cancellationToken)
5959
{
6060
var entity = await _context.TodoItems
61-
.FindAsync(new object[] { request.Id }, cancellationToken);
62-
63-
if (entity == null)
64-
{
65-
throw new NotFoundException(nameof(TodoItem), request.Id);
66-
}
61+
.FindAsync(new object[] { request.Id }, cancellationToken) ?? throw new NotFoundException(nameof(TodoItem), request.Id);
6762

6863
entity.Title = request.Title;
6964
entity.Done = request.Done;

src/Application/Features/TodoItems/UpdateTodoItemDetail.cs

+1-6
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,7 @@ public UpdateTodoItemDetailCommandHandler(ApplicationDbContext context)
4848
public async Task<Unit> Handle(UpdateTodoItemDetailCommand request, CancellationToken cancellationToken)
4949
{
5050
var entity = await _context.TodoItems
51-
.FindAsync(new object[] { request.Id }, cancellationToken);
52-
53-
if (entity == null)
54-
{
55-
throw new NotFoundException(nameof(TodoItem), request.Id);
56-
}
51+
.FindAsync(new object[] { request.Id }, cancellationToken) ?? throw new NotFoundException(nameof(TodoItem), request.Id);
5752

5853
entity.ListId = request.ListId;
5954
entity.Priority = request.Priority;

src/Application/Features/TodoLists/CreateTodoList.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,4 @@ public async Task<int> Handle(CreateTodoListCommand request, CancellationToken c
6565

6666
return entity.Id;
6767
}
68-
}
68+
}

src/Application/Features/TodoLists/DeleteTodoList.cs

+2-7
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,12 @@ public async Task<Unit> Handle(DeleteTodoListCommand request, CancellationToken
3939
{
4040
var entity = await _context.TodoLists
4141
.Where(l => l.Id == request.Id)
42-
.SingleOrDefaultAsync(cancellationToken);
43-
44-
if (entity == null)
45-
{
46-
throw new NotFoundException(nameof(TodoList), request.Id);
47-
}
42+
.SingleOrDefaultAsync(cancellationToken) ?? throw new NotFoundException(nameof(TodoList), request.Id);
4843

4944
_context.TodoLists.Remove(entity);
5045

5146
await _context.SaveChangesAsync(cancellationToken);
5247

5348
return Unit.Value;
5449
}
55-
}
50+
}

src/Application/Features/TodoLists/ExportTodos.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,4 @@ public async Task<ExportTodosVm> Handle(ExportTodosQuery request, CancellationTo
7272

7373
return vm;
7474
}
75-
}
75+
}

src/Application/Features/TodoLists/GetTodos.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,4 @@ public async Task<TodosVm> Handle(GetTodosQuery request, CancellationToken cance
104104
.ToListAsync(cancellationToken)
105105
};
106106
}
107-
}
107+
}

src/Application/Features/TodoLists/UpdateTodoList.cs

+2-7
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,12 @@ public async Task<Unit> Handle(UpdateTodoListCommand request, CancellationToken
7070
{
7171
var entity = await _context.TodoLists
7272
.FindAsync(new object[] { request.Id }, cancellationToken)
73-
.ConfigureAwait(false);
74-
75-
if (entity == null)
76-
{
77-
throw new NotFoundException(nameof(TodoList), request.Id);
78-
}
73+
.ConfigureAwait(false) ?? throw new NotFoundException(nameof(TodoList), request.Id);
7974

8075
entity.Title = request.Title;
8176

8277
await _context.SaveChangesAsync(cancellationToken);
8378

8479
return Unit.Value;
8580
}
86-
}
81+
}

src/Application/Infrastructure/Files/CsvFileBuilder.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ public byte[] BuildTodoItemsFile(IEnumerable<TodoItemRecord> records)
2323

2424
return memoryStream.ToArray();
2525
}
26-
}
26+
}

src/Application/Infrastructure/Files/Maps/TodoItemRecordMap.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ public TodoItemRecordMap()
1414

1515
Map(m => m.Done).ConvertUsing(c => c.Done ? "Yes" : "No");
1616
}
17-
}
17+
}

src/Application/Infrastructure/Persistence/ApplicationDbContext.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,4 @@ private async Task DispatchEvents(DomainEvent[] events)
8383
await _domainEventService.Publish(@event);
8484
}
8585
}
86-
}
86+
}

src/Application/Infrastructure/Persistence/ApplicationDbContextSeed.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ public static async Task SeedSampleDataAsync(ApplicationDbContext context)
3030
await context.SaveChangesAsync();
3131
}
3232
}
33-
}
33+
}

src/Application/Infrastructure/Persistence/Configurations/TodoItemConfiguration.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ public void Configure(EntityTypeBuilder<TodoItem> builder)
1515
.HasMaxLength(200)
1616
.IsRequired();
1717
}
18-
}
18+
}

src/Application/Infrastructure/Persistence/Configurations/TodoListConfiguration.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ public void Configure(EntityTypeBuilder<TodoList> builder)
1616
builder
1717
.OwnsOne(b => b.Colour);
1818
}
19-
}
19+
}

src/Application/Infrastructure/Persistence/Migrations/20220322201554_InitialMigration.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,4 @@ protected override void Down(MigrationBuilder migrationBuilder)
6666
name: "TodoLists");
6767
}
6868
}
69-
}
69+
}

src/Application/Infrastructure/Services/DateTimeService.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ namespace VerticalSliceArchitecture.Application.Infrastructure.Services;
55
public class DateTimeService : IDateTime
66
{
77
public DateTime Now => DateTime.Now;
8-
}
8+
}

0 commit comments

Comments
 (0)