From 7c98284a428d854392d27cc496e23a577ed3e725 Mon Sep 17 00:00:00 2001 From: Ivan Paulovich Date: Mon, 30 Nov 2020 20:35:49 +0100 Subject: [PATCH] Migration to .NET 5 --- .../src/Application/Application.csproj | 3 +-- accounts-api/src/Domain/Domain.csproj | 3 +-- .../Repositories/AccountRepositoryFake.cs | 15 ++++++++---- .../src/Infrastructure/Infrastructure.csproj | 21 +++++++++-------- accounts-api/src/WebApi/Dockerfile | 4 ++-- .../WebApi/Modules/Common/ExceptionFilter.cs | 2 +- accounts-api/src/WebApi/WebApi.csproj | 23 +++++++++---------- .../test/ComponentTests/ComponentTests.csproj | 7 +++--- .../test/ComponentTests/V1/SunnyDayTests.cs | 8 +++---- .../test/EndToEndTests/EndToEndTests.csproj | 7 +++--- .../IntegrationTests/IntegrationTests.csproj | 7 +++--- accounts-api/test/UnitTests/UnitTests.csproj | 5 ++-- 12 files changed, 52 insertions(+), 53 deletions(-) diff --git a/accounts-api/src/Application/Application.csproj b/accounts-api/src/Application/Application.csproj index 91bb11ec..149646b9 100644 --- a/accounts-api/src/Application/Application.csproj +++ b/accounts-api/src/Application/Application.csproj @@ -1,10 +1,9 @@  - netcoreapp3.1 + net5.0 $(NoWarn);CA1062;1591 enable true - 8.0 true true en diff --git a/accounts-api/src/Domain/Domain.csproj b/accounts-api/src/Domain/Domain.csproj index 3522805a..2f021d44 100644 --- a/accounts-api/src/Domain/Domain.csproj +++ b/accounts-api/src/Domain/Domain.csproj @@ -1,10 +1,9 @@  - netcoreapp3.1 + net5.0 $(NoWarn);CA1062;1591 enable true - 8.0 true true en diff --git a/accounts-api/src/Infrastructure/DataAccess/Repositories/AccountRepositoryFake.cs b/accounts-api/src/Infrastructure/DataAccess/Repositories/AccountRepositoryFake.cs index 6d52b2e0..95f45c0d 100644 --- a/accounts-api/src/Infrastructure/DataAccess/Repositories/AccountRepositoryFake.cs +++ b/accounts-api/src/Infrastructure/DataAccess/Repositories/AccountRepositoryFake.cs @@ -40,10 +40,15 @@ await Task.CompletedTask /// public async Task Delete(AccountId accountId) { - Account accountOld = this._context + Account? accountOld = this._context .Accounts .SingleOrDefault(e => e.AccountId.Equals(accountId)); + if (accountOld == null) + { + return; + } + this._context .Accounts .Remove(accountOld); @@ -54,7 +59,7 @@ await Task.CompletedTask public async Task Find(AccountId accountId, string externalUserId) { - Account account = this._context + Account? account = this._context .Accounts .Where(e => e.ExternalUserId == externalUserId && e.AccountId.Equals(accountId)) .Select(e => e) @@ -72,7 +77,7 @@ public async Task Find(AccountId accountId, string externalUserId) /// public async Task GetAccount(AccountId accountId) { - Account account = this._context + Account? account = this._context .Accounts .SingleOrDefault(e => e.AccountId.Equals(accountId)); @@ -100,7 +105,7 @@ public async Task> GetAccounts(string externalUserId) /// public async Task Update(Account account, Credit credit) { - Account accountOld = this._context + Account? accountOld = this._context .Accounts .SingleOrDefault(e => e.AccountId.Equals(account.AccountId)); @@ -119,7 +124,7 @@ await Task.CompletedTask /// public async Task Update(Account account, Debit debit) { - Account accountOld = this._context + Account? accountOld = this._context .Accounts .SingleOrDefault(e => e.AccountId.Equals(account.AccountId)); diff --git a/accounts-api/src/Infrastructure/Infrastructure.csproj b/accounts-api/src/Infrastructure/Infrastructure.csproj index 21d52a06..84c4d744 100644 --- a/accounts-api/src/Infrastructure/Infrastructure.csproj +++ b/accounts-api/src/Infrastructure/Infrastructure.csproj @@ -1,11 +1,10 @@  - netcoreapp3.1 + net5.0 $(NoWarn);CA1062;1591 enable true - 8.0 true true en @@ -13,11 +12,11 @@ - + all runtime; build; native; contentfiles; analyzers - + all runtime; build; native; contentfiles; analyzers @@ -29,20 +28,22 @@ - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + all runtime; build; native; contentfiles; analyzers - + - + - + diff --git a/accounts-api/src/WebApi/Dockerfile b/accounts-api/src/WebApi/Dockerfile index 13121cc5..8b606363 100644 --- a/accounts-api/src/WebApi/Dockerfile +++ b/accounts-api/src/WebApi/Dockerfile @@ -1,11 +1,11 @@ #See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging. -FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base +FROM mcr.microsoft.com/dotnet/aspnet:5.0-alpine AS base WORKDIR /app EXPOSE 80 EXPOSE 443 -FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build +FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build WORKDIR /src COPY ["src/WebApi/WebApi.csproj", "src/WebApi/"] COPY ["src/Application/Application.csproj", "src/Application/"] diff --git a/accounts-api/src/WebApi/Modules/Common/ExceptionFilter.cs b/accounts-api/src/WebApi/Modules/Common/ExceptionFilter.cs index 2c5a1f46..45dbeab8 100644 --- a/accounts-api/src/WebApi/Modules/Common/ExceptionFilter.cs +++ b/accounts-api/src/WebApi/Modules/Common/ExceptionFilter.cs @@ -16,7 +16,7 @@ public void OnException(ExceptionContext context) ProblemDetails problemDetails = new ProblemDetails {Status = 500, Title = "Bad Request"}; context.Result = new JsonResult(problemDetails); - context.Exception = null; + context.Exception = null!; } } } diff --git a/accounts-api/src/WebApi/WebApi.csproj b/accounts-api/src/WebApi/WebApi.csproj index 2cbfeb86..82969ff7 100644 --- a/accounts-api/src/WebApi/WebApi.csproj +++ b/accounts-api/src/WebApi/WebApi.csproj @@ -1,11 +1,10 @@  - netcoreapp3.1 + net5.0 $(NoWarn);CA1062;1591;CA1801;S1128;S1481;S1075 enable true - 8.0 true true en @@ -39,11 +38,11 @@ - + all runtime; build; native; contentfiles; analyzers - + all runtime; build; native; contentfiles; analyzers @@ -56,19 +55,19 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - - - + + + - - + + @@ -79,7 +78,7 @@ - + diff --git a/accounts-api/test/ComponentTests/ComponentTests.csproj b/accounts-api/test/ComponentTests/ComponentTests.csproj index 1d986a68..dfaf3854 100644 --- a/accounts-api/test/ComponentTests/ComponentTests.csproj +++ b/accounts-api/test/ComponentTests/ComponentTests.csproj @@ -1,11 +1,10 @@  - netcoreapp3.1 + net5.0 false enable true - 8.0 true true en @@ -13,13 +12,13 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/accounts-api/test/ComponentTests/V1/SunnyDayTests.cs b/accounts-api/test/ComponentTests/V1/SunnyDayTests.cs index 50494dc5..13185cae 100644 --- a/accounts-api/test/ComponentTests/V1/SunnyDayTests.cs +++ b/accounts-api/test/ComponentTests/V1/SunnyDayTests.cs @@ -63,8 +63,8 @@ private async Task Deposit(string account, decimal amount) HttpClient client = this._factory.CreateClient(); FormUrlEncodedContent content = new FormUrlEncodedContent(new[] { - new KeyValuePair("amount", amount.ToString(CultureInfo.InvariantCulture)), - new KeyValuePair("currency", "USD") + new KeyValuePair("amount", amount.ToString(CultureInfo.InvariantCulture)), + new KeyValuePair("currency", "USD") }); HttpResponseMessage response = await client.PatchAsync($"api/v1/Transactions/{account}/Deposit", content) @@ -83,8 +83,8 @@ private async Task Withdraw(string account, decimal amount) FormUrlEncodedContent content = new FormUrlEncodedContent(new[] { - new KeyValuePair("amount", amount.ToString(CultureInfo.InvariantCulture)), - new KeyValuePair("currency", "USD") + new KeyValuePair("amount", amount.ToString(CultureInfo.InvariantCulture)), + new KeyValuePair("currency", "USD") }); HttpResponseMessage response = await client.PatchAsync($"api/v1/Transactions/{account}/Withdraw", content) diff --git a/accounts-api/test/EndToEndTests/EndToEndTests.csproj b/accounts-api/test/EndToEndTests/EndToEndTests.csproj index 1d986a68..dfaf3854 100644 --- a/accounts-api/test/EndToEndTests/EndToEndTests.csproj +++ b/accounts-api/test/EndToEndTests/EndToEndTests.csproj @@ -1,11 +1,10 @@  - netcoreapp3.1 + net5.0 false enable true - 8.0 true true en @@ -13,13 +12,13 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/accounts-api/test/IntegrationTests/IntegrationTests.csproj b/accounts-api/test/IntegrationTests/IntegrationTests.csproj index ba9d5236..c4eeb4f6 100644 --- a/accounts-api/test/IntegrationTests/IntegrationTests.csproj +++ b/accounts-api/test/IntegrationTests/IntegrationTests.csproj @@ -1,11 +1,10 @@  - netcoreapp3.1 + net5.0 false enable true - 8.0 true true en @@ -13,8 +12,8 @@ - - + + all diff --git a/accounts-api/test/UnitTests/UnitTests.csproj b/accounts-api/test/UnitTests/UnitTests.csproj index c04049c2..b2ea7083 100644 --- a/accounts-api/test/UnitTests/UnitTests.csproj +++ b/accounts-api/test/UnitTests/UnitTests.csproj @@ -1,11 +1,10 @@  - netcoreapp3.1 + net5.0 false enable true - 8.0 true true en @@ -13,7 +12,7 @@ - + all