Skip to content

Upgrade to .NET 9 - #133

Merged
luttje merged 40 commits into
mainfrom
93-upgrade-to-dot-net-9
Mar 28, 2026
Merged

luttje merged 40 commits into
mainfrom
93-upgrade-to-dot-net-9

Conversation

@luttje

@luttje luttje commented Mar 24, 2026 •

Copy link
Copy Markdown
Collaborator

Will fix #93

I upgraded this using the Microsoft recommended way: using the 'Modernize .NET' agent, which produced most of the commits included.

TODO:

  • Await for this PR with SimWinInput to be merged, so we can get this package from NuGet instead of including it locally
  • Go through the changes and see if the agent did anything weird

luttje added 30 commits March 24, 2026 21:09
Changed the target framework from NET48 to net9.0-windows in Key2Joy.Contracts.csproj. Also updated the System.Text.Json package reference to a more concise format and made minor property formatting adjustments.
Downgraded System.Text.Json package from version 10.0.5 to 9.0.14 and removed multiple assembly references, including PresentationCore, PresentationFramework, System.Windows.Forms, and others, from the project file.
… 'System.Diagnostics.TraceEventType.Information.ToString()' as 'EventLogEntryType' does not exist, but 'TraceEventType.Information' is available in the referenced assembly. This preserves the intent of logging an informational entry.' in file 'Core\Key2Joy.Contracts\Output.cs'
…ics.EventLog package, fixed EventLog.WriteEntry call to use EventLogEntryType.
Changed the target framework from NET48 to net9.0-windows in Key2Joy.Core.csproj. Consolidated and reformatted package references into a single ItemGroup using the new syntax. Minor property cleanups were made, such as updating the AssemblyOriginatorKeyFile property. No changes to dependencies themselves; only project structure and framework target were updated.
Removed several unused or redundant package references, including Microsoft.NETCore.Platforms, NETStandard.Library, and various System.* packages. Downgraded SimWinGamePad from version 1.1.1 to 1.0.0 and added System.Configuration.ConfigurationManager version 10.0.5. Also removed references to PresentationCore, PresentationFramework, and other related assemblies, streamlining the project file.
…rms.MessageBox, as System.Windows.MessageBox does not exist and the correct type is in System.Windows.Forms.

Line 37: Replaced System.Windows.MessageBox with System.Windows.Forms.MessageBox for the same reason as above.
Line 6: Added using directive for System.Windows.Forms to clarify the namespace for MessageBox.' in file 'Core\Key2Joy.Core\Mapping\Actions\Logic\MessageBoxAction.cs'
…#, extension methods are defined as static methods in static classes with 'this' as the first parameter. This line is not valid C# syntax and causes the CS1513 error.' in file 'Core\Key2Joy.Core\Extensions\ScpBusExtensions.cs'
…s declaration at line 9 already opens the class body, so this brace is not needed and causes a mismatched brace error (CS1513).' in file 'Core\Key2Joy.Core\Extensions\ScpBusExtensions.cs'
…le, which was causing the CS1022 error. The file already has the correct closing brace for the class at line 31.' in file 'Core\Key2Joy.Core\Extensions\ScpBusExtensions.cs'
Changed the target framework in Key2Joy.Cmd.csproj from NET48 to net9.0-windows and set the language version to latest within the main PropertyGroup. Moved package references for CommandLineParser and System.Resources.Extensions into the main ItemGroup and removed the redundant ItemGroup. No changes were made to project dependencies or functionality.
Upgraded System.Resources.Extensions package from version 7.0.0 to 9.0.14. Removed the explicit reference to System.Windows.Forms. No other significant changes were made to the project file.
Changed target framework from NET48 to net9.0-windows and cleaned up property groups. Moved package references to a simplified format and removed redundant ItemGroup entries. No changes to application logic or dependencies, only project file structure and framework update.
Removed multiple unused or redundant package and assembly references from Key2Joy.Gui.csproj. Upgraded System.Management to version 9.0.14 and replaced ObjectListView.Official with ObjectListView.Repack.Core3 (v2.9.3). Cleaned up legacy .NET and system references to streamline dependencies.
Added comments in MainForm.cs noting that MenuItem and ContextMenu are no longer supported in newer WinForms versions, with suggestions to use ToolStripMenuItem and ContextMenuStrip instead. Provided links to Microsoft documentation for further details. No functional code changes were made.
…ed name 'Key2Joy.Util.TypeExtensions' to resolve the CS0104 error.

