Skip to content

Commit

Permalink
Migration to .NET 5
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanpaulovich committed Nov 30, 2020
1 parent 20973ff commit 7c98284
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 53 deletions.
3 changes: 1 addition & 2 deletions accounts-api/src/Application/Application.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<NoWarn>$(NoWarn);CA1062;1591</NoWarn>
<Nullable>enable</Nullable>
<NullableReferenceTypes>true</NullableReferenceTypes>
<LangVersion>8.0</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NeutralLanguage>en</NeutralLanguage>
Expand Down
3 changes: 1 addition & 2 deletions accounts-api/src/Domain/Domain.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<NoWarn>$(NoWarn);CA1062;1591</NoWarn>
<Nullable>enable</Nullable>
<NullableReferenceTypes>true</NullableReferenceTypes>
<LangVersion>8.0</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NeutralLanguage>en</NeutralLanguage>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,15 @@ await Task.CompletedTask
/// <inheritdoc />
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);
Expand All @@ -54,7 +59,7 @@ await Task.CompletedTask

public async Task<IAccount> 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)
Expand All @@ -72,7 +77,7 @@ public async Task<IAccount> Find(AccountId accountId, string externalUserId)
/// <inheritdoc />
public async Task<IAccount> GetAccount(AccountId accountId)
{
Account account = this._context
Account? account = this._context
.Accounts
.SingleOrDefault(e => e.AccountId.Equals(accountId));

Expand Down Expand Up @@ -100,7 +105,7 @@ public async Task<IList<Account>> GetAccounts(string externalUserId)
/// <inheritdoc />
public async Task Update(Account account, Credit credit)
{
Account accountOld = this._context
Account? accountOld = this._context
.Accounts
.SingleOrDefault(e => e.AccountId.Equals(account.AccountId));

Expand All @@ -119,7 +124,7 @@ await Task.CompletedTask
/// <inheritdoc />
public async Task Update(Account account, Debit debit)
{
Account accountOld = this._context
Account? accountOld = this._context
.Accounts
.SingleOrDefault(e => e.AccountId.Equals(account.AccountId));

Expand Down
21 changes: 11 additions & 10 deletions accounts-api/src/Infrastructure/Infrastructure.csproj
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<NoWarn>$(NoWarn);CA1062;1591</NoWarn>
<Nullable>enable</Nullable>
<NullableReferenceTypes>true</NullableReferenceTypes>
<LangVersion>8.0</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NeutralLanguage>en</NeutralLanguage>
</PropertyGroup>

<ItemGroup>
<!-- Code Analyzers -->
<PackageReference Include="Microsoft.CodeQuality.Analyzers" Version="3.3.0">
<PackageReference Include="Microsoft.CodeQuality.Analyzers" Version="3.3.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.14.0.22654">
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.15.0.24505">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand All @@ -29,20 +28,22 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.8">
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="5.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.8">
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.8" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
<PackageReference Include="Microsoft.Extensions.Http" Version="3.1.8" />
<PackageReference Include="Microsoft.Extensions.Http" Version="5.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="3.1.8" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="5.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions accounts-api/src/WebApi/Dockerfile
Original file line number Diff line number Diff line change
@@ -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/"]
Expand Down
2 changes: 1 addition & 1 deletion accounts-api/src/WebApi/Modules/Common/ExceptionFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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!;
}
}
}
23 changes: 11 additions & 12 deletions accounts-api/src/WebApi/WebApi.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<NoWarn>$(NoWarn);CA1062;1591;CA1801;S1128;S1481;S1075</NoWarn>
<Nullable>enable</Nullable>
<NullableReferenceTypes>true</NullableReferenceTypes>
<LangVersion>8.0</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NeutralLanguage>en</NeutralLanguage>
Expand Down Expand Up @@ -39,11 +38,11 @@

<ItemGroup>
<!-- Code Analyzers -->
<PackageReference Include="Microsoft.CodeQuality.Analyzers" Version="3.3.0">
<PackageReference Include="Microsoft.CodeQuality.Analyzers" Version="3.3.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.14.0.22654">
<PackageReference Include="SonarAnalyzer.CSharp" Version="8.15.0.24505">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand All @@ -56,19 +55,19 @@

