From 2cc4efb886a6c85977bff535cb19e7c217f678f5 Mon Sep 17 00:00:00 2001 From: Carl Mathieu Date: Fri, 17 Nov 2023 20:18:54 -0500 Subject: [PATCH] feat!: Update to Uno 5 --- BREAKING_CHANGES.md | 8 ++ README.md | 1 + build/azure-pipelines.yml | 15 +-- .../DynamicMvvm.Abstractions.csproj | 2 +- .../DynamicMvvm.CollectionTracking.csproj | 2 +- .../DynamicMvvm.FluentValidation.csproj | 2 +- .../DynamicMvvm.Reactive.csproj | 2 +- .../DynamicMvvm.Uno.WinUI.csproj | 12 +- .../BatchingCoreDispatcherDispatcher.cs | 119 ------------------ .../Dispatchers/CoreDispatcherDispatcher.cs | 76 ----------- .../Dispatchers/DispatcherFactory.cs | 44 ------- src/DynamicMvvm.Uno/DynamicMvvm.Uno.csproj | 53 -------- .../ViewModel/IViewModel.Extensions.Uno.cs | 20 --- src/DynamicMvvm/DynamicMvvm.csproj | 2 +- 14 files changed, 22 insertions(+), 336 deletions(-) delete mode 100644 src/DynamicMvvm.Uno/Dispatchers/BatchingCoreDispatcherDispatcher.cs delete mode 100644 src/DynamicMvvm.Uno/Dispatchers/CoreDispatcherDispatcher.cs delete mode 100644 src/DynamicMvvm.Uno/Dispatchers/DispatcherFactory.cs delete mode 100644 src/DynamicMvvm.Uno/DynamicMvvm.Uno.csproj delete mode 100644 src/DynamicMvvm.Uno/ViewModel/IViewModel.Extensions.Uno.cs diff --git a/BREAKING_CHANGES.md b/BREAKING_CHANGES.md index f84b4c5..0de8558 100644 --- a/BREAKING_CHANGES.md +++ b/BREAKING_CHANGES.md @@ -1,5 +1,13 @@ # Breaking Changes +## 2.0.0 +- Added support for .NET 7. +- Updated Uno.WinUI to 5.0.19. +- Updated Windows SDK version from 18362 to 19041. +- Removed support for Xamarin. +- Removed support for .NET 6. +- Removed support for NetStandard2.0 in DynamicMvvm.Uno.WinUI. + ## 0.11.0 - `DecoratorCommandStrategy` not longer exists. Use `DelegatingCommandStrategy` instead. diff --git a/README.md b/README.md index 8e16d17..fe83e6f 100644 --- a/README.md +++ b/README.md @@ -110,6 +110,7 @@ public MainPage() } ``` +### Legacy For UWP or Uno.UI apps, install the `Chinook.DynamicMvvm.Uno` nuget package. You can then use `CoreDispatcherDispatcher` or `BatchingCoreDispatcherDispatcher`. ```csharp diff --git a/build/azure-pipelines.yml b/build/azure-pipelines.yml index 3e718e1..2887a89 100644 --- a/build/azure-pipelines.yml +++ b/build/azure-pipelines.yml @@ -3,11 +3,6 @@ include: - main -resources: - containers: - - container: windows - image: nventive/vs_build-tools:17.2.5 - variables: - name: NUGET_VERSION value: 6.2.0 @@ -20,8 +15,8 @@ variables: - name: IsReleaseBranch # Should this branch name use the release stage value: $[or(eq(variables['Build.SourceBranch'], 'refs/heads/main'), startsWith(variables['Build.SourceBranch'], 'refs/heads/feature/'))] # Pool names -- name: windowsPoolName - value: 'windows 2022' +- name: windowsHostedAgentImage + value: 'windows-2022' stages: - stage: Build @@ -36,7 +31,7 @@ stages: GeneratePackageOnBuild: true pool: - name: $(windowsPoolName) + vmImage: $(windowsHostedAgentImage) variables: - name: PackageOutputPath # Path where nuget packages will be copied to. @@ -45,8 +40,6 @@ stages: workspace: clean: all # Cleanup the workspaca before starting - container: windows - steps: - template: stage-build.yml @@ -57,7 +50,7 @@ stages: - job: Publish_NuGet_External pool: - name: $(windowsPoolName) + vmImage: $(windowsHostedAgentImage) workspace: clean: all # Cleanup the workspaca before starting diff --git a/src/DynamicMvvm.Abstractions/DynamicMvvm.Abstractions.csproj b/src/DynamicMvvm.Abstractions/DynamicMvvm.Abstractions.csproj index 575dfa2..736ca8f 100644 --- a/src/DynamicMvvm.Abstractions/DynamicMvvm.Abstractions.csproj +++ b/src/DynamicMvvm.Abstractions/DynamicMvvm.Abstractions.csproj @@ -10,7 +10,7 @@ Chinook.DynamicMvvm is a collection of extensible MVVM libraries for declarative ViewModels. true README.md - mvvm;xamarin;ios;android;uwp;chinook;maui;winui; + mvvm;ios;android;chinook;maui;winui; Apache-2.0 https://github.com/nventive/Chinook.DynamicMvvm diff --git a/src/DynamicMvvm.CollectionTracking/DynamicMvvm.CollectionTracking.csproj b/src/DynamicMvvm.CollectionTracking/DynamicMvvm.CollectionTracking.csproj index fea4294..7ca71d7 100644 --- a/src/DynamicMvvm.CollectionTracking/DynamicMvvm.CollectionTracking.csproj +++ b/src/DynamicMvvm.CollectionTracking/DynamicMvvm.CollectionTracking.csproj @@ -10,7 +10,7 @@ Chinook.DynamicMvvm is a collection of extensible MVVM libraries for declarative ViewModels. true README.md - mvvm;xamarin;ios;android;uwp;chinook;maui;winui; + mvvm;ios;android;uwp;chinook;maui;winui; Apache-2.0 https://github.com/nventive/Chinook.DynamicMvvm diff --git a/src/DynamicMvvm.FluentValidation/DynamicMvvm.FluentValidation.csproj b/src/DynamicMvvm.FluentValidation/DynamicMvvm.FluentValidation.csproj index 70c8495..84e973e 100644 --- a/src/DynamicMvvm.FluentValidation/DynamicMvvm.FluentValidation.csproj +++ b/src/DynamicMvvm.FluentValidation/DynamicMvvm.FluentValidation.csproj @@ -10,7 +10,7 @@ Chinook.DynamicMvvm is a collection of extensible MVVM libraries for declarative ViewModels. true README.md - mvvm;xamarin;ios;android;uwp;chinook;maui;winui; + mvvm;ios;android;chinook;maui;winui; Apache-2.0 https://github.com/nventive/Chinook.DynamicMvvm diff --git a/src/DynamicMvvm.Reactive/DynamicMvvm.Reactive.csproj b/src/DynamicMvvm.Reactive/DynamicMvvm.Reactive.csproj index edfafa2..65ffada 100644 --- a/src/DynamicMvvm.Reactive/DynamicMvvm.Reactive.csproj +++ b/src/DynamicMvvm.Reactive/DynamicMvvm.Reactive.csproj @@ -10,7 +10,7 @@ Chinook.DynamicMvvm is a collection of extensible MVVM libraries for declarative ViewModels. true README.md - mvvm;xamarin;ios;android;uwp;chinook;maui;winui; + mvvm;ios;android;chinook;maui;winui; Apache-2.0 https://github.com/nventive/Chinook.DynamicMvvm diff --git a/src/DynamicMvvm.Uno.WinUI/DynamicMvvm.Uno.WinUI.csproj b/src/DynamicMvvm.Uno.WinUI/DynamicMvvm.Uno.WinUI.csproj index c3f4305..46c254b 100644 --- a/src/DynamicMvvm.Uno.WinUI/DynamicMvvm.Uno.WinUI.csproj +++ b/src/DynamicMvvm.Uno.WinUI/DynamicMvvm.Uno.WinUI.csproj @@ -1,7 +1,7 @@  - net6.0-windows10.0.18362;netstandard2.0;net6.0-android;net6.0-ios;net6.0-macos;net6.0-maccatalyst; - 10.0 + net7.0-windows10.0.19041;net7.0-android;net7.0-ios;net7.0-macos;net7.0-maccatalyst; + 11.0 true Chinook.DynamicMvvm @@ -32,20 +32,16 @@ - + - - $(DefineConstants);__WASM__ - - - + diff --git a/src/DynamicMvvm.Uno/Dispatchers/BatchingCoreDispatcherDispatcher.cs b/src/DynamicMvvm.Uno/Dispatchers/BatchingCoreDispatcherDispatcher.cs deleted file mode 100644 index 6e82664..0000000 --- a/src/DynamicMvvm.Uno/Dispatchers/BatchingCoreDispatcherDispatcher.cs +++ /dev/null @@ -1,119 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.Extensions.Logging; -using Windows.UI.Core; -using Windows.UI.Xaml; - -namespace Chinook.DynamicMvvm -{ - /// - /// This implementation of batches its operations to reduce the call count of .
- /// When is invoked, the dispatcher operation is delayed by a small duration during which other invocations that may occur are accumulated. - /// After that short delay, all accumulated actions are executed within the same . - ///
- public class BatchingCoreDispatcherDispatcher : IDispatcher - { - private readonly CoreDispatcher _coreDispatcher; - private readonly int _throttleDurationMs; - private readonly object _mutex = new object(); - private readonly Queue _requests = new Queue(capacity: 128); - - /// - /// Initializes a new instance of the class. - /// - /// The from which to retrieve the . - /// The amount of time during which the batching accumulation occurs. - public BatchingCoreDispatcherDispatcher(FrameworkElement frameworkElement, int throttleDurationMs = 10) - { - if (frameworkElement is null) - { - throw new ArgumentNullException(nameof(frameworkElement)); - } - - _coreDispatcher = frameworkElement.Dispatcher; - _throttleDurationMs = throttleDurationMs; - } - - /// - /// Initializes a new instance of the class. - /// - /// The . - /// The amount of time during which the batching accumulation occurs. - public BatchingCoreDispatcherDispatcher(CoreDispatcher coreDispatcher, int throttleDurationMs = 10) - { - _coreDispatcher = coreDispatcher ?? throw new ArgumentNullException(nameof(coreDispatcher)); - _throttleDurationMs = throttleDurationMs; - } - - /// - public bool GetHasDispatcherAccess() => _coreDispatcher.HasThreadAccess; - - /// - public async Task ExecuteOnDispatcher(CancellationToken ct, Action action) - { - if (ct.IsCancellationRequested) - { - this.Log().LogDebug($"Cancelled 'ExecuteOnDispatcher' because of the cancellation token."); - return; - } - - if (GetHasDispatcherAccess()) - { - this.Log().LogDebug($"Executed action immediately because already on dispatcher."); - action(); - return; - } - - lock (_mutex) - { - _requests.Enqueue(new Request { CT = ct, Action = action }); - } - - await Task.Delay(_throttleDurationMs, ct); - - Request[] requests; - lock (_mutex) - { - requests = _requests.ToArray(); - _requests.Clear(); - } - - if (requests.Length == 0) - { - return; - } - - await _coreDispatcher.RunAsync(CoreDispatcherPriority.High, () => - { - foreach (var request in requests) - { - try - { - if (request.CT.IsCancellationRequested) - { - this.Log().LogDebug($"Cancelled 'ExecuteOnDispatcher' because of the cancellation token."); - continue; - } - - request.Action(); - } - catch (Exception e) - { - this.Log().LogError(e, "Failed 'ExecuteOnDispatcher'."); - } - } - }); - - this.Log().LogDebug($"Batched {requests.Length} dispatcher requests."); - } - - private class Request - { - public CancellationToken CT { get; set; } - - public Action Action { get; set; } - } - } -} diff --git a/src/DynamicMvvm.Uno/Dispatchers/CoreDispatcherDispatcher.cs b/src/DynamicMvvm.Uno/Dispatchers/CoreDispatcherDispatcher.cs deleted file mode 100644 index cf70776..0000000 --- a/src/DynamicMvvm.Uno/Dispatchers/CoreDispatcherDispatcher.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System; -using Windows.UI.Xaml; -using Windows.UI.Core; -using Microsoft.Extensions.Logging; -using System.Threading.Tasks; -using System.Threading; - -namespace Chinook.DynamicMvvm -{ - /// - /// This implementation of uses . - /// - public class CoreDispatcherDispatcher : IDispatcher - { - private readonly CoreDispatcher _coreDispatcher; - - /// - /// Initializes a new instance of the class. - /// - /// The from which to retrieve the . - public CoreDispatcherDispatcher(FrameworkElement frameworkElement) - { - if (frameworkElement is null) - { - throw new ArgumentNullException(nameof(frameworkElement)); - } - - _coreDispatcher = frameworkElement.Dispatcher; - } - - /// - /// Initializes a new instance of the class. - /// - /// The . - public CoreDispatcherDispatcher(CoreDispatcher coreDispatcher) - { - if (coreDispatcher is null) - { - throw new ArgumentNullException(nameof(coreDispatcher)); - } - - _coreDispatcher = coreDispatcher; - } - - /// - public bool GetHasDispatcherAccess() => _coreDispatcher.HasThreadAccess; - - /// - public async Task ExecuteOnDispatcher(CancellationToken ct, Action action) - { - if (ct.IsCancellationRequested) - { - this.Log().LogDebug($"Cancelled 'ExecuteOnDispatcher' because of the cancellation token."); - return; - } - - await _coreDispatcher.RunAsync(CoreDispatcherPriority.High, () => - { - try - { - if (ct.IsCancellationRequested) - { - this.Log().LogDebug($"Cancelled 'ExecuteOnDispatcher' because of the cancellation token."); - return; - } - - action(); - } - catch (Exception e) - { - this.Log().LogError(e, "Failed 'ExecuteOnDispatcher'."); - } - }); - } - } -} diff --git a/src/DynamicMvvm.Uno/Dispatchers/DispatcherFactory.cs b/src/DynamicMvvm.Uno/Dispatchers/DispatcherFactory.cs deleted file mode 100644 index 8cfaad7..0000000 --- a/src/DynamicMvvm.Uno/Dispatchers/DispatcherFactory.cs +++ /dev/null @@ -1,44 +0,0 @@ -using Windows.UI.Xaml; - -namespace Chinook.DynamicMvvm -{ - /// - /// This is the default implementation of . - /// It uses the implementation by default. - /// - [Preserve(AllMembers = true)] - public class DispatcherFactory : IDispatcherFactory - { - private readonly CreateDispatcher _createDispatcher; - - /// - /// Creates a new instance of . - /// - /// - /// The optional method to use to generate the . - /// When not provided, a method using the implementation is used. - /// - public DispatcherFactory(CreateDispatcher createDispatcher = null) - { - _createDispatcher = createDispatcher ?? CreateFromCoreDispatcher; - } - - /// - public IDispatcher Create(object view) - { - return _createDispatcher(view); - } - - private IDispatcher CreateFromCoreDispatcher(object view) - { - return new CoreDispatcherDispatcher((FrameworkElement)view); - } - } - - /// - /// This deletage is used to create an from a native view object. - /// - /// The native view object. - /// A instance. - public delegate IDispatcher CreateDispatcher(object view); -} diff --git a/src/DynamicMvvm.Uno/DynamicMvvm.Uno.csproj b/src/DynamicMvvm.Uno/DynamicMvvm.Uno.csproj deleted file mode 100644 index c870081..0000000 --- a/src/DynamicMvvm.Uno/DynamicMvvm.Uno.csproj +++ /dev/null @@ -1,53 +0,0 @@ - - - - netstandard2.0;xamarinios10; - netstandard2.0;xamarinios10;monoandroid11.0;monoandroid12.0;uap10.0.19041 - - true - Chinook.DynamicMvvm - nventive - nventive - Chinook.DynamicMvvm.Uno - Chinook.DynamicMvvm.Uno - Chinook.DynamicMvvm is a collection of extensible MVVM libraries for declarative ViewModels. - true - README.md - mvvm;xamarin;ios;android;uwp;chinook; - Apache-2.0 - https://github.com/nventive/Chinook.DynamicMvvm - - - true - true - true - snupkg - - - - - True - \ - - - - - $(DefineConstants);__WASM__ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/DynamicMvvm.Uno/ViewModel/IViewModel.Extensions.Uno.cs b/src/DynamicMvvm.Uno/ViewModel/IViewModel.Extensions.Uno.cs deleted file mode 100644 index f722b22..0000000 --- a/src/DynamicMvvm.Uno/ViewModel/IViewModel.Extensions.Uno.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Windows.UI.Xaml; - -namespace Chinook.DynamicMvvm -{ - /// - /// Extensions on for Uno. - /// - public static class UnoViewModelExtensions - { - /// - /// Attaches a to a by setting the using the implementation. - /// - /// - /// - public static void AttachToView(this IViewModel viewModel, FrameworkElement frameworkElement) - { - viewModel.Dispatcher = new CoreDispatcherDispatcher(frameworkElement); - } - } -} diff --git a/src/DynamicMvvm/DynamicMvvm.csproj b/src/DynamicMvvm/DynamicMvvm.csproj index 551645f..131b22c 100644 --- a/src/DynamicMvvm/DynamicMvvm.csproj +++ b/src/DynamicMvvm/DynamicMvvm.csproj @@ -10,7 +10,7 @@ Chinook.DynamicMvvm is a collection of extensible MVVM libraries for declarative ViewModels. true README.md - mvvm;xamarin;ios;android;uwp;chinook;maui;winui; + mvvm;ios;android;chinook;maui;winui; Apache-2.0 https://github.com/nventive/Chinook.DynamicMvvm