From 2bd2dfabd175502bf81467c5b1a067dbc5120367 Mon Sep 17 00:00:00 2001 From: Daniel Pfeiffer Date: Fri, 30 May 2025 17:05:24 -0500 Subject: [PATCH] Updates Float.Core for MAUI 9 --- .github/workflows/deploy.yml | 27 +++++++++++-------- .github/workflows/test.yml | 7 +++-- Float.Core.Tests/DebounceCommand.tests.cs | 4 ++- Float.Core.Tests/Float.Core.Tests.csproj | 17 ++++++------ Float.Core/Float.Core.csproj | 17 +++++++++--- Float.Core/L10n/TranslateExtension.cs | 2 +- .../Notifications/AlertNotificationHandler.cs | 4 +++ version.json | 14 ---------- 8 files changed, 48 insertions(+), 44 deletions(-) delete mode 100644 version.json diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ff0c266..6098951 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -9,30 +9,35 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Setup .NET - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v4 with: - dotnet-version: | - 6.0.x - 7.0.x - 8.0.x + dotnet-version: 9.0.x - name: Retore Workload run: dotnet workload restore - name: Restore dependencies run: dotnet restore - # This action does a nice job of updating the version, but it does not ensure a valid version format. - - name: .NET project version updater + - name: Prepare assembly version + id: version + run: | + VERSION=${{ github.event.release.name }} + echo "assembly=${VERSION%-*}.${{ github.run_number }}" >> "$GITHUB_OUTPUT" + - name: Update project version uses: vers-one/dotnet-project-version-updater@v1.7 with: - file: | - "Float.Core/Float.Core.csproj", "**/*.nuspec", "**/AssemblyInfo.cs" + file: "**/*.csproj" version: ${{ github.event.release.name }} + - name: Update assembly version + uses: vers-one/dotnet-project-version-updater@v1.7 + with: + file: "**/AssemblyInfo.cs" + version: ${{ steps.version.outputs.assembly }} - name: Build Library run: dotnet build ./Float.Core/Float.Core.csproj --configuration Release --no-restore - - name: Pack and Upload + - name: Pack run: dotnet pack --configuration Release --no-restore - name: Archive artifact uses: actions/upload-artifact@v4 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 612caf9..7443631 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,14 +9,13 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup .NET - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v4 with: dotnet-version: | - 6.0.x - 7.0.x 8.0.x + 9.0.x - name: Restore Workload run: dotnet workload restore - name: Restore dependencies diff --git a/Float.Core.Tests/DebounceCommand.tests.cs b/Float.Core.Tests/DebounceCommand.tests.cs index be57072..1b848db 100644 --- a/Float.Core.Tests/DebounceCommand.tests.cs +++ b/Float.Core.Tests/DebounceCommand.tests.cs @@ -13,6 +13,8 @@ namespace Float.Core.Tests { public class DebounceCommandTests { + Timer timer; + [Fact] public async Task TestDoesDebounceTimer() { @@ -23,7 +25,7 @@ public async Task TestDoesDebounceTimer() var debouncedIncrementCommand = new DebounceCommand(incrementCommand, 450); // attempt to increment every 100ms - new Timer(arg => debouncedIncrementCommand.Execute(arg), null, 100, 100); + timer = new Timer(arg => debouncedIncrementCommand.Execute(arg), null, 100, 100); // wait one second await Task.Delay(1000); diff --git a/Float.Core.Tests/Float.Core.Tests.csproj b/Float.Core.Tests/Float.Core.Tests.csproj index d30cbda..bdf7f58 100644 --- a/Float.Core.Tests/Float.Core.Tests.csproj +++ b/Float.Core.Tests/Float.Core.Tests.csproj @@ -1,9 +1,8 @@ - net7.0;net8.0; + net8.0;net9.0; false 9.0 - true @@ -11,13 +10,13 @@ ../stylecop.ruleset - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all @@ -33,9 +32,9 @@ - - - + + + diff --git a/Float.Core/Float.Core.csproj b/Float.Core/Float.Core.csproj index 9512928..8485233 100644 --- a/Float.Core/Float.Core.csproj +++ b/Float.Core/Float.Core.csproj @@ -1,6 +1,6 @@ - net7.0;net8.0; + netstandard2;net7.0;net8.0;net9.0; Float.Core Float Common utility code used by Float projects. @@ -37,11 +37,20 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all - + - - + + + + + + + + + + + diff --git a/Float.Core/L10n/TranslateExtension.cs b/Float.Core/L10n/TranslateExtension.cs index f8dfb63..f04968b 100644 --- a/Float.Core/L10n/TranslateExtension.cs +++ b/Float.Core/L10n/TranslateExtension.cs @@ -7,7 +7,6 @@ using Xamarin.Forms; using Xamarin.Forms.Xaml; #else -using Microsoft.Maui; using Microsoft.Maui.Controls; using Microsoft.Maui.Controls.Xaml; #endif @@ -18,6 +17,7 @@ namespace Float.Core.L10n /// The markup extension allowing XAML to contain localization. /// [ContentProperty("Text")] + [AcceptEmptyServiceProvider] public class TranslateExtension : IMarkupExtension { static readonly List RegisteredResourceManagers = new () diff --git a/Float.Core/Notifications/AlertNotificationHandler.cs b/Float.Core/Notifications/AlertNotificationHandler.cs index 74fb956..c74e5ce 100644 --- a/Float.Core/Notifications/AlertNotificationHandler.cs +++ b/Float.Core/Notifications/AlertNotificationHandler.cs @@ -70,7 +70,11 @@ protected void DisplayAlert(string title, string message) { DeviceProxy.BeginInvokeOnMainThread(() => { + #if NET8_0_OR_GREATER + var page = context ?? Application.Current.Windows[0].Page; + #else var page = context ?? Application.Current.MainPage; + #endif page.DisplayAlert(title, message, Localize.String("OK")); }); } diff --git a/version.json b/version.json deleted file mode 100644 index 866c082..0000000 --- a/version.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", - "version": "1.0", - "assemblyVersion": { - "precision": "build" - }, - "nugetPackageVersion": { - "semVer": 2 - }, - "publicReleaseRefSpec": [ - "^refs/heads/main$", - "^refs/tags/v\\d+\\.\\d+" - ] -}