Skip to content

Commit

Permalink
Merge pull request #50 from tecnocrata/feature/net6-migration
Browse files Browse the repository at this point in the history
Migration to .net 6
  • Loading branch information
JavierCane authored Mar 28, 2022
2 parents 6917270 + fafa74c commit ccaf073
Show file tree
Hide file tree
Showing 25 changed files with 97 additions and 84 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.100
dotnet-version: 6.0.x

- name: Build with dotnet
run: dotnet build --configuration Release
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ msbuild.log
msbuild.err
msbuild.wrn

# SQL Server Data
database/data

# Visual Studio 2015
.vs/

Expand Down
2 changes: 1 addition & 1 deletion apps/Backoffice/Backend/Backend.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<AssemblyName>CodelyTv.Apps.Backoffice.Backend</AssemblyName>
<RootNamespace>CodelyTv.Apps.Backoffice.Backend</RootNamespace>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ public static IServiceCollection AddInfrastructure(this IServiceCollection servi

services.AddScoped<DbContext, BackofficeContext>();
services.AddDbContext<BackofficeContext>(options =>
options.UseSqlServer(configuration.GetConnectionString("BackofficeDatabase")),
options.UseSqlServer(configuration.GetConnectionString("BackofficeDatabase"), options => options.EnableRetryOnFailure()),
ServiceLifetime.Transient);

services.AddScoped<MoocContext, MoocContext>();
services.AddDbContext<MoocContext>(options =>
options.UseSqlServer(configuration.GetConnectionString("MoocDatabase")), ServiceLifetime.Transient);
options.UseSqlServer(configuration.GetConnectionString("MoocDatabase"), options => options.EnableRetryOnFailure()), ServiceLifetime.Transient);

services.AddRabbitMq(configuration);
services.AddScoped<DomainEventJsonDeserializer, DomainEventJsonDeserializer>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Globalization;
using System.Text;
using Microsoft.AspNetCore.Html;
using Microsoft.AspNetCore.Mvc.ModelBinding;
Expand All @@ -14,7 +15,7 @@ public static IHtmlContent ValidationSummaryByProperty<TModel>(this IHtmlHelper<

if (dictionary[property] != null)
foreach (var modelState in dictionary[property].Errors)
builder.Append($"<p class='{className}'>{modelState.ErrorMessage}</p>");
builder.Append(CultureInfo.CurrentCulture, $"<p class='{className}'>{modelState.ErrorMessage}</p>");

return new HtmlString(builder.ToString());
}
Expand Down
8 changes: 4 additions & 4 deletions apps/Backoffice/Frontend/Frontend.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<AssemblyName>CodelyTv.Apps.Backoffice.Frontend</AssemblyName>
<RootNamespace>CodelyTv.Apps.Backoffice.Frontend</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="3.1.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.5" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="3.1.4" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="6.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.2" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="6.0.2" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions apps/Backoffice/Frontend/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
},
"AllowedHosts": "*",
"ConnectionStrings": {
"BackofficeDatabase": "Server=localhost;Database=backoffice;User=sa;Password=Your_password123;MultipleActiveResultSets=true;",
"MoocDatabase": "Server=localhost;Database=mooc;User=sa;Password=Your_password123;MultipleActiveResultSets=true;"
"BackofficeDatabase": "Server=localhost;Database=backoffice;User=sa;Password=Your_password123;Encrypt=yes;TrustServerCertificate=yes;MultipleActiveResultSets=true;",
"MoocDatabase": "Server=localhost;Database=mooc;User=sa;Password=Your_password123;Encrypt=yes;TrustServerCertificate=yes;MultipleActiveResultSets=true;"
},
"RabbitMq": {
"Username": "codelytv",
Expand Down
4 changes: 2 additions & 2 deletions apps/Mooc/Backend/Backend.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>CodelyTv.Apps.Mooc.Backend</RootNamespace>
<AssemblyName>CodelyTv.Apps.Mooc.Backend</AssemblyName>
</PropertyGroup>
Expand All @@ -12,6 +12,6 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.2" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static IServiceCollection AddInfrastructure(this IServiceCollection servi

services.AddScoped<DbContext, MoocContext>();
services.AddDbContext<MoocContext>(options =>
options.UseSqlServer(configuration.GetConnectionString("MoocDatabase")), ServiceLifetime.Transient);
options.UseSqlServer(configuration.GetConnectionString("MoocDatabase"), options => options.EnableRetryOnFailure()), ServiceLifetime.Transient);

services.AddRabbitMq(configuration);

