From 1e83ffc13129e6b975780963e0bb4f7fd1b6e553 Mon Sep 17 00:00:00 2001 From: Eddasol Date: Thu, 16 Jan 2025 10:46:09 +0100 Subject: [PATCH 1/2] Update to dotnet9 --- .github/workflows/backend_lint_and_test.yml | 6 +++--- .github/workflows/runMigrations.yml | 4 ++-- backend/.config/dotnet-tools.json | 2 +- backend/Dockerfile | 4 ++-- backend/api.test/api.test.csproj | 4 ++-- backend/api/api.csproj | 12 ++++++------ 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/backend_lint_and_test.yml b/.github/workflows/backend_lint_and_test.yml index 969d245fd..701000206 100644 --- a/.github/workflows/backend_lint_and_test.yml +++ b/.github/workflows/backend_lint_and_test.yml @@ -22,7 +22,7 @@ jobs: - name: Set up .NET uses: actions/setup-dotnet@v4 with: - dotnet-version: "8.0.x" + dotnet-version: "9.0.x" - name: Build project and dependencies run: dotnet build @@ -35,7 +35,7 @@ jobs: - name: Set up .NET uses: actions/setup-dotnet@v4 with: - dotnet-version: "8.0.x" + dotnet-version: "9.0.x" - name: Build project and dependencies run: dotnet build -warnaserror @@ -51,7 +51,7 @@ jobs: - name: Setup .NET Core uses: actions/setup-dotnet@v4 with: - dotnet-version: "8.0.x" + dotnet-version: "9.0.x" - name: Run csharpier format run: | diff --git a/.github/workflows/runMigrations.yml b/.github/workflows/runMigrations.yml index 079850952..c36de611a 100644 --- a/.github/workflows/runMigrations.yml +++ b/.github/workflows/runMigrations.yml @@ -45,13 +45,13 @@ jobs: - name: Set up .NET uses: actions/setup-dotnet@v4 with: - dotnet-version: "8.0.x" + dotnet-version: "9.0.x" - name: Build project and dependencies run: dotnet build - name: Install dotnet ef tool - run: dotnet tool install -g dotnet-ef --version 8.0.0 + run: dotnet tool install -g dotnet-ef --version 9.0.0 - name: Update database run: dotnet ef database update --no-build --verbose diff --git a/backend/.config/dotnet-tools.json b/backend/.config/dotnet-tools.json index c8a1c60aa..3c40b6da3 100644 --- a/backend/.config/dotnet-tools.json +++ b/backend/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "csharpier": { - "version": "0.29.2", + "version": "0.30.6", "commands": [ "dotnet-csharpier" ] diff --git a/backend/Dockerfile b/backend/Dockerfile index 71c1c55c1..5c0a96af4 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,5 +1,5 @@ # https://hub.docker.com/_/microsoft-dotnet -FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build WORKDIR /source # copy everything @@ -9,7 +9,7 @@ WORKDIR /source/api RUN dotnet publish -c release -o /app # final stage/image -FROM mcr.microsoft.com/dotnet/aspnet:8.0 +FROM mcr.microsoft.com/dotnet/aspnet:9.0 WORKDIR /app COPY --from=build /app ./ RUN apt-get update && apt-get install -y apt-utils libgdiplus libc6-dev diff --git a/backend/api.test/api.test.csproj b/backend/api.test/api.test.csproj index 58647026a..a20bb78c6 100644 --- a/backend/api.test/api.test.csproj +++ b/backend/api.test/api.test.csproj @@ -1,7 +1,7 @@ - net8.0 + net9.0 enable false @@ -11,7 +11,7 @@ - + diff --git a/backend/api/api.csproj b/backend/api/api.csproj index ce196cc33..fed926d3a 100644 --- a/backend/api/api.csproj +++ b/backend/api/api.csproj @@ -1,7 +1,7 @@  - net8.0 + net9.0 enable enable f888e68d-d6f9-4dad-adb2-269ae53a9ea1 @@ -16,15 +16,15 @@ - - + + all runtime; build; native; contentfiles; analyzers - - - + + + From 820671b9140bd1e9e1deef58b1b5734dacb5cc4d Mon Sep 17 00:00:00 2001 From: Eddasol Date: Thu, 16 Jan 2025 13:48:20 +0100 Subject: [PATCH 2/2] Format to new csharper version --- backend/api.test/Mocks/MissionLoaderMock.cs | 21 +++++++++-------- backend/api/Database/Context/InitDb.cs | 17 +++++++------- backend/api/MQTT/MqttService.cs | 6 +++-- backend/api/MQTT/MqttTopics.cs | 25 ++++++++++----------- 4 files changed, 34 insertions(+), 35 deletions(-) diff --git a/backend/api.test/Mocks/MissionLoaderMock.cs b/backend/api.test/Mocks/MissionLoaderMock.cs index 2d1bf8946..35fe738ba 100644 --- a/backend/api.test/Mocks/MissionLoaderMock.cs +++ b/backend/api.test/Mocks/MissionLoaderMock.cs @@ -73,17 +73,16 @@ public class MockMissionLoader() : IMissionLoader ), ]; - private readonly MissionDefinition _mockMissionDefinition = - new() - { - InspectionArea = new InspectionArea(), - Comment = "", - Id = "", - InstallationCode = "TTT", - IsDeprecated = false, - Name = "test", - Source = new Source { Id = "", SourceId = "" }, - }; + private readonly MissionDefinition _mockMissionDefinition = new() + { + InspectionArea = new InspectionArea(), + Comment = "", + Id = "", + InstallationCode = "TTT", + IsDeprecated = false, + Name = "test", + Source = new Source { Id = "", SourceId = "" }, + }; public async Task GetMissionById(string sourceMissionId) { diff --git a/backend/api/Database/Context/InitDb.cs b/backend/api/Database/Context/InitDb.cs index d17a0e2e1..d2ac05020 100644 --- a/backend/api/Database/Context/InitDb.cs +++ b/backend/api/Database/Context/InitDb.cs @@ -576,15 +576,14 @@ public static void AddRobotModelsToContext(FlotillaDbContext context) { foreach (var type in Enum.GetValues()) { - RobotModel model = - new() - { - Type = type, - BatteryWarningThreshold = null, - BatteryMissionStartThreshold = null, - LowerPressureWarningThreshold = null, - UpperPressureWarningThreshold = null, - }; + RobotModel model = new() + { + Type = type, + BatteryWarningThreshold = null, + BatteryMissionStartThreshold = null, + LowerPressureWarningThreshold = null, + UpperPressureWarningThreshold = null, + }; context.Add(model); } } diff --git a/backend/api/MQTT/MqttService.cs b/backend/api/MQTT/MqttService.cs index 5b3f2b7aa..19da69619 100644 --- a/backend/api/MQTT/MqttService.cs +++ b/backend/api/MQTT/MqttService.cs @@ -28,8 +28,10 @@ public class MqttService : BackgroundService private readonly int _serverPort; private readonly bool _shouldFailOnMaxRetries; - private static readonly JsonSerializerOptions serializerOptions = - new() { Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) } }; + private static readonly JsonSerializerOptions serializerOptions = new() + { + Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }, + }; private CancellationToken _cancellationToken; private int _reconnectAttempts; diff --git a/backend/api/MQTT/MqttTopics.cs b/backend/api/MQTT/MqttTopics.cs index 93f052905..c984f4731 100644 --- a/backend/api/MQTT/MqttTopics.cs +++ b/backend/api/MQTT/MqttTopics.cs @@ -11,19 +11,18 @@ public static class MqttTopics /// /// A dictionary linking MQTT topics to their respective message models /// - public static readonly Dictionary TopicsToMessages = - new() - { - { "isar/+/status", typeof(IsarStatusMessage) }, - { "isar/+/robot_info", typeof(IsarRobotInfoMessage) }, - { "isar/+/robot_heartbeat", typeof(IsarRobotHeartbeatMessage) }, - { "isar/+/mission", typeof(IsarMissionMessage) }, - { "isar/+/task", typeof(IsarTaskMessage) }, - { "isar/+/battery", typeof(IsarBatteryMessage) }, - { "isar/+/pressure", typeof(IsarPressureMessage) }, - { "isar/+/pose", typeof(IsarPoseMessage) }, - { "isar/+/cloud_health", typeof(IsarCloudHealthMessage) }, - }; + public static readonly Dictionary TopicsToMessages = new() + { + { "isar/+/status", typeof(IsarStatusMessage) }, + { "isar/+/robot_info", typeof(IsarRobotInfoMessage) }, + { "isar/+/robot_heartbeat", typeof(IsarRobotHeartbeatMessage) }, + { "isar/+/mission", typeof(IsarMissionMessage) }, + { "isar/+/task", typeof(IsarTaskMessage) }, + { "isar/+/battery", typeof(IsarBatteryMessage) }, + { "isar/+/pressure", typeof(IsarPressureMessage) }, + { "isar/+/pose", typeof(IsarPoseMessage) }, + { "isar/+/cloud_health", typeof(IsarCloudHealthMessage) }, + }; /// /// Searches a dictionary for a specific topic name and returns the corresponding value from the wildcarded dictionary