Line 104: Disambiguate 'TypeExtensions' by using the fully qualified name 'Key2Joy.Util.TypeExtensions' to resolve the CS0104 error.
Line 107: Disambiguate 'TypeExtensions' by using the fully qualified name 'Key2Joy.Util.TypeExtensions' to resolve the CS0104 error.
Line 118: Disambiguate 'TypeExtensions' by using the fully qualified name 'Key2Joy.Util.TypeExtensions' to resolve the CS0104 error.
Line 119: Disambiguate 'TypeExtensions' by using the fully qualified name 'Key2Joy.Util.TypeExtensions' to resolve the CS0104 error.
Line 122: Disambiguate 'TypeExtensions' by using the fully qualified name 'Key2Joy.Util.TypeExtensions' to resolve the CS0104 error.' in file 'Key2Joy.Gui\MappingPropertyEditorForm.cs'
…olStripMenuItem/ContextMenuStrip as required by .NET 9.0+ WinForms. Used fully qualified names to ensure correct type usage.' in file 'Key2Joy.Gui\MainForm.cs'
…riverInstalled' of 'ScpBus', as 'IsDriverInstalled' does not exist. This follows the typical pattern for such checks and resolves CS0117.' in file 'Key2Joy.Gui\Program.cs'
…ty or method named 'DriverInstalled' or 'IsDriverInstalled'. The original check must be replaced with a real implementation if available. For now, a placeholder 'if (true)' is used to allow compilation, but you should implement a proper driver check if possible.' in file 'Key2Joy.Gui\Program.cs'
Changed the target framework in BuildMarkdownDocs.csproj from NET48 to net9.0, consolidating property groups and ensuring the language version remains set to 'latest'. Other project properties remain unchanged.
Changed the TargetFramework in BuildMarkdownDocs.csproj from net9.0 to net9.0-windows7.0 to specify compatibility with Windows 7. No other project settings were modified.
Changed the target framework from NET48 to net9.0-windows in Key2Joy.Tests.csproj. Consolidated and updated the placement of test-related package references (coverlet.msbuild, Microsoft.NET.Test.Sdk, Moq, MSTest.TestAdapter, MSTest.TestFramework) into a single ItemGroup. Retained other project settings and references.
The System.Windows.Forms assembly reference was removed from the Key2Joy.Tests.csproj file. No other changes were made to the project configuration.
Changed the target framework from NET48 to net9.0-windows and updated the project file structure. Consolidated package references into a single ItemGroup and ensured all necessary dependencies are included. Cleaned up redundant PropertyGroup and ItemGroup sections for improved maintainability.
Removed System.IO.Compression and System.IO.Compression.ZipFile package references, and downgraded System.Text.Json from version 10.0.5 to 9.0.14 in Key2Joy.Setup.csproj. Also removed the explicit reference to System.Windows.Forms.
…se the namespace does not exist in the current project dependencies or framework. The MessageBox usage will need to be replaced with an alternative error reporting mechanism compatible with net9.0-windows, but this change only addresses the invalid using directive as per the error CS0234.' in file 'Support\Key2Joy.Setup\Cmd\InstallOptions.cs'
…o resolve MessageBox, MessageBoxButtons, and MessageBoxIcon.' in file 'Support\Key2Joy.Setup\Cmd\InstallOptions.cs'
luttje added 9 commits March 24, 2026 21:52
… reporting, as MessageBox is not available in the current framework and dependencies.

Line 5: Replaced the unavailable 'System.Windows.Forms' namespace with 'System', as MessageBox is not available and Console can be used for output in a command-line context.' in file 'Support\Key2Joy.Setup\Cmd\InstallOptions.cs'
…se the namespace does not exist in the current project dependencies. The MessageBox and related types are not available, so this using is invalid.' in file 'Support\Key2Joy.Setup\Cmd\UninstallOptions.cs'
…o resolve MessageBox, MessageBoxButtons, and MessageBoxIcon types.' in file 'Support\Key2Joy.Setup\Cmd\UninstallOptions.cs'
…on.ConfigurationManager package to resolve System.Windows.Forms and ApplicationSettingsBase errors.
@luttje luttje self-assigned this Mar 24, 2026
@abart27

abart27 commented Mar 25, 2026

Copy link
Copy Markdown
Collaborator

I haven't tested this comprehensively, but it seems to work very well!

I'll review the code changes later as well. For now I have two things to add:

Await for DavidRieman/SimWinInput#7 to be merged, so we can get this package from NuGet instead of including it locally

The maintainer isn't all too active, so I doubt we'd get this through in a reasonable amount of time. It's fine to merge this PR while still consuming the local version imo.

Improve dark-mode (#125)

It's probably better to make this a separate PR. We get a saner history.

@luttje
luttje force-pushed the 93-upgrade-to-dot-net-9 branch from 8b33663 to 3653bec Compare March 25, 2026 21:40
@luttje

luttje commented Mar 25, 2026 •

Copy link
Copy Markdown
Collaborator Author

Alright good call, I removed those two commits related to dark-mode and will push them to a new PR. I'm guessing we'll rebase that history then when it comes to it.

@luttje
luttje marked this pull request as ready for review March 25, 2026 21:42
@luttje
luttje requested a review from abart27 March 25, 2026 21:42
@luttje luttje mentioned this pull request Mar 25, 2026
1 task done

@abart27 abart27 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great 😀

@luttje
luttje merged commit 78ca440 into main Mar 28, 2026
2 checks passed
@luttje
luttje deleted the 93-upgrade-to-dot-net-9 branch March 28, 2026 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Upgrade to .NET 9

2 participants