Merge pull request #17 from jeangatto/feat/net_core_9_upgrade

feat: upgrade solution to net 9
This commit is contained in:
Jean Francisco Flores Gatto
2024-12-11 17:07:35 -03:00
committed by GitHub
26 changed files with 336 additions and 75 deletions
+6
View File
@@ -1,3 +1,4 @@
# https://github.com/github/codeql-action
name: "CodeQL" name: "CodeQL"
on: on:
@@ -31,6 +32,11 @@ jobs:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: "9.0.x"
- name: Initialize CodeQL - name: Initialize CodeQL
uses: github/codeql-action/init@v3 uses: github/codeql-action/init@v3
with: with:
+1
View File
@@ -1,3 +1,4 @@
# https://github.com/microsoft/DevSkim-Action
name: DevSkim name: DevSkim
on: on:
+2 -2
View File
@@ -1,3 +1,4 @@
# https://github.com/actions/setup-dotnet
name: Build name: Build
on: on:
@@ -13,7 +14,6 @@ on:
- "**/*.yml" - "**/*.yml"
env: env:
DOTNET_VERSION: "8.0.x"
DOTNET_NOLOGO: true DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
@@ -32,7 +32,7 @@ jobs:
- name: Setup .NET - name: Setup .NET
uses: actions/setup-dotnet@v4 uses: actions/setup-dotnet@v4
with: with:
dotnet-version: ${{ env.DOTNET_VERSION }} dotnet-version: "9.0.x"
- name: Restore dependencies - name: Restore dependencies
run: dotnet restore Shop.sln run: dotnet restore Shop.sln
+1
View File
@@ -1,3 +1,4 @@
# https://github.com/SonarSource/sonarcloud-github-action
name: SonarCloud name: SonarCloud
on: on:
+40 -39
View File
@@ -18,55 +18,56 @@
<PackageVersion Include="CorrelationId" Version="3.0.1" /> <PackageVersion Include="CorrelationId" Version="3.0.1" />
<PackageVersion Include="coverlet.collector" Version="6.0.2" /> <PackageVersion Include="coverlet.collector" Version="6.0.2" />
<PackageVersion Include="coverlet.msbuild" Version="6.0.2" /> <PackageVersion Include="coverlet.msbuild" Version="6.0.2" />
<PackageVersion Include="FluentAssertions" Version="6.12.1" /> <PackageVersion Include="FluentAssertions" Version="7.0.0" />
<PackageVersion Include="FluentValidation" Version="11.10.0" /> <PackageVersion Include="FluentValidation" Version="11.11.0" />
<PackageVersion Include="FluentValidation.DependencyInjectionExtensions" Version="11.10.0" /> <PackageVersion Include="FluentValidation.DependencyInjectionExtensions" Version="11.11.0" />
<PackageVersion Include="MediatR" Version="12.4.1" /> <PackageVersion Include="MediatR" Version="12.4.1" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.10" /> <PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="8.0.10" /> <PackageVersion Include="Microsoft.EntityFrameworkCore" Version="9.0.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Analyzers" Version="8.0.10" /> <PackageVersion Include="Microsoft.EntityFrameworkCore.Analyzers" Version="9.0.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.10" /> <PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.10" /> <PackageVersion Include="Microsoft.EntityFrameworkCore.InMemory" Version="9.0.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.10" /> <PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="9.0.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.10" /> <PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.10" /> <PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.10" /> <PackageVersion Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="8.0.10" /> <PackageVersion Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="8.0.0" /> <PackageVersion Include="Microsoft.Extensions.Configuration" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="8.0.0" /> <PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="8.0.1" /> <PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.2" /> <PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="8.0.10" /> <PackageVersion Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="8.0.10" /> <PackageVersion Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="8.0.1" /> <PackageVersion Include="Microsoft.Extensions.Hosting" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.1" /> <PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Http" Version="8.0.1" /> <PackageVersion Include="Microsoft.Extensions.Http" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Identity.Core" Version="8.0.10" /> <PackageVersion Include="Microsoft.Extensions.Identity.Core" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.2" /> <PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Options" Version="8.0.2" /> <PackageVersion Include="Microsoft.Extensions.Options" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" /> <PackageVersion Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Options.DataAnnotations" Version="8.0.0" /> <PackageVersion Include="Microsoft.Extensions.Options.DataAnnotations" Version="9.0.0" />
<PackageVersion Include="Microsoft.Extensions.Primitives" Version="8.0.0" /> <PackageVersion Include="Microsoft.Extensions.Primitives" Version="9.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" /> <PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageVersion Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" /> <PackageVersion Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
<PackageVersion Include="MiniProfiler.AspNetCore.Mvc" Version="4.3.8" /> <PackageVersion Include="MiniProfiler.AspNetCore.Mvc" Version="4.5.4" />
<PackageVersion Include="MiniProfiler.EntityFrameworkCore" Version="4.3.8" /> <PackageVersion Include="MiniProfiler.EntityFrameworkCore" Version="4.5.4" />
<PackageVersion Include="MongoDB.Bson" Version="3.0.0" /> <PackageVersion Include="MongoDB.Bson" Version="3.1.0" />
<PackageVersion Include="MongoDB.Driver" Version="3.0.0" /> <PackageVersion Include="MongoDB.Driver" Version="3.1.0" />
<PackageVersion Include="NSubstitute" Version="5.3.0" /> <PackageVersion Include="NSubstitute" Version="5.3.0" />
<PackageVersion Include="NSubstitute.Analyzers.CSharp" Version="1.0.17" /> <PackageVersion Include="NSubstitute.Analyzers.CSharp" Version="1.0.17" />
<PackageVersion Include="OwaspHeaders.Core" Version="8.1.3" /> <PackageVersion Include="OwaspHeaders.Core" Version="9.4.3" />
<PackageVersion Include="Polly" Version="8.4.2" /> <PackageVersion Include="Polly" Version="8.5.0" />
<PackageVersion Include="Roslynator.Analyzers" Version="4.12.9" /> <PackageVersion Include="Roslynator.Analyzers" Version="4.12.9" />
<PackageVersion Include="Roslynator.CodeAnalysis.Analyzers" Version="4.12.9" /> <PackageVersion Include="Roslynator.CodeAnalysis.Analyzers" Version="4.12.9" />
<PackageVersion Include="Roslynator.CodeFixes" Version="4.12.9" /> <PackageVersion Include="Roslynator.CodeFixes" Version="4.12.9" />
<PackageVersion Include="Roslynator.Formatting.Analyzers" Version="4.12.9" /> <PackageVersion Include="Roslynator.Formatting.Analyzers" Version="4.12.9" />
<PackageVersion Include="Roslynator.Refactorings" Version="4.12.9" /> <PackageVersion Include="Roslynator.Refactorings" Version="4.12.9" />
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.9.0" /> <PackageVersion Include="Swashbuckle.AspNetCore" Version="7.2.0" />
<PackageVersion Include="System.Configuration.ConfigurationManager" Version="8.0.1" /> <PackageVersion Include="System.Configuration.ConfigurationManager" Version="9.0.0" />
<PackageVersion Include="System.Text.Json" Version="8.0.5" /> <PackageVersion Include="System.Text.Json" Version="9.0.0" />
<PackageVersion Include="System.Text.RegularExpressions" Version="4.3.1" />
<PackageVersion Include="xunit" Version="2.9.2" /> <PackageVersion Include="xunit" Version="2.9.2" />
<PackageVersion Include="xunit.analyzers" Version="1.16.0" /> <PackageVersion Include="xunit.analyzers" Version="1.17.0" />
<PackageVersion Include="xunit.categories" Version="2.0.8" /> <PackageVersion Include="xunit.categories" Version="2.0.8" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" /> <PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
</ItemGroup> </ItemGroup>
+4 -4
View File
@@ -26,8 +26,8 @@ If you liked this project, learned something, give it a star. Thank you!
## **Technologies** ## **Technologies**
- ASP.NET Core 8 - ASP.NET Core 9
- Entity Framework Core 8 - Entity Framework Core 9
- Unit & Integration Tests + xUnit + FluentAssertions - Unit & Integration Tests + xUnit + FluentAssertions
- Polly - Polly
- AutoMapper - AutoMapper
@@ -73,7 +73,7 @@ docker-compose up --build --abort-on-container-exit --remove-orphans
Now just open the url in the browser: Now just open the url in the browser:
```csharp ```csharp
http://localhost:5072/swagger/ http://localhost:{port}/swagger/
``` ```
@@ -83,7 +83,7 @@ http://localhost:5072/swagger/
To access the page with the performance indicators and performance: To access the page with the performance indicators and performance:
```csharp ```csharp
http://localhost:5072/profiler/results-index http://localhost:{port}/profiler/results-index
``` ```
## License ## License
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"sdk": { "sdk": {
"version": "8.0.400", "version": "9.0.100",
"rollForward": "latestMajor", "rollForward": "latestMajor",
"allowPrerelease": false "allowPrerelease": false
} }
+1 -1
View File
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net9.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
+1 -1
View File
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net9.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
+1 -1
View File
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net9.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net9.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
+2 -2
View File
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0-bookworm-slim AS base FROM mcr.microsoft.com/dotnet/aspnet:9.0-bookworm-slim AS base
WORKDIR /app WORKDIR /app
EXPOSE 80 EXPOSE 80
@@ -10,7 +10,7 @@ ENV DOTNET_NOLOGO=1
# Specifies whether data about the .NET tools usage is collected and sent to Microsoft. # Specifies whether data about the .NET tools usage is collected and sent to Microsoft.
ENV DOTNET_CLI_TELEMETRY_OPTOUT=1 ENV DOTNET_CLI_TELEMETRY_OPTOUT=1
FROM mcr.microsoft.com/dotnet/sdk:8.0-bookworm-slim AS build FROM mcr.microsoft.com/dotnet/sdk:9.0-bookworm-slim AS build
WORKDIR /src WORKDIR /src
COPY ["Directory.Packages.props", "."] COPY ["Directory.Packages.props", "."]
COPY ["Directory.Build.props", "."] COPY ["Directory.Build.props", "."]
@@ -2,6 +2,7 @@ using System;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
@@ -67,13 +68,16 @@ internal static class ServicesCollectionExtensions
healthCheckBuilder.AddRedis(options.CacheConnection); healthCheckBuilder.AddRedis(options.CacheConnection);
} }
public static IServiceCollection AddWriteDbContext(this IServiceCollection services) public static IServiceCollection AddWriteDbContext(this IServiceCollection services, IWebHostEnvironment environment)
{ {
services.AddDbContext<WriteDbContext>((serviceProvider, optionsBuilder) => if (!environment.IsEnvironment("Testing"))
ConfigureDbContext<WriteDbContext>(serviceProvider, optionsBuilder, QueryTrackingBehavior.TrackAll)); {
services.AddDbContext<WriteDbContext>((serviceProvider, optionsBuilder) =>
ConfigureDbContext<WriteDbContext>(serviceProvider, optionsBuilder, QueryTrackingBehavior.TrackAll));
services.AddDbContext<EventStoreDbContext>((serviceProvider, optionsBuilder) => services.AddDbContext<EventStoreDbContext>((serviceProvider, optionsBuilder) =>
ConfigureDbContext<EventStoreDbContext>(serviceProvider, optionsBuilder, QueryTrackingBehavior.NoTrackingWithIdentityResolution)); ConfigureDbContext<EventStoreDbContext>(serviceProvider, optionsBuilder, QueryTrackingBehavior.NoTrackingWithIdentityResolution));
}
return services; return services;
} }
@@ -0,0 +1,90 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Shop.Infrastructure.Data.Context;
#nullable disable
namespace Shop.PublicApi.Migrations
{
[DbContext(typeof(WriteDbContext))]
[Migration("20241128202054_EF_Update")]
partial class EF_Update
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.UseCollation("Latin1_General_CI_AI")
.HasAnnotation("ProductVersion", "9.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("Shop.Domain.Entities.CustomerAggregate.Customer", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("DateOfBirth")
.HasColumnType("DATE");
b.Property<string>("FirstName")
.IsRequired()
.HasMaxLength(100)
.IsUnicode(false)
.HasColumnType("varchar(100)");
b.Property<string>("Gender")
.IsRequired()
.HasMaxLength(6)
.HasColumnType("nvarchar(6)");
b.Property<string>("LastName")
.IsRequired()
.HasMaxLength(100)
.IsUnicode(false)
.HasColumnType("varchar(100)");
b.HasKey("Id");
b.ToTable("Customers");
});
modelBuilder.Entity("Shop.Domain.Entities.CustomerAggregate.Customer", b =>
{
b.OwnsOne("Shop.Domain.ValueObjects.Email", "Email", b1 =>
{
b1.Property<Guid>("CustomerId")
.HasColumnType("uniqueidentifier");
b1.Property<string>("Address")
.IsRequired()
.HasMaxLength(254)
.IsUnicode(false)
.HasColumnType("varchar(254)")
.HasColumnName("Email");
b1.HasKey("CustomerId");
b1.HasIndex("Address")
.IsUnique()
.HasFilter("[Email] IS NOT NULL");
b1.ToTable("Customers");
b1.WithOwner()
.HasForeignKey("CustomerId");
});
b.Navigation("Email");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,39 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Shop.PublicApi.Migrations;
/// <inheritdoc />
public partial class EF_Update : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "Gender",
table: "Customers",
type: "nvarchar(6)",
maxLength: 6,
nullable: false,
oldClrType: typeof(string),
oldType: "varchar(6)",
oldUnicode: false,
oldMaxLength: 6);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "Gender",
table: "Customers",
type: "varchar(6)",
unicode: false,
maxLength: 6,
nullable: false,
oldClrType: typeof(string),
oldType: "nvarchar(6)",
oldMaxLength: 6);
}
}
@@ -0,0 +1,61 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Shop.Infrastructure.Data.Context;
#nullable disable
namespace Shop.PublicApi.Migrations.EventStoreDb
{
[DbContext(typeof(EventStoreDbContext))]
[Migration("20241128202230_EF_Update")]
partial class EF_Update
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.UseCollation("Latin1_General_CI_AI")
.HasAnnotation("ProductVersion", "9.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("Shop.Core.SharedKernel.EventStore", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier");
b.Property<Guid>("AggregateId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Data")
.IsRequired()
.HasMaxLength(255)
.IsUnicode(false)
.HasColumnType("varchar(255)")
.HasComment("JSON serialized event");
b.Property<string>("MessageType")
.IsRequired()
.HasMaxLength(100)
.IsUnicode(false)
.HasColumnType("varchar(100)");
b.Property<DateTime>("OccurredOn")
.HasColumnType("datetime2")
.HasColumnName("CreatedAt");
b.HasKey("Id");
b.ToTable("EventStores");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,43 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Shop.PublicApi.Migrations.EventStoreDb;
/// <inheritdoc />
public partial class EF_Update : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "Data",
table: "EventStores",
type: "varchar(255)",
unicode: false,
maxLength: 255,
nullable: false,
oldClrType: typeof(string),
oldType: "VARCHAR(MAX)",
oldUnicode: false,
comment: "JSON serialized event",
oldComment: "JSON serialized event");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "Data",
table: "EventStores",
type: "VARCHAR(MAX)",
unicode: false,
nullable: false,
oldClrType: typeof(string),
oldType: "varchar(255)",
oldUnicode: false,
oldMaxLength: 255,
comment: "JSON serialized event",
oldComment: "JSON serialized event");
}
}
@@ -2,6 +2,8 @@
using System; using System;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Shop.Infrastructure.Data.Context; using Shop.Infrastructure.Data.Context;
#nullable disable #nullable disable
@@ -16,12 +18,12 @@ namespace Shop.PublicApi.Migrations.EventStoreDb
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.UseCollation("Latin1_General_CI_AI") .UseCollation("Latin1_General_CI_AI")
.HasAnnotation("ProductVersion", "7.0.3") .HasAnnotation("ProductVersion", "9.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 128); .HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("Shop.Core.Events.EventStore", b => modelBuilder.Entity("Shop.Core.SharedKernel.EventStore", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
@@ -31,8 +33,9 @@ namespace Shop.PublicApi.Migrations.EventStoreDb
b.Property<string>("Data") b.Property<string>("Data")
.IsRequired() .IsRequired()
.HasMaxLength(255)
.IsUnicode(false) .IsUnicode(false)
.HasColumnType("VARCHAR(MAX)") .HasColumnType("varchar(255)")
.HasComment("JSON serialized event"); .HasComment("JSON serialized event");
b.Property<string>("MessageType") b.Property<string>("MessageType")
@@ -2,6 +2,8 @@
using System; using System;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Shop.Infrastructure.Data.Context; using Shop.Infrastructure.Data.Context;
#nullable disable #nullable disable
@@ -16,12 +18,12 @@ namespace Shop.PublicApi.Migrations
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.UseCollation("Latin1_General_CI_AI") .UseCollation("Latin1_General_CI_AI")
.HasAnnotation("ProductVersion", "7.0.2") .HasAnnotation("ProductVersion", "9.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 128); .HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("Shop.Domain.Entities.Customer.Customer", b => modelBuilder.Entity("Shop.Domain.Entities.CustomerAggregate.Customer", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
@@ -38,8 +40,7 @@ namespace Shop.PublicApi.Migrations
b.Property<string>("Gender") b.Property<string>("Gender")
.IsRequired() .IsRequired()
.HasMaxLength(6) .HasMaxLength(6)
.IsUnicode(false) .HasColumnType("nvarchar(6)");
.HasColumnType("varchar(6)");
b.Property<string>("LastName") b.Property<string>("LastName")
.IsRequired() .IsRequired()
@@ -52,7 +53,7 @@ namespace Shop.PublicApi.Migrations
b.ToTable("Customers"); b.ToTable("Customers");
}); });
modelBuilder.Entity("Shop.Domain.Entities.Customer.Customer", b => modelBuilder.Entity("Shop.Domain.Entities.CustomerAggregate.Customer", b =>
{ {
b.OwnsOne("Shop.Domain.ValueObjects.Email", "Email", b1 => b.OwnsOne("Shop.Domain.ValueObjects.Email", "Email", b1 =>
{ {
+1 -1
View File
@@ -65,7 +65,7 @@ builder.Services
.AddInfrastructure() .AddInfrastructure()
.AddCommandHandlers() .AddCommandHandlers()
.AddQueryHandlers() .AddQueryHandlers()
.AddWriteDbContext() .AddWriteDbContext(builder.Environment)
.AddWriteOnlyRepositories() .AddWriteOnlyRepositories()
.AddReadDbContext() .AddReadDbContext()
.AddReadOnlyRepositories() .AddReadOnlyRepositories()
+3 -2
View File
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net9.0</TargetFramework>
<IncludeOpenAPIAnalyzers>true</IncludeOpenAPIAnalyzers> <IncludeOpenAPIAnalyzers>true</IncludeOpenAPIAnalyzers>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<UserSecretsId>7d8d0af0-7540-48a6-b160-d34c988a1ad6</UserSecretsId> <UserSecretsId>7d8d0af0-7540-48a6-b160-d34c988a1ad6</UserSecretsId>
@@ -61,6 +61,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Swashbuckle.AspNetCore" /> <PackageReference Include="Swashbuckle.AspNetCore" />
<PackageReference Include="System.Text.RegularExpressions" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@@ -76,7 +77,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Remove="D:\.nuget\packages\owaspheaders.core\8.1.0\contentFiles\any\net8.0\README.md" /> <Content Remove="D:\.nuget\packages\owaspheaders.core\8.1.0\contentFiles\any\net9.0\README.md" />
</ItemGroup> </ItemGroup>
</Project> </Project>
+1 -1
View File
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net9.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data.Common;
using System.Net; using System.Net;
using System.Threading.Tasks; using System.Threading.Tasks;
using Bogus; using Bogus;
@@ -9,6 +10,7 @@ using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Data.Sqlite; using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
@@ -477,12 +479,14 @@ public class CustomersControllerTests : IAsyncLifetime
hostBuilder.UseSetting("CacheOptions:AbsoluteExpirationInHours", "1"); hostBuilder.UseSetting("CacheOptions:AbsoluteExpirationInHours", "1");
hostBuilder.UseSetting("CacheOptions:SlidingExpirationInSeconds", "30"); hostBuilder.UseSetting("CacheOptions:SlidingExpirationInSeconds", "30");
hostBuilder.UseEnvironment(Environments.Production); hostBuilder.UseEnvironment("Testing");
hostBuilder.ConfigureLogging(logging => logging.ClearProviders()); hostBuilder.ConfigureLogging(logging => logging.ClearProviders());
hostBuilder.ConfigureServices(services => hostBuilder.ConfigureServices(services =>
{ {
services.RemoveAll<DbConnection>();
services.RemoveAll<DbContextOptions>();
services.RemoveAll<WriteDbContext>(); services.RemoveAll<WriteDbContext>();
services.RemoveAll<DbContextOptions<WriteDbContext>>(); services.RemoveAll<DbContextOptions<WriteDbContext>>();
services.RemoveAll<EventStoreDbContext>(); services.RemoveAll<EventStoreDbContext>();
@@ -491,10 +495,14 @@ public class CustomersControllerTests : IAsyncLifetime
services.RemoveAll<ISynchronizeDb>(); services.RemoveAll<ISynchronizeDb>();
services.AddDbContext<WriteDbContext>( services.AddDbContext<WriteDbContext>(
options => options.UseSqlite(_writeDbContextSqlite)); options => options
.UseSqlite(_writeDbContextSqlite)
.ConfigureWarnings(warningBuilder => warningBuilder.Ignore(InMemoryEventId.TransactionIgnoredWarning)));
services.AddDbContext<EventStoreDbContext>( services.AddDbContext<EventStoreDbContext>(
options => options.UseSqlite(_eventStoreDbContextSqlite)); options => options
.UseSqlite(_eventStoreDbContextSqlite)
.ConfigureWarnings(warningBuilder => warningBuilder.Ignore(InMemoryEventId.TransactionIgnoredWarning)));
services.AddSingleton(_ => Substitute.For<IReadDbContext>()); services.AddSingleton(_ => Substitute.For<IReadDbContext>());
services.AddSingleton(_ => Substitute.For<ISynchronizeDb>()); services.AddSingleton(_ => Substitute.For<ISynchronizeDb>());
@@ -9,4 +9,4 @@ public static class TRequestExtensions
{ {
public static HttpContent ToJsonHttpContent<TRequest>(this TRequest request) => public static HttpContent ToJsonHttpContent<TRequest>(this TRequest request) =>
new StringContent(request.ToJson(), Encoding.UTF8, MediaTypeNames.Application.Json); new StringContent(request.ToJson(), Encoding.UTF8, MediaTypeNames.Application.Json);
} }
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net9.0</TargetFramework>
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject> <IsTestProject>true</IsTestProject>
<SonarQubeTestProject>True</SonarQubeTestProject> <SonarQubeTestProject>True</SonarQubeTestProject>
@@ -60,6 +60,7 @@
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="System.Text.RegularExpressions" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
+2 -1
View File
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net9.0</TargetFramework>
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject> <IsTestProject>true</IsTestProject>
<SonarQubeTestProject>True</SonarQubeTestProject> <SonarQubeTestProject>True</SonarQubeTestProject>
@@ -57,6 +57,7 @@
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="System.Text.RegularExpressions" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>