From a01ce652571c84c35cbeaf6f2af250c5f8ee82c7 Mon Sep 17 00:00:00 2001 From: Blobadoodle Date: Fri, 17 Apr 2026 22:53:20 +0100 Subject: [PATCH 1/4] dotnet 10 --- .../SS14.MapServer.Tests.csproj | 12 +++---- .../Helpers/MapFromDataParameterFilter.cs | 4 +-- SS14.MapServer/Program.cs | 2 +- SS14.MapServer/SS14.MapServer.csproj | 36 +++++++++---------- .../ExcludeAnonymousSecurityFilter.cs | 24 +++++-------- 5 files changed, 36 insertions(+), 42 deletions(-) diff --git a/SS14.MapServer.Tests/SS14.MapServer.Tests.csproj b/SS14.MapServer.Tests/SS14.MapServer.Tests.csproj index 3f4f60b..eb1a1c1 100644 --- a/SS14.MapServer.Tests/SS14.MapServer.Tests.csproj +++ b/SS14.MapServer.Tests/SS14.MapServer.Tests.csproj @@ -1,7 +1,7 @@ - net9.0 + net10.0 enable enable @@ -10,14 +10,14 @@ - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/SS14.MapServer/Helpers/MapFromDataParameterFilter.cs b/SS14.MapServer/Helpers/MapFromDataParameterFilter.cs index 10d47d3..6bd6570 100644 --- a/SS14.MapServer/Helpers/MapFromDataParameterFilter.cs +++ b/SS14.MapServer/Helpers/MapFromDataParameterFilter.cs @@ -1,4 +1,4 @@ -using Microsoft.OpenApi.Models; +using Microsoft.OpenApi; using Swashbuckle.AspNetCore.SwaggerGen; namespace SS14.MapServer.Helpers; @@ -32,7 +32,7 @@ public void Apply(OpenApiOperation operation, OperationFilterContext context) var mapParameter = new OpenApiSchema { - Type = "string" + Type = JsonSchemaType.String }; type.Schema.Properties.Clear(); diff --git a/SS14.MapServer/Program.cs b/SS14.MapServer/Program.cs index e237e09..a28e167 100644 --- a/SS14.MapServer/Program.cs +++ b/SS14.MapServer/Program.cs @@ -2,7 +2,7 @@ using Microsoft.AspNetCore.HttpOverrides; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; -using Microsoft.OpenApi.Models; +using Microsoft.OpenApi; using Npgsql; using Quartz; using Quartz.AspNetCore; diff --git a/SS14.MapServer/SS14.MapServer.csproj b/SS14.MapServer/SS14.MapServer.csproj index de1fe3b..cbc1eb8 100644 --- a/SS14.MapServer/SS14.MapServer.csproj +++ b/SS14.MapServer/SS14.MapServer.csproj @@ -1,7 +1,7 @@ - net9.0 + net10.0 enable enable Linux @@ -10,30 +10,30 @@ - + - + runtime; build; native; contentfiles; analyzers; buildtransitive all - - - - - + + + + + - - + + - - - - - - - - + + + + + + + + diff --git a/SS14.MapServer/Security/ExcludeAnonymousSecurityFilter.cs b/SS14.MapServer/Security/ExcludeAnonymousSecurityFilter.cs index 180a33e..cd54eb8 100644 --- a/SS14.MapServer/Security/ExcludeAnonymousSecurityFilter.cs +++ b/SS14.MapServer/Security/ExcludeAnonymousSecurityFilter.cs @@ -1,5 +1,5 @@ using Microsoft.AspNetCore.Authorization; -using Microsoft.OpenApi.Models; +using Microsoft.OpenApi; using Swashbuckle.AspNetCore.SwaggerGen; namespace SS14.MapServer.Security; @@ -14,24 +14,18 @@ public void Apply(OpenApiOperation operation, OperationFilterContext context) if (allowsAnonymousAccess) return; - + operation.Responses.Add("401", new OpenApiResponse { Description = "Unauthorized" }); operation.Responses.Add("403", new OpenApiResponse { Description = "Forbidden" }); - var apiKeyScheme = new OpenApiSecurityScheme - { - Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = ApiKeyHandler.Name } - }; + var apiKeyScheme = new OpenApiSecuritySchemeReference(ApiKeyHandler.Name, context.Document); - operation.Security = new List - { - new() + operation.Security = + [ + new OpenApiSecurityRequirement { - [ apiKeyScheme ] = new List - { - "API" - } + [apiKeyScheme] = ["API"] } - }; + ]; } -} \ No newline at end of file +} From b63da3fb3c991655e45ae6d08e123aa30185c3ac Mon Sep 17 00:00:00 2001 From: Blobadoodle Date: Fri, 17 Apr 2026 22:58:34 +0100 Subject: [PATCH 2/4] dotnet 10 dockerfile --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 25cc1eb..e5f6ac3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ -FROM mcr.microsoft.com/dotnet/sdk:9.0 AS base +FROM mcr.microsoft.com/dotnet/sdk:10.0 AS base WORKDIR /app EXPOSE 80 -FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build +FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build WORKDIR /src COPY ["SS14.MapServer/SS14.MapServer.csproj", "SS14.MapServer/"] RUN dotnet restore "SS14.MapServer/SS14.MapServer.csproj" From a9bbe9190aec336e59e1e89e6e96389d98faf4ce Mon Sep 17 00:00:00 2001 From: Blobadoodle Date: Sat, 18 Apr 2026 18:56:52 +0100 Subject: [PATCH 3/4] fix some warnings --- SS14.MapServer/Controllers/GitHubWebhookController.cs | 4 ++-- SS14.MapServer/Helpers/MapFromDataParameterFilter.cs | 8 +++++++- SS14.MapServer/Jobs/ProcessTiledImage.cs | 2 +- SS14.MapServer/Models/DTOs/MapRendererData.cs | 8 ++++---- SS14.MapServer/Security/ExcludeAnonymousSecurityFilter.cs | 4 ++-- SS14.MapServer/Services/FileManagementService.cs | 2 +- SS14.MapServer/Services/MapService.cs | 4 ++-- 7 files changed, 19 insertions(+), 13 deletions(-) diff --git a/SS14.MapServer/Controllers/GitHubWebhookController.cs b/SS14.MapServer/Controllers/GitHubWebhookController.cs index 407eea9..67e7207 100644 --- a/SS14.MapServer/Controllers/GitHubWebhookController.cs +++ b/SS14.MapServer/Controllers/GitHubWebhookController.cs @@ -64,7 +64,7 @@ public async Task Post() var cloneUrl = pushEvent.Repository?.CloneUrl ?? string.Empty; if (cloneUrl != string.Empty && !_gitConfiguration.RepositoryUrl.Equals(cloneUrl)) - return new BadRequestObjectResult($"Instance not configured for repository: {pushEvent.Repository.CloneUrl}"); + return new BadRequestObjectResult($"Instance not configured for repository: {pushEvent.Repository?.CloneUrl}"); switch (eventName) { @@ -319,7 +319,7 @@ private string GetGridImageUrl(Guid mapGuid, int gridId) /// public sealed class PatchedPushEventPayload : PushEventPayload { - public string Before { get; private set; } + public new string Before { get; private set; } public string After { get; private set; } public new string Ref { get; private set; } } diff --git a/SS14.MapServer/Helpers/MapFromDataParameterFilter.cs b/SS14.MapServer/Helpers/MapFromDataParameterFilter.cs index 6bd6570..5136655 100644 --- a/SS14.MapServer/Helpers/MapFromDataParameterFilter.cs +++ b/SS14.MapServer/Helpers/MapFromDataParameterFilter.cs @@ -12,12 +12,18 @@ public void Apply(OpenApiOperation operation, OperationFilterContext context) if (methodName != "PostMap" && methodName != "PutMap") return; + if (operation.RequestBody?.Content is null) + return; if(!operation.RequestBody.Content.TryGetValue("multipart/form-data", out var type)) return; + if(type.Schema?.Properties is null) + return; if(!type.Schema.Properties.TryGetValue("images", out var imagesParameter)) return; + if (type.Encoding is null) + return; if(!type.Encoding.TryGetValue("images", out var imageEncoding)) return; @@ -39,6 +45,6 @@ public void Apply(OpenApiOperation operation, OperationFilterContext context) type.Schema.Properties.Add("images", imagesParameter); type.Schema.Properties.Add("map", mapParameter); - type.Schema.Required.Clear(); + type.Schema?.Required?.Clear(); } } diff --git a/SS14.MapServer/Jobs/ProcessTiledImage.cs b/SS14.MapServer/Jobs/ProcessTiledImage.cs index e93a132..21f5f21 100644 --- a/SS14.MapServer/Jobs/ProcessTiledImage.cs +++ b/SS14.MapServer/Jobs/ProcessTiledImage.cs @@ -23,7 +23,7 @@ public async Task Execute(IJobExecutionContext context) { var dataMap = context.JobDetail.JobDataMap; - if (dataMap.Get(ProcessOptionsKey) is not ProcessingOptions options) + if (dataMap[ProcessOptionsKey] is not ProcessingOptions options) throw new JobExecutionException($"Job data value with key ${ProcessOptionsKey} and type ProcessingOptions is missing"); var tiles = await _processingService.TileImage( diff --git a/SS14.MapServer/Models/DTOs/MapRendererData.cs b/SS14.MapServer/Models/DTOs/MapRendererData.cs index 27dbe5c..1becdef 100644 --- a/SS14.MapServer/Models/DTOs/MapRendererData.cs +++ b/SS14.MapServer/Models/DTOs/MapRendererData.cs @@ -6,12 +6,12 @@ namespace SS14.MapServer.Models.DTOs; public sealed class MapRendererData { - public string Id {get; set;} + public required string Id {get; set;} [Required, JsonProperty("Name")] - public string DisplayName {get; set;} + public required string DisplayName {get; set;} [JsonProperty("Attributions")] public string? Attribution {get; set;} [Required] public List Grids {get;} = new(); - public List ParallaxLayers {get; set;} -} \ No newline at end of file + public required List ParallaxLayers {get; set;} +} diff --git a/SS14.MapServer/Security/ExcludeAnonymousSecurityFilter.cs b/SS14.MapServer/Security/ExcludeAnonymousSecurityFilter.cs index cd54eb8..ef598a6 100644 --- a/SS14.MapServer/Security/ExcludeAnonymousSecurityFilter.cs +++ b/SS14.MapServer/Security/ExcludeAnonymousSecurityFilter.cs @@ -15,8 +15,8 @@ public void Apply(OpenApiOperation operation, OperationFilterContext context) if (allowsAnonymousAccess) return; - operation.Responses.Add("401", new OpenApiResponse { Description = "Unauthorized" }); - operation.Responses.Add("403", new OpenApiResponse { Description = "Forbidden" }); + operation.Responses?.Add("401", new OpenApiResponse { Description = "Unauthorized" }); + operation.Responses?.Add("403", new OpenApiResponse { Description = "Forbidden" }); var apiKeyScheme = new OpenApiSecuritySchemeReference(ApiKeyHandler.Name, context.Document); diff --git a/SS14.MapServer/Services/FileManagementService.cs b/SS14.MapServer/Services/FileManagementService.cs index 5276e84..816e493 100644 --- a/SS14.MapServer/Services/FileManagementService.cs +++ b/SS14.MapServer/Services/FileManagementService.cs @@ -60,7 +60,7 @@ private Task InternalCleanBuildDirectories() file.Delete(); filesCounter++; } - catch (Exception e) + catch (Exception) { // Ignore } diff --git a/SS14.MapServer/Services/MapService.cs b/SS14.MapServer/Services/MapService.cs index d936569..c316c38 100644 --- a/SS14.MapServer/Services/MapService.cs +++ b/SS14.MapServer/Services/MapService.cs @@ -44,7 +44,7 @@ private void DeleteFile(string path) { File.Delete(path); } - catch (Exception _) + catch (Exception) { // Best effort deletion } @@ -56,7 +56,7 @@ private void DeleteDirectory(string path) { Directory.Delete(path, true); } - catch (Exception _) + catch (Exception) { // Best effort deletion } From be119a2815d0109b041b77694ea0c817ba1c322f Mon Sep 17 00:00:00 2001 From: Blobadoodle Date: Sat, 18 Apr 2026 19:00:39 +0100 Subject: [PATCH 4/4] dotnet 10 workflows --- .github/workflows/build-test.yml | 2 +- .github/workflows/deploy-dev-image.yml | 2 +- .github/workflows/deploy.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 0cc262b..a706dfd 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -15,7 +15,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 7.x.x + dotnet-version: 10.x.x - name: Restore dependencies run: dotnet restore - name: Build diff --git a/.github/workflows/deploy-dev-image.yml b/.github/workflows/deploy-dev-image.yml index 9a5d87e..c656536 100644 --- a/.github/workflows/deploy-dev-image.yml +++ b/.github/workflows/deploy-dev-image.yml @@ -21,7 +21,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 7.x.x + dotnet-version: 10.x.x - name: Restore dependencies run: dotnet restore diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index d89d852..4e5b6ee 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -23,7 +23,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 7.x.x + dotnet-version: 10.x.x - name: Restore dependencies run: dotnet restore