Expand Down
8 changes: 7 additions & 1 deletion apps/Mooc/Backend/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@
},
"AllowedHosts": "*",
"ConnectionStrings": {
"MoocDatabase": "Server=localhost;Database=mooc;User=sa;Password=Your_password123;MultipleActiveResultSets=true;"
"MoocDatabase": "Server=localhost;Database=mooc;User=sa;Password=Your_password123;Encrypt=yes;TrustServerCertificate=yes;MultipleActiveResultSets=true;"
},
"RabbitMq": {
"Username": "codelytv",
"Password": "c0d3ly",
"Hostname": "localhost",
"port": "5630"
},
"Elasticsearch":
{
"Host": "http://localhost",
"Port": "9200",
"IndexPrefix": "backoffice"
}
}
7 changes: 6 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@ version: '3.0'
services:
mssql:
container_name: codelytv-chsarp_ddd_skeleton-mssql
image: mcr.microsoft.com/mssql/server:2019-latest
image: mcr.microsoft.com/mssql/server:2019-latest
user: root
ports:
- 1433:1433
environment:
- ACCEPT_EULA=Y
- SA_PASSWORD=Your_password123
- MSSQL_SA_PASSWORD=Your_password123
volumes:
- ./database/init.sql:/init.sql
- ./database/mooc.sql:/mooc.sql
- ./database/backoffice.sql:/backoffice.sql
- ./database/data/data:/var/opt/mssql/data
- ./database/data/log:/var/opt/mssql/log
- ./database/data/secrets:/var/opt/mssql/secrets
rabbitmq:
container_name: codelytv-chsarp_ddd_skeleton-rabbitmq
image: 'rabbitmq:3.7-management'
Expand Down
5 changes: 3 additions & 2 deletions src/Backoffice/Backoffice.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<AssemblyName>CodelyTv.Backoffice</AssemblyName>
<RootNamespace>CodelyTv.Backoffice</RootNamespace>
</PropertyGroup>
Expand All @@ -11,7 +11,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="NEST" Version="7.8.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.2" />
<PackageReference Include="NEST" Version="7.17.0" />
</ItemGroup>

</Project>
3 changes: 1 addition & 2 deletions src/Backoffice/Courses/Domain/BackofficeCourse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ public Dictionary<string, object> ToPrimitives()

public static BackofficeCourse FromPrimitives(Dictionary<string, object> body)
{
return new BackofficeCourse(Convert.ToString(body["id"]), Convert.ToString(body["name"]),
Convert.ToString(body["duration"]));
return new BackofficeCourse(body["id"].ToString(), body["name"].ToString(), body["duration"].ToString());
}

public override bool Equals(object obj)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;
using CodelyTv.Backoffice.Courses.Domain;
Expand Down Expand Up @@ -34,7 +35,7 @@ public async Task<IEnumerable<BackofficeCourse>> SearchAll()

protected override string ModuleName()
{
return nameof(BackofficeCourse).ToLower();
return nameof(BackofficeCourse).ToLower(CultureInfo.CurrentCulture);
}
}
}
16 changes: 6 additions & 10 deletions src/Mooc/Mooc.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<AssemblyName>CodelyTv.Mooc</AssemblyName>
<RootNamespace>CodelyTv.Mooc</RootNamespace>
</PropertyGroup>
Expand All @@ -11,17 +11,13 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="3.1.2" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Retention/Retention.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ public void ConsumeMessages(string queue, ushort prefetchCount = 10)
var consumer = new EventingBasicConsumer(channel);
consumer.Received += async (model, ea) =>
{
var body = ea.Body;
var message = Encoding.UTF8.GetString(body);
var message = Encoding.UTF8.GetString(ea.Body.Span);
var @event = _deserializer.Deserialize(message);

var subscriber = DomainEventSubscribers.ContainsKey(queue)
Expand Down
26 changes: 13 additions & 13 deletions src/Shared/Shared.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<AssemblyName>CodelyTv.Shared</AssemblyName>
<RootNamespace>CodelyTv.Shared</RootNamespace>
</PropertyGroup>
Expand All @@ -11,17 +11,17 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PackageReference Include="Microsoft.Data.SqlClient" Version="4.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Data.SqlClient" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.2" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.2" />
<PackageReference Include="NEST" Version="7.8.2" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="RabbitMQ.Client" Version="5.1.2" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.2.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0" />
<PackageReference Include="NEST" Version="7.17.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="RabbitMQ.Client" Version="6.2.4" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.2.17" />
</ItemGroup>
</Project>
12 changes: 6 additions & 6 deletions test/apps/Mooc/Mooc.csproj
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
<AssemblyName>MoocTest.apps</AssemblyName>
<RootNamespace>MoocTest.apps</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="3.1.2" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="6.0.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
<PackageReference Include="xunit" Version="2.4.1" />
</ItemGroup>

Expand Down
15 changes: 11 additions & 4 deletions test/src/Backoffice/Backoffice.csproj
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
<AssemblyName>CodelyTv.Test.Backoffice</AssemblyName>
<RootNamespace>CodelyTv.Test.Backoffice</RootNamespace>
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<PackageReference Include="coverlet.collector" Version="1.2.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down
18 changes: 11 additions & 7 deletions test/src/Mooc/Mooc.csproj
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
<AssemblyName>CodelyTv.Test.Mooc</AssemblyName>
<RootNamespace>CodelyTv.Test.Mooc</RootNamespace>
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="Moq" Version="4.13.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="6.0.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="Moq" Version="4.17.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" 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>
Expand Down
2 changes: 1 addition & 1 deletion test/src/Mooc/MoocContextInfrastructureTestCase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected override Action<IServiceCollection> Services()
services.AddQueryServices(AssemblyHelper.GetInstance(Assemblies.Mooc));

services.AddDbContext<MoocContext>(options =>
options.UseSqlServer(configuration.GetConnectionString("MoocDatabase")));
options.UseSqlServer(configuration.GetConnectionString("MoocDatabase"), options => options.EnableRetryOnFailure()));

services.Configure<RabbitMqConfig>(configuration.GetSection("RabbitMq"));
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public void Invoke(DbContext context)
{
var tables = Tables(context);
var truncateTablesSql = TruncateDatabaseSql(tables);
context.Database.ExecuteSqlCommand(truncateTablesSql);
context.Database.ExecuteSqlRaw(truncateTablesSql);
}

private string TruncateDatabaseSql(List<string> tables)
Expand Down
Loading

0 comments on commit ccaf073

Please sign in to comment.