Skip to content

Commit

Permalink
Migrate to dotnet 3.1 (#7)
Browse files Browse the repository at this point in the history
- Update to dotnet 3.1 including CI and Dockerfile
- Migrated all JSON serialization to System.Text.Json
- Upgrade nuget packages
  • Loading branch information
sei-ebram authored Nov 4, 2020
1 parent b3afd25 commit 07182ba
Show file tree
Hide file tree
Showing 46 changed files with 356 additions and 341 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Setup dotnet
uses: actions/setup-dotnet@v1
with:
dotnet-version: '2.2.103'
dotnet-version: '3.1.x'

- name: Setup Package Name
id: package_name
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
#multi-stage target: dev
#
FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS dev
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS dev

ENV ASPNETCORE_URLS=http://0.0.0.0:4300 \
ASPNETCORE_ENVIRONMENT=DEVELOPMENT
Expand All @@ -14,7 +14,7 @@ CMD ["dotnet", "run"]
#
#multi-stage target: prod
#
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2 AS prod
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS prod
ARG commit
ENV COMMIT=$commit
COPY --from=dev /app/dist /app
Expand Down
4 changes: 1 addition & 3 deletions Player.Api.Client/Player.Api.Client.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netstandard2.0</TargetFramework>
<OutputType>library</OutputType>
<IsPackable>true</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" />
<PackageReference Include="Microsoft.Rest.ClientRuntime" Version="2.3.12" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions Player.Api.Data/Data/Extensions/ModelBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ public static void UsePostgresCasing(this ModelBuilder builder)
// modify column names
foreach (var property in entity.GetProperties())
{
property.Relational().ColumnName = mapper.TranslateMemberName(property.Relational().ColumnName);
property.SetColumnName(mapper.TranslateMemberName(property.GetColumnName()));
}

// modify table name
entity.Relational().TableName = mapper.TranslateMemberName(entity.Relational().TableName);
entity.SetTableName(mapper.TranslateMemberName(entity.GetTableName()));
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions Player.Api.Data/Data/Models/Application.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ Carnegie Mellon(R) and CERT(R) are registered in the U.S. Patent and Trademark O
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.Text.Json;

namespace Player.Api.Data.Data.Models
{
Expand Down
7 changes: 4 additions & 3 deletions Player.Api.Data/Data/Models/Notification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ Carnegie Mellon(R) and CERT(R) are registered in the U.S. Patent and Trademark O

using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.Text.Json.Serialization;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
Expand All @@ -37,14 +36,16 @@ public class NotificationEntity
public NotificationPriority Priority { get; set; }
}

[JsonConverter(typeof(JsonStringEnumConverter))]
public enum NotificationPriority
{
Normal = 0,
Elevated = 1,
High = 2,
System = 3
}


[JsonConverter(typeof(JsonStringEnumConverter))]
public enum NotificationType
{
View = 0,
Expand Down
3 changes: 1 addition & 2 deletions Player.Api.Data/Data/Models/Permission.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ Carnegie Mellon(R) and CERT(R) are registered in the U.S. Patent and Trademark O

using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.Text.Json.Serialization;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
Expand Down
3 changes: 1 addition & 2 deletions Player.Api.Data/Data/Models/Team.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ Carnegie Mellon(R) and CERT(R) are registered in the U.S. Patent and Trademark O
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.Text.Json.Serialization;

namespace Player.Api.Data.Data.Models
{
Expand Down
3 changes: 1 addition & 2 deletions Player.Api.Data/Data/Models/TeamMembership.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ Carnegie Mellon(R) and CERT(R) are registered in the U.S. Patent and Trademark O
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.Text.Json.Serialization;

namespace Player.Api.Data.Data.Models
{
Expand Down
3 changes: 1 addition & 2 deletions Player.Api.Data/Data/Models/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ Carnegie Mellon(R) and CERT(R) are registered in the U.S. Patent and Trademark O

using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.Text.Json.Serialization;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
Expand Down
4 changes: 2 additions & 2 deletions Player.Api.Data/Data/Models/View.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ Carnegie Mellon(R) and CERT(R) are registered in the U.S. Patent and Trademark O
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.Text.Json.Serialization;

namespace Player.Api.Data.Data.Models
{
Expand Down Expand Up @@ -45,6 +44,7 @@ public ViewEntity Clone()
}
}

[JsonConverter(typeof(JsonStringEnumConverter))]
public enum ViewStatus
{
Active = 0,
Expand Down
3 changes: 1 addition & 2 deletions Player.Api.Data/Data/Models/ViewMembership.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ Carnegie Mellon(R) and CERT(R) are registered in the U.S. Patent and Trademark O
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System.Text.Json.Serialization;

namespace Player.Api.Data.Data.Models
{
Expand Down
7 changes: 2 additions & 5 deletions Player.Api.Data/Player.Api.Data.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" />
<PackageReference Include="log4net" Version="2.0.8" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.1" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="2.1.1.1" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.1" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="2.1.1.1" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.0" />
</ItemGroup>

<ItemGroup>
Expand Down
32 changes: 16 additions & 16 deletions Player.Api/Controllers/ApplicationController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Carnegie Mellon(R) and CERT(R) are registered in the U.S. Patent and Trademark O
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using Swashbuckle.AspNetCore.SwaggerGen;
using Swashbuckle.AspNetCore.Annotations;

namespace Player.Api.Controllers
{
Expand All @@ -45,7 +45,7 @@ public ApplicationController(IApplicationService service)
/// <returns></returns>
[HttpGet("application-templates")]
[ProducesResponseType(typeof(IEnumerable<ApplicationTemplate>), (int)HttpStatusCode.OK)]
[SwaggerOperation(operationId: "getApplicationTemplates")]
[SwaggerOperation(OperationId = "getApplicationTemplates")]
public async Task<IActionResult> GetTemplates(CancellationToken ct)
{
var list = await _applicationService.GetTemplatesAsync(ct);
Expand All @@ -65,7 +65,7 @@ public async Task<IActionResult> GetTemplates(CancellationToken ct)
/// <returns></returns>
[HttpGet("application-templates/{id}")]
[ProducesResponseType(typeof(ApplicationTemplate), (int)HttpStatusCode.OK)]
[SwaggerOperation(operationId: "getApplicationTemplate")]
[SwaggerOperation(OperationId = "getApplicationTemplate")]
public async Task<IActionResult> GetTemplate(Guid id, CancellationToken ct)
{
var template = await _applicationService.GetTemplateAsync(id, ct);
Expand All @@ -88,7 +88,7 @@ public async Task<IActionResult> GetTemplate(Guid id, CancellationToken ct)
/// </remarks>
[HttpPost("application-templates")]
[ProducesResponseType(typeof(ApplicationTemplate), (int)HttpStatusCode.Created)]
[SwaggerOperation(operationId: "createApplicationTemplate")]
[SwaggerOperation(OperationId = "createApplicationTemplate")]
public async Task<IActionResult> Create([FromBody] ApplicationTemplateForm form, CancellationToken ct)
{
var createdTemplate = await _applicationService.CreateTemplateAsync(form, ct);
Expand All @@ -109,7 +109,7 @@ public async Task<IActionResult> Create([FromBody] ApplicationTemplateForm form,
/// <returns></returns>
[HttpPut("application-templates/{id}")]
[ProducesResponseType(typeof(ApplicationTemplate), (int)HttpStatusCode.OK)]
[SwaggerOperation(operationId: "updateApplicationTemplate")]
[SwaggerOperation(OperationId = "updateApplicationTemplate")]
public async Task<IActionResult> Update([FromRoute] Guid id, [FromBody] ApplicationTemplateForm form, CancellationToken ct)
{
var updatedTemplate = await _applicationService.UpdateTemplateAsync(id, form, ct);
Expand All @@ -128,7 +128,7 @@ public async Task<IActionResult> Update([FromRoute] Guid id, [FromBody] Applicat
/// <param name="ct"></param>
[HttpDelete("application-templates/{id}")]
[ProducesResponseType((int)HttpStatusCode.NoContent)]
[SwaggerOperation(operationId: "deleteApplicationTemplate")]
[SwaggerOperation(OperationId = "deleteApplicationTemplate")]
public async Task<IActionResult> Delete(Guid id, CancellationToken ct)
{
await _applicationService.DeleteTemplateAsync(id, ct);
Expand All @@ -152,7 +152,7 @@ public async Task<IActionResult> Delete(Guid id, CancellationToken ct)
/// <returns></returns>
[HttpGet("views/{id}/applications")]
[ProducesResponseType(typeof(IEnumerable<Application>), (int)HttpStatusCode.OK)]
[SwaggerOperation(operationId: "getViewApplications")]
[SwaggerOperation(OperationId = "getViewApplications")]
public async Task<IActionResult> GetApplicationsByView(Guid id, CancellationToken ct)
{
var list = await _applicationService.GetApplicationsByViewAsync(id, ct);
Expand All @@ -172,7 +172,7 @@ public async Task<IActionResult> GetApplicationsByView(Guid id, CancellationToke
/// <returns></returns>
[HttpGet("applications/{id}")]
[ProducesResponseType(typeof(Application), (int)HttpStatusCode.OK)]
[SwaggerOperation(operationId: "getApplication")]
[SwaggerOperation(OperationId = "getApplication")]
public async Task<IActionResult> GetApplication(Guid id, CancellationToken ct)
{
var application = await _applicationService.GetApplicationAsync(id, ct);
Expand All @@ -196,7 +196,7 @@ public async Task<IActionResult> GetApplication(Guid id, CancellationToken ct)
/// <param name="ct"></param>
[HttpPost("views/{id}/applications")]
[ProducesResponseType(typeof(Application), (int)HttpStatusCode.Created)]
[SwaggerOperation(operationId: "createApplication")]
[SwaggerOperation(OperationId = "createApplication")]
public async Task<IActionResult> CreateApplication([FromRoute] Guid id, [FromBody] Application application, CancellationToken ct)
{
var createdApplication = await _applicationService.CreateApplicationAsync(id, application, ct);
Expand All @@ -213,7 +213,7 @@ public async Task<IActionResult> CreateApplication([FromRoute] Guid id, [FromBod
/// </remarks>
[HttpPut("applications/{id}")]
[ProducesResponseType(typeof(Application), (int)HttpStatusCode.OK)]
[SwaggerOperation(operationId: "updateApplication")]
[SwaggerOperation(OperationId = "updateApplication")]
public async Task<IActionResult> UpdateApplication([FromRoute] Guid id, [FromBody] Application application, CancellationToken ct)
{
var updatedApplication = await _applicationService.UpdateApplicationAsync(id, application, ct);
Expand All @@ -232,7 +232,7 @@ public async Task<IActionResult> UpdateApplication([FromRoute] Guid id, [FromBod
/// <param name="ct"></param>
[HttpDelete("applications/{id}")]
[ProducesResponseType((int)HttpStatusCode.NoContent)]
[SwaggerOperation(operationId: "deleteApplication")]
[SwaggerOperation(OperationId = "deleteApplication")]
public async Task<IActionResult> DeleteApplication(Guid id, CancellationToken ct)
{
await _applicationService.DeleteApplicationAsync(id, ct);
Expand All @@ -256,7 +256,7 @@ public async Task<IActionResult> DeleteApplication(Guid id, CancellationToken ct
/// <returns></returns>
[HttpGet("teams/{id}/application-instances")]
[ProducesResponseType(typeof(IEnumerable<ApplicationInstance>), (int)HttpStatusCode.OK)]
[SwaggerOperation(operationId: "getTeamApplicationInstances")]
[SwaggerOperation(OperationId = "getTeamApplicationInstances")]
public async Task<IActionResult> GetInstancesByTeam(Guid id, CancellationToken ct)
{
var list = await _applicationService.GetInstancesByTeamAsync(id, ct);
Expand All @@ -276,7 +276,7 @@ public async Task<IActionResult> GetInstancesByTeam(Guid id, CancellationToken c
/// <returns></returns>
[HttpGet("application-instances/{id}")]
[ProducesResponseType(typeof(ApplicationInstance), (int)HttpStatusCode.OK)]
[SwaggerOperation(operationId: "getApplicationInstance")]
[SwaggerOperation(OperationId = "getApplicationInstance")]
public async Task<IActionResult> GetInstance(Guid id, CancellationToken ct)
{
var instance = await _applicationService.GetInstanceAsync(id, ct);
Expand All @@ -300,7 +300,7 @@ public async Task<IActionResult> GetInstance(Guid id, CancellationToken ct)
/// <param name="ct"></param>
[HttpPost("teams/{id}/application-instances")]
[ProducesResponseType(typeof(ApplicationInstance), (int)HttpStatusCode.Created)]
[SwaggerOperation(operationId: "createApplicationInstance")]
[SwaggerOperation(OperationId = "createApplicationInstance")]
public async Task<IActionResult> CreateApplicationInstance([FromRoute] Guid id, [FromBody] ApplicationInstanceForm instance, CancellationToken ct)
{
var createdInstance = await _applicationService.CreateInstanceAsync(id, instance, ct);
Expand All @@ -320,7 +320,7 @@ public async Task<IActionResult> CreateApplicationInstance([FromRoute] Guid id,
/// <param name="ct"></param>
[HttpPut("application-instances/{id}")]
[ProducesResponseType(typeof(ApplicationInstance), (int)HttpStatusCode.OK)]
[SwaggerOperation(operationId: "updateApplicationInstance")]
[SwaggerOperation(OperationId = "updateApplicationInstance")]
public async Task<IActionResult> UpdateApplicationInstance([FromRoute] Guid id, [FromBody] ApplicationInstanceForm instance, CancellationToken ct)
{
var updatedInstance = await _applicationService.UpdateInstanceAsync(id, instance, ct);
Expand All @@ -339,7 +339,7 @@ public async Task<IActionResult> UpdateApplicationInstance([FromRoute] Guid id,
/// <param name="ct"></param>
[HttpDelete("application-instances/{id}")]
[ProducesResponseType((int)HttpStatusCode.NoContent)]
[SwaggerOperation(operationId: "deleteApplicationInstance")]
[SwaggerOperation(OperationId = "deleteApplicationInstance")]
public async Task<IActionResult> DeleteApplicationInstance(Guid id, CancellationToken ct)
{
await _applicationService.DeleteInstanceAsync(id, ct);
Expand Down
Loading

0 comments on commit 07182ba

Please sign in to comment.