From 0761f1a8c15417b11b5860d3190770a88483f0b5 Mon Sep 17 00:00:00 2001 From: Markus Ewald Date: Thu, 19 Jun 2025 10:43:58 +0200 Subject: [PATCH] Upgraded project to .NET 8.0 because .NET 6.0 is out of support --- ...uclex.Windows.Forms (net-4.6)(net-8.0).csproj | 2 +- ...Windows.Forms.Tests (net-4.6)(net-8.0).csproj | 4 ++-- Source/AsyncProgressBar/AsyncProgressBar.cs | 7 +++++++ Source/CommonDialogs/CommonDialogManager.cs | 7 +++++++ Source/ContainerListView/ContainerListView.cs | 9 ++++++++- Source/LateCheckedSynchronizer.cs | 7 +++++++ Source/Messages/MessageServiceHelper.cs | 7 +++++++ Source/Messages/StandardMessageBoxManager.cs | 7 +++++++ Source/ViewModels/ThreadedAction.cs | 16 ++++++++++++++++ Source/ViewModels/ThreadedViewModel.cs | 6 ++++++ Source/Views/MultiPageViewForm.cs | 7 +++++++ Source/Views/ViewControl.cs | 6 +++++- Source/Views/ViewForm.cs | 13 ++++++++++++- Source/WindowManager.cs | 7 +++++++ Tests/Messages/MessageEventArgsTest.cs | 7 +++++++ Tests/WindowManagerTest.cs | 7 +++++++ 16 files changed, 113 insertions(+), 6 deletions(-) rename Nuclex.Windows.Forms (net-4.6)(net-6.0).csproj => Nuclex.Windows.Forms (net-4.6)(net-8.0).csproj (89%) rename Nuclex.Windows.Forms.Tests (net-4.6)(net-6.0).csproj => Nuclex.Windows.Forms.Tests (net-4.6)(net-8.0).csproj (88%) diff --git a/Nuclex.Windows.Forms (net-4.6)(net-6.0).csproj b/Nuclex.Windows.Forms (net-4.6)(net-8.0).csproj similarity index 89% rename from Nuclex.Windows.Forms (net-4.6)(net-6.0).csproj rename to Nuclex.Windows.Forms (net-4.6)(net-8.0).csproj index 8360577..4b5fe2c 100644 --- a/Nuclex.Windows.Forms (net-4.6)(net-6.0).csproj +++ b/Nuclex.Windows.Forms (net-4.6)(net-8.0).csproj @@ -1,7 +1,7 @@  - net462;net6.0-windows + net462;net8.0-windows Apache-2.0 false True diff --git a/Nuclex.Windows.Forms.Tests (net-4.6)(net-6.0).csproj b/Nuclex.Windows.Forms.Tests (net-4.6)(net-8.0).csproj similarity index 88% rename from Nuclex.Windows.Forms.Tests (net-4.6)(net-6.0).csproj rename to Nuclex.Windows.Forms.Tests (net-4.6)(net-8.0).csproj index 467100c..caf0bd4 100644 --- a/Nuclex.Windows.Forms.Tests (net-4.6)(net-6.0).csproj +++ b/Nuclex.Windows.Forms.Tests (net-4.6)(net-8.0).csproj @@ -1,7 +1,7 @@  - net462;net6.0-windows + net462;net8.0-windows Apache-2.0 false True @@ -26,7 +26,7 @@ - + diff --git a/Source/AsyncProgressBar/AsyncProgressBar.cs b/Source/AsyncProgressBar/AsyncProgressBar.cs index 237ff04..2e2f8b6 100644 --- a/Source/AsyncProgressBar/AsyncProgressBar.cs +++ b/Source/AsyncProgressBar/AsyncProgressBar.cs @@ -21,6 +21,10 @@ using System; using System.Threading; using System.Windows.Forms; +#if NET6_0_OR_GREATER +using System.Runtime.Versioning; +#endif + namespace Nuclex.Windows.Forms { /// Progress bar with optimized multi-threading behavior @@ -37,6 +41,9 @@ namespace Nuclex.Windows.Forms { /// worker thread, increasing its performance. /// /// +#if NET6_0_OR_GREATER + [SupportedOSPlatform("windows")] +#endif public partial class AsyncProgressBar : ProgressBar { /// Initializes a new asynchronous progress bar diff --git a/Source/CommonDialogs/CommonDialogManager.cs b/Source/CommonDialogs/CommonDialogManager.cs index 4bd4027..0b8ba02 100644 --- a/Source/CommonDialogs/CommonDialogManager.cs +++ b/Source/CommonDialogs/CommonDialogManager.cs @@ -21,9 +21,16 @@ using System; using System.Text; using System.Windows.Forms; +#if NET6_0_OR_GREATER +using System.Runtime.Versioning; +#endif + namespace Nuclex.Windows.Forms.CommonDialogs { /// Displays common dialogs for selecting files and directories +#if NET6_0_OR_GREATER + [SupportedOSPlatform("windows")] +#endif public class CommonDialogManager : ICommonDialogService { /// Initializes a new task dialog message service diff --git a/Source/ContainerListView/ContainerListView.cs b/Source/ContainerListView/ContainerListView.cs index a2a7edd..ccd0835 100644 --- a/Source/ContainerListView/ContainerListView.cs +++ b/Source/ContainerListView/ContainerListView.cs @@ -26,6 +26,10 @@ using System.Text; using System.Windows.Forms; using System.Runtime.InteropServices; +#if NET6_0_OR_GREATER +using System.Runtime.Versioning; +#endif + using Nuclex.Support.Collections; namespace Nuclex.Windows.Forms { @@ -44,12 +48,15 @@ namespace Nuclex.Windows.Forms { /// /// /// This control is useful for simple item lists where you want to provide - /// a combobox, checkbox or other control to the user for a certain column. + /// a combo box, checkbox or other control to the user for a certain column. /// It will not perform well for lists with hundreds of items since it /// requires a control to be created per row and management of the embedded /// controls is designed for limited usage. /// /// +#if NET6_0_OR_GREATER + [SupportedOSPlatform("windows")] +#endif public partial class ContainerListView : System.Windows.Forms.ListView { /// Message sent to a control to let it paint itself diff --git a/Source/LateCheckedSynchronizer.cs b/Source/LateCheckedSynchronizer.cs index af371cf..7cf851f 100644 --- a/Source/LateCheckedSynchronizer.cs +++ b/Source/LateCheckedSynchronizer.cs @@ -21,6 +21,10 @@ using System; using System.ComponentModel; using System.Windows.Forms; +#if NET6_0_OR_GREATER +using System.Runtime.Versioning; +#endif + namespace Nuclex.Windows.Forms { /// @@ -41,6 +45,9 @@ namespace Nuclex.Windows.Forms { /// the main window only when something needs to be executed in the UI thread. /// /// +#if NET6_0_OR_GREATER + [SupportedOSPlatform("windows")] +#endif class LateCheckedSynchronizer : ISynchronizeInvoke { /// Initializes a new late-checked main window synchronizer diff --git a/Source/Messages/MessageServiceHelper.cs b/Source/Messages/MessageServiceHelper.cs index aa5fc05..fa0da46 100644 --- a/Source/Messages/MessageServiceHelper.cs +++ b/Source/Messages/MessageServiceHelper.cs @@ -20,9 +20,16 @@ limitations under the License. using System; using System.Windows.Forms; +#if NET6_0_OR_GREATER +using System.Runtime.Versioning; +#endif + namespace Nuclex.Windows.Forms.Messages { /// Contains helper methods for the message service +#if NET6_0_OR_GREATER + [SupportedOSPlatform("windows")] +#endif public static class MessageServiceHelper { /// Asks the user a question that can be answered with yes or no diff --git a/Source/Messages/StandardMessageBoxManager.cs b/Source/Messages/StandardMessageBoxManager.cs index aed0bde..42dfdf0 100644 --- a/Source/Messages/StandardMessageBoxManager.cs +++ b/Source/Messages/StandardMessageBoxManager.cs @@ -20,9 +20,16 @@ limitations under the License. using System; using System.Windows.Forms; +#if NET6_0_OR_GREATER +using System.Runtime.Versioning; +#endif + namespace Nuclex.Windows.Forms.Messages { /// Uses task dialogs to display message boxes +#if NET6_0_OR_GREATER + [SupportedOSPlatform("windows")] +#endif public class StandardMessageBoxManager : IMessageService { #region class MessageScope diff --git a/Source/ViewModels/ThreadedAction.cs b/Source/ViewModels/ThreadedAction.cs index 41f6fce..78c3929 100644 --- a/Source/ViewModels/ThreadedAction.cs +++ b/Source/ViewModels/ThreadedAction.cs @@ -22,6 +22,10 @@ using System.ComponentModel; using System.Threading; using System.Windows.Forms; +#if NET6_0_OR_GREATER +using System.Runtime.Versioning; +#endif + using Nuclex.Support; using Nuclex.Support.Threading; @@ -91,6 +95,9 @@ namespace Nuclex.Windows.Forms.ViewModels { /// Initializes a threaded action that uses its own thread runner public ThreadedAction(ISynchronizeInvoke uiContext = null) : this() { +#if NET6_0_OR_GREATER + if(OperatingSystem.IsWindows()) { +#endif if(uiContext == null) { this.uiContext = LateCheckedSynchronizer.GetMainWindow(); if(this.uiContext == null) { @@ -99,6 +106,9 @@ namespace Nuclex.Windows.Forms.ViewModels { } else { this.uiContext = uiContext; } +#if NET6_0_OR_GREATER + } +#endif this.ownThreadRunner = new ThreadedActionThreadRunner(this); } @@ -113,6 +123,9 @@ namespace Nuclex.Windows.Forms.ViewModels { public ThreadedAction( ThreadedViewModel viewModel, ISynchronizeInvoke uiContext = null ) : this() { +#if NET6_0_OR_GREATER + if(OperatingSystem.IsWindows()) { +#endif if(uiContext == null) { this.uiContext = LateCheckedSynchronizer.GetMainWindow(); if(this.uiContext == null) { @@ -121,6 +134,9 @@ namespace Nuclex.Windows.Forms.ViewModels { } else { this.uiContext = uiContext; } +#if NET6_0_OR_GREATER + } +#endif this.externalThreadRunner = viewModel.ThreadRunner; } diff --git a/Source/ViewModels/ThreadedViewModel.cs b/Source/ViewModels/ThreadedViewModel.cs index 9ed0cbc..8fe454a 100644 --- a/Source/ViewModels/ThreadedViewModel.cs +++ b/Source/ViewModels/ThreadedViewModel.cs @@ -62,6 +62,9 @@ namespace Nuclex.Windows.Forms.ViewModels { /// UI dispatcher that can be used to run callbacks in the UI thread /// protected ThreadedViewModel(ISynchronizeInvoke uiContext = null) { +#if NET6_0_OR_GREATER + if(OperatingSystem.IsWindows()) { +#endif if(uiContext == null) { this.uiContext = LateCheckedSynchronizer.GetMainWindow(); if(this.uiContext == null) { @@ -70,6 +73,9 @@ namespace Nuclex.Windows.Forms.ViewModels { } else { this.uiContext = uiContext; } +#if NET6_0_OR_GREATER + } +#endif this.reportErrorDelegate = new Action(ReportError); diff --git a/Source/Views/MultiPageViewForm.cs b/Source/Views/MultiPageViewForm.cs index 364192f..4c3a034 100644 --- a/Source/Views/MultiPageViewForm.cs +++ b/Source/Views/MultiPageViewForm.cs @@ -25,12 +25,19 @@ using System.Reflection; using System.Runtime.InteropServices; using System.Windows.Forms; +#if NET6_0_OR_GREATER +using System.Runtime.Versioning; +#endif + using Nuclex.Support; using Nuclex.Windows.Forms.ViewModels; namespace Nuclex.Windows.Forms.Views { /// Special view form that can display different child views +#if NET6_0_OR_GREATER + [SupportedOSPlatform("windows")] +#endif public class MultiPageViewForm : ViewForm { #region struct RedrawLockScope diff --git a/Source/Views/ViewControl.cs b/Source/Views/ViewControl.cs index c31ea60..b5b72aa 100644 --- a/Source/Views/ViewControl.cs +++ b/Source/Views/ViewControl.cs @@ -56,7 +56,7 @@ namespace Nuclex.Windows.Forms.Views { /// Refreshes all properties from the view model protected void InvalidateAllViewModelProperties() { - OnViewModelPropertyChanged(this.dataContext, PropertyChangedEventArgsHelper.Wildcard); + OnViewModelPropertyChanged(DataContext, PropertyChangedEventArgsHelper.Wildcard); } /// Called when a property of the view model is changed @@ -66,6 +66,7 @@ namespace Nuclex.Windows.Forms.Views { object sender, PropertyChangedEventArgs arguments ) { } +#if !NET8_0_OR_GREATER /// Provides the data binding target for the view public object DataContext { get { return this.dataContext; } @@ -77,9 +78,12 @@ namespace Nuclex.Windows.Forms.Views { } } } +#endif +#if !NET8_0_OR_GREATER /// Active data binding target, can be null private object dataContext; +#endif /// Delegate for the OnViewModelPropertyChanged() method private PropertyChangedEventHandler onViewModelPropertyChangedDelegate; diff --git a/Source/Views/ViewForm.cs b/Source/Views/ViewForm.cs index 625b218..db8d242 100644 --- a/Source/Views/ViewForm.cs +++ b/Source/Views/ViewForm.cs @@ -21,6 +21,10 @@ using System; using System.ComponentModel; using System.Windows.Forms; +#if NET6_0_OR_GREATER +using System.Runtime.Versioning; +#endif + using Nuclex.Support; namespace Nuclex.Windows.Forms.Views { @@ -28,6 +32,9 @@ namespace Nuclex.Windows.Forms.Views { /// /// Base class for MVVM windows that act as views connected to a view model /// +#if NET6_0_OR_GREATER + [SupportedOSPlatform("windows")] +#endif public class ViewForm : Form, IView { /// Initializes a new view control @@ -35,6 +42,7 @@ namespace Nuclex.Windows.Forms.Views { this.onViewModelPropertyChangedDelegate = OnViewModelPropertyChanged; } +#if !NET8_0_OR_GREATER /// Provides the data binding target for the view public object DataContext { get { return this.dataContext; } @@ -46,6 +54,7 @@ namespace Nuclex.Windows.Forms.Views { } } } +#endif /// Called when the window's data context is changed /// Window whose data context was changed @@ -68,7 +77,7 @@ namespace Nuclex.Windows.Forms.Views { /// Refreshes all properties from the view model protected void InvalidateAllViewModelProperties() { - OnViewModelPropertyChanged(this.dataContext, PropertyChangedEventArgsHelper.Wildcard); + OnViewModelPropertyChanged(DataContext, PropertyChangedEventArgsHelper.Wildcard); } /// Called when a property of the view model is changed @@ -78,8 +87,10 @@ namespace Nuclex.Windows.Forms.Views { object sender, PropertyChangedEventArgs arguments ) { } +#if !NET8_0_OR_GREATER /// Active data binding target, can be null private object dataContext; +#endif /// Delegate for the OnViewModelPropertyChanged() method private PropertyChangedEventHandler onViewModelPropertyChangedDelegate; diff --git a/Source/WindowManager.cs b/Source/WindowManager.cs index f944052..d73d0ff 100644 --- a/Source/WindowManager.cs +++ b/Source/WindowManager.cs @@ -22,6 +22,10 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Windows.Forms; +#if NET6_0_OR_GREATER +using System.Runtime.Versioning; +#endif + using Nuclex.Support; using Nuclex.Windows.Forms.AutoBinding; using Nuclex.Windows.Forms.Views; @@ -29,6 +33,9 @@ using Nuclex.Windows.Forms.Views; namespace Nuclex.Windows.Forms { /// Manages an application's windows and views +#if NET6_0_OR_GREATER + [SupportedOSPlatform("windows")] +#endif public class WindowManager : Observable, IWindowManager { #region class CancellableDisposer diff --git a/Tests/Messages/MessageEventArgsTest.cs b/Tests/Messages/MessageEventArgsTest.cs index f25895d..6d08f0e 100644 --- a/Tests/Messages/MessageEventArgsTest.cs +++ b/Tests/Messages/MessageEventArgsTest.cs @@ -20,12 +20,19 @@ limitations under the License. using System; using System.Windows.Forms; +#if NET6_0_OR_GREATER +using System.Runtime.Versioning; +#endif + using NUnit.Framework; namespace Nuclex.Windows.Forms.Messages { /// Unit tests for the message box event argument container [TestFixture] +#if NET6_0_OR_GREATER + [SupportedOSPlatform("windows")] +#endif internal class MessageEventArgsTest { /// Verifies that the image associated with the message gets stored diff --git a/Tests/WindowManagerTest.cs b/Tests/WindowManagerTest.cs index d710fbc..c9d3d1b 100644 --- a/Tests/WindowManagerTest.cs +++ b/Tests/WindowManagerTest.cs @@ -19,12 +19,19 @@ limitations under the License. using System; +#if NET6_0_OR_GREATER +using System.Runtime.Versioning; +#endif + using NUnit.Framework; namespace Nuclex.Windows.Forms { /// Unit test for the window manager [TestFixture] +#if NET6_0_OR_GREATER + [SupportedOSPlatform("windows")] +#endif public class WindowManagerTest { /// Verifies that the window manager provides a default constructor