<ItemGroup>
<!-- Microsoft -->
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.8">
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="3.1.8" />
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.PlatformAbstractions" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="4.2.0-rc.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="4.2.0-rc.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.8" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="5.0.0-preview.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="5.0.0-preview.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.0" />
<PackageReference Include="Microsoft.FeatureManagement.AspNetCore" Version="2.2.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.8.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.8" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="3.1.8" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="5.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.9" />
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="3.0.1" />
</ItemGroup>
Expand All @@ -79,7 +78,7 @@
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
<PackageReference Include="EPPlus.Core" Version="1.5.4" />
<!-- Decorator injection comparison https://greatrexpectations.com/2018/10/25/decorators-in-net-core-with-dependency-injection -->
<PackageReference Include="Scrutor" Version="3.2.2" />
<PackageReference Include="Scrutor" Version="3.3.0" />
</ItemGroup>

<ItemGroup>
Expand Down
7 changes: 3 additions & 4 deletions accounts-api/test/ComponentTests/ComponentTests.csproj
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<IsPackable>false</IsPackable>
<Nullable>enable</Nullable>
<NullableReferenceTypes>true</NullableReferenceTypes>
<LangVersion>8.0</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NeutralLanguage>en</NeutralLanguage>
<NoWarn>1591</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0-preview-20200921-01" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.0-preview-20201123-03" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.1.8" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="5.0.0" />
<PackageReference Include="coverlet.msbuild" Version="2.9.0" />
</ItemGroup>

Expand Down
8 changes: 4 additions & 4 deletions accounts-api/test/ComponentTests/V1/SunnyDayTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ private async Task Deposit(string account, decimal amount)
HttpClient client = this._factory.CreateClient();
FormUrlEncodedContent content = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("amount", amount.ToString(CultureInfo.InvariantCulture)),
new KeyValuePair<string, string>("currency", "USD")
new KeyValuePair<string?, string?>("amount", amount.ToString(CultureInfo.InvariantCulture)),
new KeyValuePair<string?, string?>("currency", "USD")
});

HttpResponseMessage response = await client.PatchAsync($"api/v1/Transactions/{account}/Deposit", content)
Expand All @@ -83,8 +83,8 @@ private async Task Withdraw(string account, decimal amount)

FormUrlEncodedContent content = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("amount", amount.ToString(CultureInfo.InvariantCulture)),
new KeyValuePair<string, string>("currency", "USD")
new KeyValuePair<string?, string?>("amount", amount.ToString(CultureInfo.InvariantCulture)),
new KeyValuePair<string?, string?>("currency", "USD")
});

HttpResponseMessage response = await client.PatchAsync($"api/v1/Transactions/{account}/Withdraw", content)
Expand Down
7 changes: 3 additions & 4 deletions accounts-api/test/EndToEndTests/EndToEndTests.csproj
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<IsPackable>false</IsPackable>
<Nullable>enable</Nullable>
<NullableReferenceTypes>true</NullableReferenceTypes>
<LangVersion>8.0</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NeutralLanguage>en</NeutralLanguage>
<NoWarn>1591</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0-preview-20200921-01" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.0-preview-20201123-03" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.1.8" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="5.0.0" />
<PackageReference Include="coverlet.msbuild" Version="2.9.0" />
</ItemGroup>

Expand Down
7 changes: 3 additions & 4 deletions accounts-api/test/IntegrationTests/IntegrationTests.csproj
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<IsPackable>false</IsPackable>
<Nullable>enable</Nullable>
<NullableReferenceTypes>true</NullableReferenceTypes>
<LangVersion>8.0</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NeutralLanguage>en</NeutralLanguage>
<NoWarn>1591</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.8" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0-preview-20200921-01" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="5.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.0-preview-20201123-03" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
Expand Down
5 changes: 2 additions & 3 deletions accounts-api/test/UnitTests/UnitTests.csproj
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
<IsPackable>false</IsPackable>
<Nullable>enable</Nullable>
<NullableReferenceTypes>true</NullableReferenceTypes>
<LangVersion>8.0</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NeutralLanguage>en</NeutralLanguage>
<NoWarn>1591</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0-preview-20200921-01" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.0-preview-20201123-03" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
Expand Down

0 comments on commit 7c98284

Please sign in to comment.