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">
<PropertyGroup>
<TargetFrameworks>net462;net6.0-windows</TargetFrameworks>
<TargetFrameworks>net462;net8.0-windows</TargetFrameworks>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>True</GenerateDocumentationFile>

View File

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

View File

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

View File

@ -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 {
/// <summary>Displays common dialogs for selecting files and directories</summary>
#if NET6_0_OR_GREATER
[SupportedOSPlatform("windows")]
#endif
public class CommonDialogManager : ICommonDialogService {
/// <summary>Initializes a new task dialog message service</summary>

View File

@ -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 {
@ -50,6 +54,9 @@ namespace Nuclex.Windows.Forms {
/// controls is designed for limited usage.
/// </para>
/// </remarks>
#if NET6_0_OR_GREATER
[SupportedOSPlatform("windows")]
#endif
public partial class ContainerListView : System.Windows.Forms.ListView {
/// <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.Windows.Forms;
#if NET6_0_OR_GREATER
using System.Runtime.Versioning;
#endif
namespace Nuclex.Windows.Forms {
/// <summary>
@ -41,6 +45,9 @@ namespace Nuclex.Windows.Forms {
/// the main window only when something needs to be executed in the UI thread.
/// </para>
/// </remarks>
#if NET6_0_OR_GREATER
[SupportedOSPlatform("windows")]
#endif
class LateCheckedSynchronizer : ISynchronizeInvoke {
/// <summary>Initializes a new late-checked main window synchronizer</summary>

View File

@ -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 {
/// <summary>Contains helper methods for the message service</summary>
#if NET6_0_OR_GREATER
[SupportedOSPlatform("windows")]
#endif
public static class MessageServiceHelper {
/// <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.Windows.Forms;
#if NET6_0_OR_GREATER
using System.Runtime.Versioning;
#endif
namespace Nuclex.Windows.Forms.Messages {
/// <summary>Uses task dialogs to display message boxes</summary>
#if NET6_0_OR_GREATER
[SupportedOSPlatform("windows")]
#endif
public class StandardMessageBoxManager : IMessageService {
#region class MessageScope

View File

@ -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 {
/// <summary>Initializes a threaded action that uses its own thread runner</summary>
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;
}

View File

@ -62,6 +62,9 @@ namespace Nuclex.Windows.Forms.ViewModels {
/// UI dispatcher that can be used to run callbacks in the UI thread
/// </param>
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<Exception>(ReportError);

View File

@ -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 {
/// <summary>Special view form that can display different child views</summary>
#if NET6_0_OR_GREATER
[SupportedOSPlatform("windows")]
#endif
public class MultiPageViewForm : ViewForm {
#region struct RedrawLockScope

View File

@ -56,7 +56,7 @@ namespace Nuclex.Windows.Forms.Views {
/// <summary>Refreshes all properties from the view model</summary>
protected void InvalidateAllViewModelProperties() {
OnViewModelPropertyChanged(this.dataContext, PropertyChangedEventArgsHelper.Wildcard);
OnViewModelPropertyChanged(DataContext, PropertyChangedEventArgsHelper.Wildcard);
}
/// <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
) { }
#if !NET8_0_OR_GREATER
/// <summary>Provides the data binding target for the view</summary>
public object 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>
private object dataContext;
#endif
/// <summary>Delegate for the OnViewModelPropertyChanged() method</summary>
private PropertyChangedEventHandler onViewModelPropertyChangedDelegate;

View File

@ -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 {
/// <summary>
/// Base class for MVVM windows that act as views connected to a view model
/// </summary>
#if NET6_0_OR_GREATER
[SupportedOSPlatform("windows")]
#endif
public class ViewForm : Form, IView {
/// <summary>Initializes a new view control</summary>
@ -35,6 +42,7 @@ namespace Nuclex.Windows.Forms.Views {
this.onViewModelPropertyChangedDelegate = OnViewModelPropertyChanged;
}
#if !NET8_0_OR_GREATER
/// <summary>Provides the data binding target for the view</summary>
public object 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>
/// <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>
protected void InvalidateAllViewModelProperties() {
OnViewModelPropertyChanged(this.dataContext, PropertyChangedEventArgsHelper.Wildcard);
OnViewModelPropertyChanged(DataContext, PropertyChangedEventArgsHelper.Wildcard);
}
/// <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
) { }
#if !NET8_0_OR_GREATER
/// <summary>Active data binding target, can be null</summary>
private object dataContext;
#endif
/// <summary>Delegate for the OnViewModelPropertyChanged() method</summary>
private PropertyChangedEventHandler onViewModelPropertyChangedDelegate;

View File

@ -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 {
/// <summary>Manages an application's windows and views</summary>
#if NET6_0_OR_GREATER
[SupportedOSPlatform("windows")]
#endif
public class WindowManager : Observable, IWindowManager {
#region class CancellableDisposer

View File

@ -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 {
/// <summary>Unit tests for the message box event argument container</summary>
[TestFixture]
#if NET6_0_OR_GREATER
[SupportedOSPlatform("windows")]
#endif
internal class MessageEventArgsTest {
/// <summary>Verifies that the image associated with the message gets stored</summary>

View File

@ -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 {
/// <summary>Unit test for the window manager</summary>
[TestFixture]
#if NET6_0_OR_GREATER
[SupportedOSPlatform("windows")]
#endif
public class WindowManagerTest {
/// <summary>Verifies that the window manager provides a default constructor</summary>