diff --git a/AutoUpdate/CKAN-autoupdate.csproj b/AutoUpdate/CKAN-autoupdate.csproj
index c7c7630f9..b0c4aaec2 100644
--- a/AutoUpdate/CKAN-autoupdate.csproj
+++ b/AutoUpdate/CKAN-autoupdate.csproj
@@ -20,8 +20,8 @@
enable
true
..\assets\ckan.ico
- net48;net7.0-windows
- true
+ net48;net8.0-windows
+ true
true
512
prompt
diff --git a/Cmdline/Action/Upgrade.cs b/Cmdline/Action/Upgrade.cs
index 1b3c46466..1fd5b9e65 100644
--- a/Cmdline/Action/Upgrade.cs
+++ b/Cmdline/Action/Upgrade.cs
@@ -8,7 +8,9 @@
using CKAN.Versioning;
using CKAN.Configuration;
+#if !NET8_0_OR_GREATER
using CKAN.Extensions;
+#endif
namespace CKAN.CmdLine
{
diff --git a/Cmdline/CKAN-cmdline.csproj b/Cmdline/CKAN-cmdline.csproj
index 60ba6400d..dbec83401 100644
--- a/Cmdline/CKAN-cmdline.csproj
+++ b/Cmdline/CKAN-cmdline.csproj
@@ -21,7 +21,7 @@
true
CKAN.CmdLine.MainClass
..\assets\ckan.ico
- net48;net7.0;net7.0-windows
+ net48;net8.0;net8.0-windows
$(TargetFramework.Replace("-windows", ""))
512
prompt
@@ -76,7 +76,7 @@
CKAN-ConsoleUI
+ Condition=" '$(TargetFramework)' != 'net8.0' ">
TargetFramework=$(TargetFramework)
{A79F9D54-315C-472B-928F-713A5860B2BE}
CKAN-GUI
diff --git a/ConsoleUI/CKAN-ConsoleUI.csproj b/ConsoleUI/CKAN-ConsoleUI.csproj
index 933422e49..c872c24ab 100644
--- a/ConsoleUI/CKAN-ConsoleUI.csproj
+++ b/ConsoleUI/CKAN-ConsoleUI.csproj
@@ -19,7 +19,7 @@
9
enable
..\assets\ckan.ico
- net48;net7.0
+ net48;net8.0
512
prompt
4
@@ -39,7 +39,7 @@
-
+
diff --git a/Core/CKAN-core.csproj b/Core/CKAN-core.csproj
index d2261a04a..40850bbc4 100644
--- a/Core/CKAN-core.csproj
+++ b/Core/CKAN-core.csproj
@@ -21,7 +21,7 @@
true
SYSLIB0050,IDE0090
IDE1006
- netstandard2.0;net48;net7.0
+ netstandard2.0;net48;net8.0
PrepareResources;$(CompileDependsOn)
diff --git a/Core/Configuration/JsonConfiguration.cs b/Core/Configuration/JsonConfiguration.cs
index 761ee0d51..413c48f42 100644
--- a/Core/Configuration/JsonConfiguration.cs
+++ b/Core/Configuration/JsonConfiguration.cs
@@ -9,7 +9,9 @@
using Newtonsoft.Json;
+#if !NET8_0_OR_GREATER
using CKAN.Extensions;
+#endif
using CKAN.Games.KerbalSpaceProgram;
namespace CKAN.Configuration
diff --git a/Core/Registry/RegistryManager.cs b/Core/Registry/RegistryManager.cs
index e841f4fd0..f6e6a3d7d 100644
--- a/Core/Registry/RegistryManager.cs
+++ b/Core/Registry/RegistryManager.cs
@@ -14,7 +14,9 @@
using Newtonsoft.Json;
using CKAN.Versioning;
+#if !NET8_0_OR_GREATER
using CKAN.Extensions;
+#endif
namespace CKAN
{
diff --git a/GUI/CKAN-GUI.csproj b/GUI/CKAN-GUI.csproj
index ee292ff4b..aed179e0a 100644
--- a/GUI/CKAN-GUI.csproj
+++ b/GUI/CKAN-GUI.csproj
@@ -22,9 +22,9 @@
true
CS0618
IDE1006,NU1701
- net48;net7.0-windows
+ net48;net8.0-windows
$(TargetFramework.Replace("-windows", ""))
- true
+ true
true
512
prompt
@@ -49,7 +49,7 @@
-
+
diff --git a/GUI/Controls/EditModpack.cs b/GUI/Controls/EditModpack.cs
index 0a293359e..7a0a674d5 100644
--- a/GUI/Controls/EditModpack.cs
+++ b/GUI/Controls/EditModpack.cs
@@ -133,25 +133,27 @@ protected override void OnHelpRequested(HelpEventArgs evt)
evt.Handled = Util.TryOpenWebPage(HelpURLs.ModPacks);
}
- private void AddGroup(List relationships, ListViewGroup group, IRegistryQuerier registry)
+ private void AddGroup(List relationships,
+ ListViewGroup group,
+ IRegistryQuerier registry)
{
if (relationships != null)
{
- RelationshipsListView.Items.AddRange(relationships
- .OrderBy(r => (r as ModuleRelationshipDescriptor)?.name)
- .Select(r => new ListViewItem(new string?[]
- {
- (r as ModuleRelationshipDescriptor)?.name,
- (r as ModuleRelationshipDescriptor)?.version?.ToString(),
- registry.InstalledModules.First(
- im => im.identifier == (r as ModuleRelationshipDescriptor)?.name
- )?.Module.@abstract
- })
- {
- Tag = r,
- Group = group,
- })
- .ToArray());
+ RelationshipsListView.Items.AddRange(
+ relationships.OfType()
+ .OrderBy(r => r.name)
+ .Select(r => new ListViewItem(new string[]
+ {
+ r.name,
+ r.version?.ToString() ?? "",
+ registry.InstalledModules.FirstOrDefault(im => im.identifier == r.name)?.Module.@abstract ?? ""
+ })
+ {
+ Tag = r,
+ Group = group,
+ })
+ .OfType()
+ .ToArray());
}
}
@@ -235,6 +237,7 @@ private void RelationshipsListView_ItemSelectionChanged(object? sender, ListView
OnSelectedItemsChanged?.Invoke(RelationshipsListView.SelectedItems);
var kinds = RelationshipsListView.SelectedItems.Cast()
.Select(lvi => lvi.Group)
+ .OfType()
.Distinct()
.ToList();
if (kinds.Count == 1)
@@ -305,12 +308,13 @@ private void IgnoreRadioButton_CheckedChanged(object? sender, EventArgs? e)
private void MoveItemsTo(IEnumerable items, ListViewGroup group, List relationships)
{
- foreach (ListViewItem lvi in items.Where(lvi => lvi.Group != group))
+ foreach (ListViewItem lvi in items)
{
- if (lvi.Tag is RelationshipDescriptor rel)
+ if (lvi.Tag is RelationshipDescriptor rel
+ && lvi.Group is ListViewGroup grp)
{
// UI
- var fromRel = GroupToRelationships[lvi.Group];
+ var fromRel = GroupToRelationships[grp];
fromRel.Remove(rel);
relationships.Add(rel);
// Model
diff --git a/GUI/Controls/HintTextBox.cs b/GUI/Controls/HintTextBox.cs
index cb26f1b2e..887c5856d 100644
--- a/GUI/Controls/HintTextBox.cs
+++ b/GUI/Controls/HintTextBox.cs
@@ -1,6 +1,9 @@
using System;
using System.Drawing;
using System.Windows.Forms;
+#if NET5_0_OR_GREATER
+using System.Runtime.Versioning;
+#endif
namespace CKAN.GUI
{
@@ -8,6 +11,9 @@ namespace CKAN.GUI
/// A textbox which shows a "clear text" icon on the right side
/// whenever data is present.
///
+ #if NET5_0_OR_GREATER
+ [SupportedOSPlatform("windows")]
+ #endif
public partial class HintTextBox : TextBox
{
diff --git a/GUI/Controls/LeftRightRowPanel.cs b/GUI/Controls/LeftRightRowPanel.cs
index 297f24086..11cc969ba 100644
--- a/GUI/Controls/LeftRightRowPanel.cs
+++ b/GUI/Controls/LeftRightRowPanel.cs
@@ -1,5 +1,8 @@
using System.Windows.Forms;
using System.Drawing;
+#if NET5_0_OR_GREATER
+using System.Runtime.Versioning;
+#endif
namespace CKAN.GUI
{
@@ -8,6 +11,9 @@ namespace CKAN.GUI
/// one on the right side and one on the left.
/// Intended to allow autosizing of Buttons.
///
+ #if NET5_0_OR_GREATER
+ [SupportedOSPlatform("windows")]
+ #endif
public class LeftRightRowPanel : TableLayoutPanel
{
///
diff --git a/GUI/Controls/ModInfo.cs b/GUI/Controls/ModInfo.cs
index 2edddb54e..fb5c77bc0 100644
--- a/GUI/Controls/ModInfo.cs
+++ b/GUI/Controls/ModInfo.cs
@@ -73,7 +73,7 @@ protected override void OnResize(EventArgs e)
private void LoadTab(GUIMod gm)
{
- switch (ModInfoTabControl.SelectedTab.Name)
+ switch (ModInfoTabControl.SelectedTab?.Name)
{
case "MetadataTabPage":
Metadata.UpdateModInfo(gm);
diff --git a/GUI/Controls/ThemedTabControl.cs b/GUI/Controls/ThemedTabControl.cs
index 05955fe72..1adfc2a36 100644
--- a/GUI/Controls/ThemedTabControl.cs
+++ b/GUI/Controls/ThemedTabControl.cs
@@ -38,10 +38,11 @@ protected override void OnDrawItem(DrawItemEventArgs e)
var textRect = e.Bounds;
// Image
- var imageIndex = !string.IsNullOrEmpty(tabPage.ImageKey)
- ? ImageList.Images.IndexOfKey(tabPage.ImageKey)
- : tabPage.ImageIndex;
- if (imageIndex > -1)
+ if (ImageList != null
+ && (!string.IsNullOrEmpty(tabPage.ImageKey)
+ ? ImageList.Images.IndexOfKey(tabPage.ImageKey)
+ : tabPage.ImageIndex) is int imageIndex
+ && imageIndex > -1)
{
var image = ImageList.Images[imageIndex];
var offsetY = (e.Bounds.Height - image.Height) / 2;
diff --git a/GUI/Controls/TransparentTextBox.cs b/GUI/Controls/TransparentTextBox.cs
index e85b493b8..f5840393d 100644
--- a/GUI/Controls/TransparentTextBox.cs
+++ b/GUI/Controls/TransparentTextBox.cs
@@ -1,4 +1,7 @@
using System.Windows.Forms;
+#if NET5_0_OR_GREATER
+using System.Runtime.Versioning;
+#endif
namespace CKAN.GUI
{
@@ -9,6 +12,9 @@ namespace CKAN.GUI
/// Multiline is set to true.
/// Used in .
///
+ #if NET5_0_OR_GREATER
+ [SupportedOSPlatform("windows")]
+ #endif
public class TransparentTextBox : TextBox
{
public TransparentTextBox()
diff --git a/GUI/Controls/UnmanagedFiles.cs b/GUI/Controls/UnmanagedFiles.cs
index df76c9a9f..624c918ad 100644
--- a/GUI/Controls/UnmanagedFiles.cs
+++ b/GUI/Controls/UnmanagedFiles.cs
@@ -219,6 +219,9 @@ private void OKButton_Click(object? sender, EventArgs? e)
private static readonly ILog log = LogManager.GetLogger(typeof(UnmanagedFiles));
}
+ #if NET5_0_OR_GREATER
+ [SupportedOSPlatform("windows")]
+ #endif
internal class DirsFirstSorter : IComparer, IComparer
{
public int Compare(object? a, object? b)
diff --git a/GUI/Dialogs/GameCommandLineOptionsDialog.cs b/GUI/Dialogs/GameCommandLineOptionsDialog.cs
index 910894870..364f2bb51 100644
--- a/GUI/Dialogs/GameCommandLineOptionsDialog.cs
+++ b/GUI/Dialogs/GameCommandLineOptionsDialog.cs
@@ -3,9 +3,15 @@
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
+#if NET5_0_OR_GREATER
+using System.Runtime.Versioning;
+#endif
namespace CKAN.GUI
{
+ #if NET5_0_OR_GREATER
+ [SupportedOSPlatform("windows")]
+ #endif
public partial class GameCommandLineOptionsDialog : Form
{
public GameCommandLineOptionsDialog()
diff --git a/GUI/Dialogs/ManageGameInstancesDialog.cs b/GUI/Dialogs/ManageGameInstancesDialog.cs
index 6c2ae6459..6aef91af1 100644
--- a/GUI/Dialogs/ManageGameInstancesDialog.cs
+++ b/GUI/Dialogs/ManageGameInstancesDialog.cs
@@ -202,16 +202,19 @@ private void ImportFromSteamMenuItem_Click(object? sender, EventArgs? e)
private void CloneGameInstanceMenuItem_Click(object? sender, EventArgs? e)
{
- var old_instance = manager.CurrentInstance;
-
- var result = new CloneGameInstanceDialog(manager, user, (string)GameInstancesListView.SelectedItems[0].Tag).ShowDialog(this);
- if (result == DialogResult.OK && !Equals(old_instance, manager.CurrentInstance))
+ if (GameInstancesListView.SelectedItems[0].Tag is string instName)
{
- DialogResult = DialogResult.OK;
- Close();
- }
+ var old_instance = manager.CurrentInstance;
- UpdateInstancesList();
+ var result = new CloneGameInstanceDialog(manager, user, instName).ShowDialog(this);
+ if (result == DialogResult.OK && !Equals(old_instance, manager.CurrentInstance))
+ {
+ DialogResult = DialogResult.OK;
+ Close();
+ }
+
+ UpdateInstancesList();
+ }
}
private void SelectButton_Click(object? sender, EventArgs? e)
@@ -268,15 +271,17 @@ private void SetAsDefaultCheckbox_Click(object? sender, EventArgs? e)
private void GameInstancesListView_SelectedIndexChanged(object? sender, EventArgs? e)
{
- UpdateButtonState();
-
- if (GameInstancesListView.SelectedItems.Count == 0)
+ if (GameInstancesListView.SelectedItems[0].Tag is string instName)
{
- return;
- }
+ UpdateButtonState();
+
+ if (GameInstancesListView.SelectedItems.Count == 0)
+ {
+ return;
+ }
- string instName = (string)GameInstancesListView.SelectedItems[0].Tag;
- SetAsDefaultCheckbox.Checked = manager.AutoStartInstance?.Equals(instName) ?? false;
+ SetAsDefaultCheckbox.Checked = manager.AutoStartInstance?.Equals(instName) ?? false;
+ }
}
private void GameInstancesListView_DoubleClick(object sender, EventArgs r)
@@ -308,31 +313,35 @@ private void GameInstancesListView_KeyDown(object? sender, KeyEventArgs? e)
private void OpenDirectoryMenuItem_Click(object? sender, EventArgs? e)
{
- string path = manager.Instances[(string) GameInstancesListView.SelectedItems[0].Tag].GameDir();
-
- if (!Directory.Exists(path))
+ if (GameInstancesListView.SelectedItems[0].Tag is string instName)
{
- user.RaiseError(Properties.Resources.ManageGameInstancesDirectoryDeleted, path);
- return;
- }
+ string path = manager.Instances[instName].GameDir();
- Utilities.ProcessStartURL(path);
+ if (!Directory.Exists(path))
+ {
+ user.RaiseError(Properties.Resources.ManageGameInstancesDirectoryDeleted, path);
+ return;
+ }
+
+ Utilities.ProcessStartURL(path);
+ }
}
private void RenameButton_Click(object? sender, EventArgs? e)
{
- var instance = (string)GameInstancesListView.SelectedItems[0].Tag;
-
- // show the dialog, and only continue if the user selected "OK"
- var renameInstanceDialog = new RenameInstanceDialog();
- if (renameInstanceDialog.ShowRenameInstanceDialog(instance) != DialogResult.OK)
+ if (GameInstancesListView.SelectedItems[0].Tag is string instName)
{
- return;
- }
+ // show the dialog, and only continue if the user selected "OK"
+ var renameInstanceDialog = new RenameInstanceDialog();
+ if (renameInstanceDialog.ShowRenameInstanceDialog(instName) != DialogResult.OK)
+ {
+ return;
+ }
- // proceed with instance rename
- manager.RenameInstance(instance, renameInstanceDialog.GetResult());
- UpdateInstancesList();
+ // proceed with instance rename
+ manager.RenameInstance(instName, renameInstanceDialog.GetResult());
+ UpdateInstancesList();
+ }
}
private void Forget_Click(object? sender, EventArgs? e)
@@ -349,9 +358,12 @@ private void Forget_Click(object? sender, EventArgs? e)
private void UpdateButtonState()
{
- RenameButton.Enabled = SelectButton.Enabled = SetAsDefaultCheckbox.Enabled = CloneGameInstanceMenuItem.Enabled = HasSelections;
- ForgetButton.Enabled = HasSelections && (string)GameInstancesListView.SelectedItems[0].Tag != manager.CurrentInstance?.Name;
- ImportFromSteamMenuItem.Enabled = manager.SteamLibrary.Games.Length > 0;
+ if (GameInstancesListView.SelectedItems[0].Tag is string instName)
+ {
+ RenameButton.Enabled = SelectButton.Enabled = SetAsDefaultCheckbox.Enabled = CloneGameInstanceMenuItem.Enabled = HasSelections;
+ ForgetButton.Enabled = HasSelections && instName != manager.CurrentInstance?.Name;
+ ImportFromSteamMenuItem.Enabled = manager.SteamLibrary.Games.Length > 0;
+ }
}
private readonly GameInstanceManager manager;
diff --git a/GUI/Dialogs/NewUpdateDialog.cs b/GUI/Dialogs/NewUpdateDialog.cs
index b2b1188e6..f876432a8 100644
--- a/GUI/Dialogs/NewUpdateDialog.cs
+++ b/GUI/Dialogs/NewUpdateDialog.cs
@@ -1,7 +1,13 @@
using System.Windows.Forms;
+#if NET5_0_OR_GREATER
+using System.Runtime.Versioning;
+#endif
namespace CKAN.GUI
{
+ #if NET5_0_OR_GREATER
+ [SupportedOSPlatform("windows")]
+ #endif
public partial class NewUpdateDialog : Form
{
///
diff --git a/GUI/Dialogs/RenameInstanceDialog.cs b/GUI/Dialogs/RenameInstanceDialog.cs
index f8d07bfee..60ee881d5 100644
--- a/GUI/Dialogs/RenameInstanceDialog.cs
+++ b/GUI/Dialogs/RenameInstanceDialog.cs
@@ -1,7 +1,13 @@
using System.Windows.Forms;
+#if NET5_0_OR_GREATER
+using System.Runtime.Versioning;
+#endif
namespace CKAN.GUI
{
+ #if NET5_0_OR_GREATER
+ [SupportedOSPlatform("windows")]
+ #endif
public partial class RenameInstanceDialog : Form
{
public RenameInstanceDialog()
diff --git a/GUI/Dialogs/SettingsDialog.cs b/GUI/Dialogs/SettingsDialog.cs
index cb5bdae30..07f5deeee 100644
--- a/GUI/Dialogs/SettingsDialog.cs
+++ b/GUI/Dialogs/SettingsDialog.cs
@@ -648,7 +648,7 @@ private void LanguageSelectionComboBox_MouseWheel(object sender, MouseEventArgs
private void LanguageSelectionComboBox_SelectionChanged(object? sender, EventArgs? e)
{
- coreConfig.Language = LanguageSelectionComboBox.SelectedItem.ToString();
+ coreConfig.Language = LanguageSelectionComboBox.SelectedItem?.ToString();
}
private void AutoSortUpdateCheckBox_CheckedChanged(object? sender, EventArgs? e)
diff --git a/GUI/FormCompatibility.cs b/GUI/FormCompatibility.cs
index 9afa43a5e..53f7ad9ae 100644
--- a/GUI/FormCompatibility.cs
+++ b/GUI/FormCompatibility.cs
@@ -1,5 +1,8 @@
using System.Drawing;
using System.Windows.Forms;
+#if NET5_0_OR_GREATER
+using System.Runtime.Versioning;
+#endif
namespace CKAN.GUI
{
@@ -7,6 +10,9 @@ namespace CKAN.GUI
/// Inheriting from this class ensures that forms are equally sized on Windows and on Linux/MacOSX
/// Choose the form size so that it is the right one for Windows.
///
+ #if NET5_0_OR_GREATER
+ [SupportedOSPlatform("windows")]
+ #endif
public class FormCompatibility : Form
{
private const int formHeightDifference = 24;
diff --git a/Netkan/CKAN-netkan.csproj b/Netkan/CKAN-netkan.csproj
index 2b7f3acd5..3c0b1b7b7 100644
--- a/Netkan/CKAN-netkan.csproj
+++ b/Netkan/CKAN-netkan.csproj
@@ -21,7 +21,7 @@
true
CKAN.NetKAN.Program
..\assets\ckan.ico
- net48;net7.0
+ net48;net8.0
512
prompt
4
diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj
index 98e4a1210..6b3d06593 100644
--- a/Tests/Tests.csproj
+++ b/Tests/Tests.csproj
@@ -21,9 +21,9 @@
enable
true
IDE1006,NU1701
- net48;net7.0;net7.0-windows
+ net48;net8.0;net8.0-windows
$(TargetFramework.Replace("-windows", ""))
- $(DefaultItemExcludes);AutoUpdate\**;GUI\**
+ $(DefaultItemExcludes);AutoUpdate\**;GUI\**
@@ -68,13 +68,13 @@
CKAN-ConsoleUI
+ Condition=" '$(TargetFramework)' != 'net8.0' ">
TargetFramework=$(TargetFramework)
{A79F9D54-315C-472B-928F-713A5860B2BE}
CKAN-GUI
+ Condition=" '$(TargetFramework)' != 'net8.0' ">
TargetFramework=$(TargetFramework)
{E5B1C768-349E-4DAF-A134-56E4ECF1EEEF}
CKAN-AutoUpdateHelper
diff --git a/build.cake b/build.cake
index 34c44457f..035c1a5f1 100644
--- a/build.cake
+++ b/build.cake
@@ -153,7 +153,7 @@ Task("Build")
DotNetBuild(solution, new DotNetBuildSettings
{
Configuration = "NoGUI",
- Framework = "net7.0",
+ Framework = "net8.0",
});
}
});
@@ -363,7 +363,7 @@ Task("Test-UnitTests+Only")
DotNetTest(solution, new DotNetTestSettings
{
Configuration = "NoGUI",
- Framework = "net7.0",
+ Framework = "net8.0",
NoRestore = true,
NoBuild = true,
NoLogo = true,