From 00f83c57dcee25d5f4aaad1a183afec289e4bb9b Mon Sep 17 00:00:00 2001 From: Ken Tucker Date: Tue, 12 Nov 2024 21:08:58 -0500 Subject: [PATCH 1/9] Add .net 9 to platform --- .github/workflows/dotnet.yml | 18 +++++++----------- .../Caliburn.Micro.Platform.csproj | 18 +++++++++++++++++- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 18402f729..bfa1c5ec9 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -1,3 +1,4 @@ + # This workflow will build a .NET project # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net @@ -15,6 +16,7 @@ env: caliburn_features: "samples\\features\\features.sln" package_feed: "https://nuget.pkg.github.com/caliburn-micro/index.json" nuget_folder: "\\packages" + nuget_upload: 'packages\*.nupkg' build_configuration: "Release" jobs: @@ -29,7 +31,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 with: - dotnet-version: 8.0.x + dotnet-version: 9.0.x - name: Setup Java SDK uses: actions/setup-java@v4 with: @@ -50,14 +52,6 @@ jobs: run: dotnet workload install maui maui-android maui-ios maui-tizen maui-maccatalyst maui-windows android --source https://api.nuget.org/v3/index.json - name: list workloads run: dotnet workload list - - - name: Ensure GitHub NuGet Source - run: dotnet nuget add source ${{ env.package_feed }} - -n github - -u ${{ secrets.NUGET_USER }} - -p ${{ secrets.CONSUME_CALIBURN_FEED }} - --store-password-in-clear-text - if: github.event_name != 'pull_request' - name: Restore nuget packages run: msbuild ${{env.caliburn_sln}} -t:restore @@ -65,7 +59,9 @@ jobs: - name: Build app for release run: msbuild ${{env.caliburn_sln}} /t:Build /p:Configuration=${{env.build_configuration}} - + - name: Run Unit Tests + run: dotnet test src/caliburn.micro.sln --configuration release -p:CollectCoverage=true -p:CoverletOutputFormat=json --no-build --verbosity normal /p:MergeWith=..\Caliburn.Micro.Core.Tests\coverage.json /m:1 + - name: Restore nuget packages for tutorial run: msbuild ${{env.caliburn_tutorial}} -t:restore @@ -82,5 +78,5 @@ jobs: run: msbuild ${{env.caliburn_sln}} /t:package /p:Configuration=${{env.build_configuration}} - name: publish Nuget Packages to GitHub - run: dotnet nuget push ${{env.nuget_folder}}\**\*.nupkg --source ${{env.package_feed}} --api-key ${{secrets.PUBLISH_NUGET_PACKAGE}} --skip-duplicate + run: dotnet nuget push ${{env.nuget_upload}} --source ${{env.package_feed}} --api-key ${{secrets.PUBLISH_NUGET_PACKAGE}} --skip-duplicate if: github.event_name != 'pull_request' diff --git a/src/Caliburn.Micro.Platform/Caliburn.Micro.Platform.csproj b/src/Caliburn.Micro.Platform/Caliburn.Micro.Platform.csproj index 35a9e8dda..f6f2be903 100644 --- a/src/Caliburn.Micro.Platform/Caliburn.Micro.Platform.csproj +++ b/src/Caliburn.Micro.Platform/Caliburn.Micro.Platform.csproj @@ -1,7 +1,7 @@  - net462;uap10.0.19041;net8.0-android;net8.0-ios;net8.0-windows; + net462;uap10.0.19041;net8.0-android;net8.0-ios;net9.0-android;net9.0-ios;net8.0-windows;net9.0-windows Caliburn.Micro Caliburn.Micro Caliburn.Micro @@ -50,6 +50,10 @@ + + + + @@ -72,6 +76,18 @@ + + + + + + + + + + + + From 688067cef6b9bdb264883b11689f44c3067441b8 Mon Sep 17 00:00:00 2001 From: Ken Tucker Date: Tue, 12 Nov 2024 21:17:01 -0500 Subject: [PATCH 2/9] Update .NET version to 9.0.x in CI configuration files The .NET version used in `codeql-analysis.yml` and `azure-pipeline.yml` files has been updated from `8.0.x` to `9.0.x`. This ensures compatibility with the latest features and improvements in .NET 9.0.x. --- .github/workflows/codeql-analysis.yml | 2 +- azure-pipeline.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 10ebcf5b9..f995400ef 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -41,7 +41,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 with: - dotnet-version: 8.0.x + dotnet-version: 9.0.x - name: Setup Java SDK uses: actions/setup-java@v4 diff --git a/azure-pipeline.yml b/azure-pipeline.yml index 8c1e348fb..6eac9e207 100644 --- a/azure-pipeline.yml +++ b/azure-pipeline.yml @@ -15,7 +15,7 @@ steps: displayName: 'Install .NET' inputs: packageType: 'sdk' - version: '8.0.x' + version: '9.0.x' - task: PowerShell@2 From a9560573443907fba8aa4fd2f6250e6753467c61 Mon Sep 17 00:00:00 2001 From: Ken Tucker Date: Thu, 14 Nov 2024 06:11:06 -0500 Subject: [PATCH 3/9] Update features and setup apps for .net 9 --- samples/features/Features.NetFive/Features.DotNet.csproj | 6 +++--- samples/setup/Setup.UWP/Setup.UWP.csproj | 2 +- samples/setup/Setup.WPF.Core.VB/Bootstrapper.vb | 2 +- samples/setup/Setup.WPF.Core.VB/Setup.WPF.Core.VB.vbproj | 4 ++-- samples/setup/Setup.WPF.Core/Bootstrapper.cs | 5 +---- samples/setup/Setup.WPF.Core/Setup.WPF.Core.csproj | 4 ++-- 6 files changed, 10 insertions(+), 13 deletions(-) diff --git a/samples/features/Features.NetFive/Features.DotNet.csproj b/samples/features/Features.NetFive/Features.DotNet.csproj index 0c8c93993..cafeaa540 100644 --- a/samples/features/Features.NetFive/Features.DotNet.csproj +++ b/samples/features/Features.NetFive/Features.DotNet.csproj @@ -2,7 +2,7 @@ WinExe - net8.0-windows + net9.0-windows true Features.CrossPlatform Features.CrossPlatform @@ -23,10 +23,10 @@ - ..\..\..\bin\Caliburn.Micro.Platform\release\net8.0-windows\Caliburn.Micro.Core.dll + ..\..\..\bin\Caliburn.Micro.Platform\release\net9.0-windows\Caliburn.Micro.Core.dll - ..\..\..\bin\Caliburn.Micro.Platform\release\net8.0-windows\Caliburn.Micro.Platform.dll + ..\..\..\bin\Caliburn.Micro.Platform\release\net9.0-windows\Caliburn.Micro.Platform.dll diff --git a/samples/setup/Setup.UWP/Setup.UWP.csproj b/samples/setup/Setup.UWP/Setup.UWP.csproj index b487e2f13..7888d0233 100644 --- a/samples/setup/Setup.UWP/Setup.UWP.csproj +++ b/samples/setup/Setup.UWP/Setup.UWP.csproj @@ -127,7 +127,7 @@ 4.0.173 - 6.2.12 + 6.2.14 diff --git a/samples/setup/Setup.WPF.Core.VB/Bootstrapper.vb b/samples/setup/Setup.WPF.Core.VB/Bootstrapper.vb index 5fa1593d3..8f13e1bb0 100644 --- a/samples/setup/Setup.WPF.Core.VB/Bootstrapper.vb +++ b/samples/setup/Setup.WPF.Core.VB/Bootstrapper.vb @@ -18,7 +18,7 @@ Public Class Bootstrapper End Sub Protected Overrides Sub OnStartup(sender As Object, e As StartupEventArgs) - DisplayRootViewFor(Of ShellViewModel)() + DisplayRootViewForAsync(Of ShellViewModel)() End Sub Protected Overrides Function GetInstance(service As Type, key As String) As Object diff --git a/samples/setup/Setup.WPF.Core.VB/Setup.WPF.Core.VB.vbproj b/samples/setup/Setup.WPF.Core.VB/Setup.WPF.Core.VB.vbproj index e620206aa..b25bdcff5 100644 --- a/samples/setup/Setup.WPF.Core.VB/Setup.WPF.Core.VB.vbproj +++ b/samples/setup/Setup.WPF.Core.VB/Setup.WPF.Core.VB.vbproj @@ -2,7 +2,7 @@ WinExe - net8.0-windows + net9.0-windows Setup.WPF.Core.VB true @@ -20,7 +20,7 @@ - + diff --git a/samples/setup/Setup.WPF.Core/Bootstrapper.cs b/samples/setup/Setup.WPF.Core/Bootstrapper.cs index 5d1c4b3ce..0b9384619 100644 --- a/samples/setup/Setup.WPF.Core/Bootstrapper.cs +++ b/samples/setup/Setup.WPF.Core/Bootstrapper.cs @@ -1,8 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows; using Caliburn.Micro; using Setup.WPF.Core.ViewModels; @@ -30,7 +27,7 @@ protected override void Configure() protected override void OnStartup(object sender, StartupEventArgs e) { - DisplayRootViewFor(); + DisplayRootViewForAsync(); } protected override object GetInstance(Type service, string key) diff --git a/samples/setup/Setup.WPF.Core/Setup.WPF.Core.csproj b/samples/setup/Setup.WPF.Core/Setup.WPF.Core.csproj index 8354fadc7..93b91a125 100644 --- a/samples/setup/Setup.WPF.Core/Setup.WPF.Core.csproj +++ b/samples/setup/Setup.WPF.Core/Setup.WPF.Core.csproj @@ -2,12 +2,12 @@ WinExe - net8.0-windows + net9.0-windows true - + From 82d612fa86c7a34f92526c11b2c4008cc10caa85 Mon Sep 17 00:00:00 2001 From: Ken Tucker Date: Thu, 14 Nov 2024 07:42:12 -0500 Subject: [PATCH 4/9] update build --- .github/workflows/dotnet.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index bfa1c5ec9..8d4b8e8be 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -1,4 +1,3 @@ - # This workflow will build a .NET project # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net @@ -31,7 +30,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 with: - dotnet-version: 9.0.x + dotnet-version: 8.0.x - name: Setup Java SDK uses: actions/setup-java@v4 with: @@ -79,4 +78,4 @@ jobs: - name: publish Nuget Packages to GitHub run: dotnet nuget push ${{env.nuget_upload}} --source ${{env.package_feed}} --api-key ${{secrets.PUBLISH_NUGET_PACKAGE}} --skip-duplicate - if: github.event_name != 'pull_request' + #if: github.event_name != 'pull_request' \ No newline at end of file From f933789dba539862c46e005aca60d3e5abd5fea1 Mon Sep 17 00:00:00 2001 From: Ken Tucker Date: Thu, 14 Nov 2024 08:21:36 -0500 Subject: [PATCH 5/9] fix build --- .github/workflows/dotnet.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 8d4b8e8be..92f411517 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -30,7 +30,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 with: - dotnet-version: 8.0.x + dotnet-version: 9.0.x - name: Setup Java SDK uses: actions/setup-java@v4 with: From 68a36d9911e82dcfdd245784d5c8b4ebecc5f9fc Mon Sep 17 00:00:00 2001 From: Ken Tucker Date: Thu, 14 Nov 2024 08:34:18 -0500 Subject: [PATCH 6/9] make nugets only upload to github feed if it is a completed pr --- .github/workflows/dotnet.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 92f411517..f16e4e6bb 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -78,4 +78,4 @@ jobs: - name: publish Nuget Packages to GitHub run: dotnet nuget push ${{env.nuget_upload}} --source ${{env.package_feed}} --api-key ${{secrets.PUBLISH_NUGET_PACKAGE}} --skip-duplicate - #if: github.event_name != 'pull_request' \ No newline at end of file + if: github.event_name != 'pull_request' \ No newline at end of file From 11358dfd5dab117fb9fa14cc8c4d6dda08a9e546 Mon Sep 17 00:00:00 2001 From: Ken Tucker Date: Thu, 14 Nov 2024 09:17:21 -0500 Subject: [PATCH 7/9] use global.json to get .net version to install --- .github/workflows/dotnet.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index f16e4e6bb..8621160b1 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -30,7 +30,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 with: - dotnet-version: 9.0.x + global-json-file: src/global.json - name: Setup Java SDK uses: actions/setup-java@v4 with: From 923df781d18dfc486afb15c341e89c4226514005 Mon Sep 17 00:00:00 2001 From: Ken Tucker Date: Thu, 14 Nov 2024 09:49:22 -0500 Subject: [PATCH 8/9] Update global.json .net version Have codeql use global.json to .net version --- .github/workflows/codeql-analysis.yml | 2 +- src/global.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index f995400ef..66a3b36ba 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -41,7 +41,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v4 with: - dotnet-version: 9.0.x + global-json-file: src/global.json - name: Setup Java SDK uses: actions/setup-java@v4 diff --git a/src/global.json b/src/global.json index 0a13e1705..18141da90 100644 --- a/src/global.json +++ b/src/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "8.0.x", + "version": "9.0.x", "rollForward": "latestFeature" }, "msbuild-sdks": { From 438e7251a5e4012d1836810751814e26e2e96228 Mon Sep 17 00:00:00 2001 From: Ken Tucker Date: Thu, 14 Nov 2024 13:05:49 -0500 Subject: [PATCH 9/9] Refactor CI configs and enhance EventAggregator logging Updated codeql-analysis.yml and dotnet.yml to use a new environment variable 'caliburn_sln' for solution file paths, improving maintainability. Refactored EventAggregatorTests.cs to optimize message type handling. Added detailed logging in EventAggregator.cs to provide better insights into handler checks and registrations. --- .github/workflows/codeql-analysis.yml | 7 ++++--- .github/workflows/dotnet.yml | 2 +- src/Caliburn.Micro.Core.Tests/EventAggregatorTests.cs | 6 +++--- src/Caliburn.Micro.Core/EventAggregator.cs | 7 ++++++- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 66a3b36ba..04c47720d 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -8,7 +8,8 @@ on: branches: [master] schedule: - cron: '26 22 * * 0' - +env: + caliburn_sln : "src\\caliburn.micro.sln" jobs: analyse: name: Analyse @@ -65,10 +66,10 @@ jobs: run: dotnet workload list - name: Restore nuget packages - run: msbuild src\caliburn.micro.sln -t:restore + run: msbuild ${{env.caliburn_sln}} -t:restore - name: Build app for release - run: msbuild src\caliburn.micro.sln /t:Build + run: msbuild ${{env.caliburn_sln}} /t:Build # ℹ️ Command-line programs to run using the OS shell. # 📚 https://git.io/JvXDl diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 8621160b1..6f22227e6 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -59,7 +59,7 @@ jobs: run: msbuild ${{env.caliburn_sln}} /t:Build /p:Configuration=${{env.build_configuration}} - name: Run Unit Tests - run: dotnet test src/caliburn.micro.sln --configuration release -p:CollectCoverage=true -p:CoverletOutputFormat=json --no-build --verbosity normal /p:MergeWith=..\Caliburn.Micro.Core.Tests\coverage.json /m:1 + run: dotnet test ${{env.caliburn_sln}} --configuration ${{env.build_configuration}} -p:CollectCoverage=true -p:CoverletOutputFormat=json --no-build --verbosity normal - name: Restore nuget packages for tutorial run: msbuild ${{env.caliburn_tutorial}} -t:restore diff --git a/src/Caliburn.Micro.Core.Tests/EventAggregatorTests.cs b/src/Caliburn.Micro.Core.Tests/EventAggregatorTests.cs index 02f764447..5e501e37d 100644 --- a/src/Caliburn.Micro.Core.Tests/EventAggregatorTests.cs +++ b/src/Caliburn.Micro.Core.Tests/EventAggregatorTests.cs @@ -26,12 +26,12 @@ public void A_valid_subscriber_is_assigned_as_a_handler_its_message_type() { var handlerStub = new Mock>().Object; var aggregator = new EventAggregator(); - - Assert.False(aggregator.HandlerExistsFor(typeof(object))); + var messageType = typeof(object); + Assert.False(aggregator.HandlerExistsFor(messageType)); aggregator.SubscribeOnPublishedThread(handlerStub); - Assert.True(aggregator.HandlerExistsFor(typeof(object))); + Assert.True(aggregator.HandlerExistsFor(messageType)); } } diff --git a/src/Caliburn.Micro.Core/EventAggregator.cs b/src/Caliburn.Micro.Core/EventAggregator.cs index 2143c074a..6190b9cba 100644 --- a/src/Caliburn.Micro.Core/EventAggregator.cs +++ b/src/Caliburn.Micro.Core/EventAggregator.cs @@ -10,6 +10,8 @@ namespace Caliburn.Micro /// public class EventAggregator : IEventAggregator { + private static readonly ILog Log = LogManager.GetLog(typeof(EventAggregator)); + private readonly List _handlers = new List(); /// @@ -17,6 +19,8 @@ public virtual bool HandlerExistsFor(Type messageType) { lock (_handlers) { + Log.Info("Checking if handler exists for {0}.", messageType.FullName); + Log.Info("There are {0} handlers registered.", _handlers.Count); return _handlers.Any(handler => handler.Handles(messageType) && !handler.IsDead); } } @@ -38,9 +42,10 @@ public virtual void Subscribe(object subscriber, Func, Task> marshal) { if (_handlers.Any(x => x.Matches(subscriber))) { + Log.Info("Message Handler exists"); return; } - + Log.Info("Message Handler Adding it"); _handlers.Add(new Handler(subscriber, marshal)); } }