Upgraded project to .NET 8.0 because .NET 6.0 is out of support

This commit is contained in:
cygon 2025-06-19 10:43:58 +02:00
parent a1e8b42706
commit 563d45f9f2
16 changed files with 113 additions and 6 deletions

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net462;net6.0-windows</TargetFrameworks> <TargetFrameworks>net462;net8.0-windows</TargetFrameworks>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression> <PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>True</GenerateDocumentationFile> <GenerateDocumentationFile>True</GenerateDocumentationFile>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net462;net6.0-windows</TargetFrameworks> <TargetFrameworks>net462;net8.0-windows</TargetFrameworks>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression> <PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo> <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>True</GenerateDocumentationFile> <GenerateDocumentationFile>True</GenerateDocumentationFile>
@ -26,7 +26,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="Nuclex.Windows.Forms (net-4.6)(net-6.0).csproj" /> <ProjectReference Include="Nuclex.Windows.Forms (net-4.6)(net-8.0).csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -21,6 +21,10 @@ using System;
using System.Threading; using System.Threading;
using System.Windows.Forms; using System.Windows.Forms;
#if NET6_0_OR_GREATER
using System.Runtime.Versioning;
#endif
namespace Nuclex.Windows.Forms { namespace Nuclex.Windows.Forms {
/// <summary>Progress bar with optimized multi-threading behavior</summary> /// <summary>Progress bar with optimized multi-threading behavior</summary>
@ -37,6 +41,9 @@ namespace Nuclex.Windows.Forms {
/// worker thread, increasing its performance. /// worker thread, increasing its performance.
/// </para> /// </para>
/// </remarks> /// </remarks>
#if NET6_0_OR_GREATER
[SupportedOSPlatform("windows")]
#endif
public partial class AsyncProgressBar : ProgressBar { public partial class AsyncProgressBar : ProgressBar {
/// <summary>Initializes a new asynchronous progress bar</summary> /// <summary>Initializes a new asynchronous progress bar</summary>

View File

@ -21,9 +21,16 @@ using System;
using System.Text; using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
#if NET6_0_OR_GREATER
using System.Runtime.Versioning;
#endif
namespace Nuclex.Windows.Forms.CommonDialogs { namespace Nuclex.Windows.Forms.CommonDialogs {
/// <summary>Displays common dialogs for selecting files and directories</summary> /// <summary>Displays common dialogs for selecting files and directories</summary>
#if NET6_0_OR_GREATER
[SupportedOSPlatform("windows")]
#endif
public class CommonDialogManager : ICommonDialogService { public class CommonDialogManager : ICommonDialogService {
/// <summary>Initializes a new task dialog message service</summary> /// <summary>Initializes a new task dialog message service</summary>

View File

@ -26,6 +26,10 @@ using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
#if NET6_0_OR_GREATER
using System.Runtime.Versioning;
#endif
using Nuclex.Support.Collections; using Nuclex.Support.Collections;
namespace Nuclex.Windows.Forms { namespace Nuclex.Windows.Forms {
@ -44,12 +48,15 @@ namespace Nuclex.Windows.Forms {
/// </para> /// </para>
/// <para> /// <para>
/// This control is useful for simple item lists where you want to provide /// 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 /// 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 /// requires a control to be created per row and management of the embedded
/// controls is designed for limited usage. /// controls is designed for limited usage.
/// </para> /// </para>
/// </remarks> /// </remarks>
#if NET6_0_OR_GREATER
[SupportedOSPlatform("windows")]
#endif
public partial class ContainerListView : System.Windows.Forms.ListView { public partial class ContainerListView : System.Windows.Forms.ListView {
/// <summary>Message sent to a control to let it paint itself</summary> /// <summary>Message sent to a control to let it paint itself</summary>

View File

@ -21,6 +21,10 @@ using System;
using System.ComponentModel; using System.ComponentModel;
using System.Windows.Forms; using System.Windows.Forms;
#if NET6_0_OR_GREATER
using System.Runtime.Versioning;
#endif
namespace Nuclex.Windows.Forms { namespace Nuclex.Windows.Forms {
/// <summary> /// <summary>
@ -41,6 +45,9 @@ namespace Nuclex.Windows.Forms {
/// the main window only when something needs to be executed in the UI thread. /// the main window only when something needs to be executed in the UI thread.
/// </para> /// </para>
/// </remarks> /// </remarks>
#if NET6_0_OR_GREATER
[SupportedOSPlatform("windows")]
#endif
class LateCheckedSynchronizer : ISynchronizeInvoke { class LateCheckedSynchronizer : ISynchronizeInvoke {
/// <summary>Initializes a new late-checked main window synchronizer</summary> /// <summary>Initializes a new late-checked main window synchronizer</summary>

View File

@ -20,9 +20,16 @@ limitations under the License.
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
#if NET6_0_OR_GREATER
using System.Runtime.Versioning;
#endif
namespace Nuclex.Windows.Forms.Messages { namespace Nuclex.Windows.Forms.Messages {
/// <summary>Contains helper methods for the message service</summary> /// <summary>Contains helper methods for the message service</summary>
#if NET6_0_OR_GREATER
[SupportedOSPlatform("windows")]
#endif
public static class MessageServiceHelper { public static class MessageServiceHelper {
/// <summary>Asks the user a question that can be answered with yes or no</summary> /// <summary>Asks the user a question that can be answered with yes or no</summary>

View File

@ -20,9 +20,16 @@ limitations under the License.
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
#if NET6_0_OR_GREATER
using System.Runtime.Versioning;
#endif
namespace Nuclex.Windows.Forms.Messages { namespace Nuclex.Windows.Forms.Messages {
/// <summary>Uses task dialogs to display message boxes</summary> /// <summary>Uses task dialogs to display message boxes</summary>
#if NET6_0_OR_GREATER
[SupportedOSPlatform("windows")]
#endif
public class StandardMessageBoxManager : IMessageService { public class StandardMessageBoxManager : IMessageService {
#region class MessageScope #region class MessageScope

View File

@ -22,6 +22,10 @@ using System.ComponentModel;
using System.Threading; using System.Threading;
using System.Windows.Forms; using System.Windows.Forms;
#if NET6_0_OR_GREATER
using System.Runtime.Versioning;
#endif
using Nuclex.Support; using Nuclex.Support;
using Nuclex.Support.Threading; using Nuclex.Support.Threading;
@ -91,6 +95,9 @@ namespace Nuclex.Windows.Forms.ViewModels {
/// <summary>Initializes a threaded action that uses its own thread runner</summary> /// <summary>Initializes a threaded action that uses its own thread runner</summary>
public ThreadedAction(ISynchronizeInvoke uiContext = null) : this() { public ThreadedAction(ISynchronizeInvoke uiContext = null) : this() {
#if NET6_0_OR_GREATER
if(OperatingSystem.IsWindows()) {
#endif
if(uiContext == null) { if(uiContext == null) {
this.uiContext = LateCheckedSynchronizer.GetMainWindow(); this.uiContext = LateCheckedSynchronizer.GetMainWindow();
if(this.uiContext == null) { if(this.uiContext == null) {
@ -99,6 +106,9 @@ namespace Nuclex.Windows.Forms.ViewModels {
} else { } else {
this.uiContext = uiContext; this.uiContext = uiContext;
} }
#if NET6_0_OR_GREATER
}
#endif
this.ownThreadRunner = new ThreadedActionThreadRunner(this); this.ownThreadRunner = new ThreadedActionThreadRunner(this);
} }
@ -113,6 +123,9 @@ namespace Nuclex.Windows.Forms.ViewModels {
public ThreadedAction( public ThreadedAction(
ThreadedViewModel viewModel, ISynchronizeInvoke uiContext = null ThreadedViewModel viewModel, ISynchronizeInvoke uiContext = null
) : this() { ) : this() {
#if NET6_0_OR_GREATER
if(OperatingSystem.IsWindows()) {
#endif
if(uiContext == null) { if(uiContext == null) {
this.uiContext = LateCheckedSynchronizer.GetMainWindow(); this.uiContext = LateCheckedSynchronizer.GetMainWindow();
if(this.uiContext == null) { if(this.uiContext == null) {
@ -121,6 +134,9 @@ namespace Nuclex.Windows.Forms.ViewModels {
} else { } else {
this.uiContext = uiContext; this.uiContext = uiContext;
} }
#if NET6_0_OR_GREATER
}
#endif
this.externalThreadRunner = viewModel.ThreadRunner; this.externalThreadRunner = viewModel.ThreadRunner;
} }

View File

@ -62,6 +62,9 @@ namespace Nuclex.Windows.Forms.ViewModels {
/// UI dispatcher that can be used to run callbacks in the UI thread /// UI dispatcher that can be used to run callbacks in the UI thread
/// </param> /// </param>
protected ThreadedViewModel(ISynchronizeInvoke uiContext = null) { protected ThreadedViewModel(ISynchronizeInvoke uiContext = null) {
#if NET6_0_OR_GREATER
if(OperatingSystem.IsWindows()) {
#endif
if(uiContext == null) { if(uiContext == null) {
this.uiContext = LateCheckedSynchronizer.GetMainWindow(); this.uiContext = LateCheckedSynchronizer.GetMainWindow();
if(this.uiContext == null) { if(this.uiContext == null) {
@ -70,6 +73,9 @@ namespace Nuclex.Windows.Forms.ViewModels {
} else { } else {
this.uiContext = uiContext; this.uiContext = uiContext;
} }
#if NET6_0_OR_GREATER
}
#endif
this.reportErrorDelegate = new Action<Exception>(ReportError); this.reportErrorDelegate = new Action<Exception>(ReportError);

View File

@ -25,12 +25,19 @@ using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Windows.Forms; using System.Windows.Forms;
#if NET6_0_OR_GREATER
using System.Runtime.Versioning;
#endif
using Nuclex.Support; using Nuclex.Support;
using Nuclex.Windows.Forms.ViewModels; using Nuclex.Windows.Forms.ViewModels;
namespace Nuclex.Windows.Forms.Views { namespace Nuclex.Windows.Forms.Views {
/// <summary>Special view form that can display different child views</summary> /// <summary>Special view form that can display different child views</summary>
#if NET6_0_OR_GREATER
[SupportedOSPlatform("windows")]
#endif
public class MultiPageViewForm : ViewForm { public class MultiPageViewForm : ViewForm {
#region struct RedrawLockScope #region struct RedrawLockScope

View File

@ -56,7 +56,7 @@ namespace Nuclex.Windows.Forms.Views {
/// <summary>Refreshes all properties from the view model</summary> /// <summary>Refreshes all properties from the view model</summary>
protected void InvalidateAllViewModelProperties() { protected void InvalidateAllViewModelProperties() {
OnViewModelPropertyChanged(this.dataContext, PropertyChangedEventArgsHelper.Wildcard); OnViewModelPropertyChanged(DataContext, PropertyChangedEventArgsHelper.Wildcard);
} }
/// <summary>Called when a property of the view model is changed</summary> /// <summary>Called when a property of the view model is changed</summary>
@ -66,6 +66,7 @@ namespace Nuclex.Windows.Forms.Views {
object sender, PropertyChangedEventArgs arguments object sender, PropertyChangedEventArgs arguments
) { } ) { }
#if !NET8_0_OR_GREATER
/// <summary>Provides the data binding target for the view</summary> /// <summary>Provides the data binding target for the view</summary>
public object DataContext { public object DataContext {
get { return this.dataContext; } get { return this.dataContext; }
@ -77,9 +78,12 @@ namespace Nuclex.Windows.Forms.Views {
} }
} }
} }
#endif
#if !NET8_0_OR_GREATER
/// <summary>Active data binding target, can be null</summary> /// <summary>Active data binding target, can be null</summary>
private object dataContext; private object dataContext;
#endif
/// <summary>Delegate for the OnViewModelPropertyChanged() method</summary> /// <summary>Delegate for the OnViewModelPropertyChanged() method</summary>
private PropertyChangedEventHandler onViewModelPropertyChangedDelegate; private PropertyChangedEventHandler onViewModelPropertyChangedDelegate;

View File

@ -21,6 +21,10 @@ using System;
using System.ComponentModel; using System.ComponentModel;
using System.Windows.Forms; using System.Windows.Forms;
#if NET6_0_OR_GREATER
using System.Runtime.Versioning;
#endif
using Nuclex.Support; using Nuclex.Support;
namespace Nuclex.Windows.Forms.Views { namespace Nuclex.Windows.Forms.Views {
@ -28,6 +32,9 @@ namespace Nuclex.Windows.Forms.Views {
/// <summary> /// <summary>
/// Base class for MVVM windows that act as views connected to a view model /// Base class for MVVM windows that act as views connected to a view model
/// </summary> /// </summary>
#if NET6_0_OR_GREATER
[SupportedOSPlatform("windows")]
#endif
public class ViewForm : Form, IView { public class ViewForm : Form, IView {
/// <summary>Initializes a new view control</summary> /// <summary>Initializes a new view control</summary>
@ -35,6 +42,7 @@ namespace Nuclex.Windows.Forms.Views {
this.onViewModelPropertyChangedDelegate = OnViewModelPropertyChanged; this.onViewModelPropertyChangedDelegate = OnViewModelPropertyChanged;
} }
#if !NET8_0_OR_GREATER
/// <summary>Provides the data binding target for the view</summary> /// <summary>Provides the data binding target for the view</summary>
public object DataContext { public object DataContext {
get { return this.dataContext; } get { return this.dataContext; }
@ -46,6 +54,7 @@ namespace Nuclex.Windows.Forms.Views {
} }
} }
} }
#endif
/// <summary>Called when the window's data context is changed</summary> /// <summary>Called when the window's data context is changed</summary>
/// <param name="sender">Window whose data context was changed</param> /// <param name="sender">Window whose data context was changed</param>
@ -68,7 +77,7 @@ namespace Nuclex.Windows.Forms.Views {
/// <summary>Refreshes all properties from the view model</summary> /// <summary>Refreshes all properties from the view model</summary>
protected void InvalidateAllViewModelProperties() { protected void InvalidateAllViewModelProperties() {
OnViewModelPropertyChanged(this.dataContext, PropertyChangedEventArgsHelper.Wildcard); OnViewModelPropertyChanged(DataContext, PropertyChangedEventArgsHelper.Wildcard);
} }
/// <summary>Called when a property of the view model is changed</summary> /// <summary>Called when a property of the view model is changed</summary>
@ -78,8 +87,10 @@ namespace Nuclex.Windows.Forms.Views {
object sender, PropertyChangedEventArgs arguments object sender, PropertyChangedEventArgs arguments
) { } ) { }
#if !NET8_0_OR_GREATER
/// <summary>Active data binding target, can be null</summary> /// <summary>Active data binding target, can be null</summary>
private object dataContext; private object dataContext;
#endif
/// <summary>Delegate for the OnViewModelPropertyChanged() method</summary> /// <summary>Delegate for the OnViewModelPropertyChanged() method</summary>
private PropertyChangedEventHandler onViewModelPropertyChangedDelegate; private PropertyChangedEventHandler onViewModelPropertyChangedDelegate;

View File

@ -22,6 +22,10 @@ using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Windows.Forms; using System.Windows.Forms;
#if NET6_0_OR_GREATER
using System.Runtime.Versioning;
#endif
using Nuclex.Support; using Nuclex.Support;
using Nuclex.Windows.Forms.AutoBinding; using Nuclex.Windows.Forms.AutoBinding;
using Nuclex.Windows.Forms.Views; using Nuclex.Windows.Forms.Views;
@ -29,6 +33,9 @@ using Nuclex.Windows.Forms.Views;
namespace Nuclex.Windows.Forms { namespace Nuclex.Windows.Forms {
/// <summary>Manages an application's windows and views</summary> /// <summary>Manages an application's windows and views</summary>
#if NET6_0_OR_GREATER
[SupportedOSPlatform("windows")]
#endif
public class WindowManager : Observable, IWindowManager { public class WindowManager : Observable, IWindowManager {
#region class CancellableDisposer #region class CancellableDisposer

View File

@ -20,12 +20,19 @@ limitations under the License.
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
#if NET6_0_OR_GREATER
using System.Runtime.Versioning;
#endif
using NUnit.Framework; using NUnit.Framework;
namespace Nuclex.Windows.Forms.Messages { namespace Nuclex.Windows.Forms.Messages {
/// <summary>Unit tests for the message box event argument container</summary> /// <summary>Unit tests for the message box event argument container</summary>
[TestFixture] [TestFixture]
#if NET6_0_OR_GREATER
[SupportedOSPlatform("windows")]
#endif
internal class MessageEventArgsTest { internal class MessageEventArgsTest {
/// <summary>Verifies that the image associated with the message gets stored</summary> /// <summary>Verifies that the image associated with the message gets stored</summary>

View File

@ -19,12 +19,19 @@ limitations under the License.
using System; using System;
#if NET6_0_OR_GREATER
using System.Runtime.Versioning;
#endif
using NUnit.Framework; using NUnit.Framework;
namespace Nuclex.Windows.Forms { namespace Nuclex.Windows.Forms {
/// <summary>Unit test for the window manager</summary> /// <summary>Unit test for the window manager</summary>
[TestFixture] [TestFixture]
#if NET6_0_OR_GREATER
[SupportedOSPlatform("windows")]
#endif
public class WindowManagerTest { public class WindowManagerTest {
/// <summary>Verifies that the window manager provides a default constructor</summary> /// <summary>Verifies that the window manager provides a default constructor</summary>