Skip to content

Commit

Permalink
Target net8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Sep 3, 2024
1 parent 1545b63 commit c13930f
Show file tree
Hide file tree
Showing 24 changed files with 145 additions and 77 deletions.
4 changes: 2 additions & 2 deletions AutoUpdate/CKAN-autoupdate.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<ApplicationIcon>..\assets\ckan.ico</ApplicationIcon>
<TargetFrameworks>net48;net7.0-windows</TargetFrameworks>
<UseWindowsForms Condition=" '$(TargetFramework)' == 'net7.0-windows' ">true</UseWindowsForms>
<TargetFrameworks>net48;net8.0-windows</TargetFrameworks>
<UseWindowsForms Condition=" '$(TargetFramework)' == 'net8.0-windows' ">true</UseWindowsForms>
<EnableWindowsTargeting>true</EnableWindowsTargeting>
<FileAlignment>512</FileAlignment>
<ErrorReport>prompt</ErrorReport>
Expand Down
2 changes: 2 additions & 0 deletions Cmdline/Action/Upgrade.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@

using CKAN.Versioning;
using CKAN.Configuration;
#if !NET8_0_OR_GREATER
using CKAN.Extensions;
#endif

namespace CKAN.CmdLine
{
Expand Down
4 changes: 2 additions & 2 deletions Cmdline/CKAN-cmdline.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<StartupObject>CKAN.CmdLine.MainClass</StartupObject>
<ApplicationIcon>..\assets\ckan.ico</ApplicationIcon>
<TargetFrameworks>net48;net7.0;net7.0-windows</TargetFrameworks>
<TargetFrameworks>net48;net8.0;net8.0-windows</TargetFrameworks>
<BaseTargetFramework>$(TargetFramework.Replace("-windows", ""))</BaseTargetFramework>
<FileAlignment>512</FileAlignment>
<ErrorReport>prompt</ErrorReport>
Expand Down Expand Up @@ -76,7 +76,7 @@
<Name>CKAN-ConsoleUI</Name>
</ProjectReference>
<ProjectReference Include="..\GUI\CKAN-GUI.csproj"
Condition=" '$(TargetFramework)' != 'net7.0' ">
Condition=" '$(TargetFramework)' != 'net8.0' ">
<SetTargetFramework>TargetFramework=$(TargetFramework)</SetTargetFramework>
<Project>{A79F9D54-315C-472B-928F-713A5860B2BE}</Project>
<Name>CKAN-GUI</Name>
Expand Down
4 changes: 2 additions & 2 deletions ConsoleUI/CKAN-ConsoleUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<LangVersion>9</LangVersion>
<Nullable>enable</Nullable>
<ApplicationIcon>..\assets\ckan.ico</ApplicationIcon>
<TargetFrameworks>net48;net7.0</TargetFrameworks>
<TargetFrameworks>net48;net8.0</TargetFrameworks>
<FileAlignment>512</FileAlignment>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
Expand All @@ -39,7 +39,7 @@
<Reference Include="System.ServiceModel" />
<Reference Include="System.Transactions" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net7.0' ">
<ItemGroup Condition=" '$(TargetFramework)' == 'net8.0' ">
<PackageReference Include="System.ServiceModel.Primitives" Version="6.2.0" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="8.0.0" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Core/CKAN-core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsNotAsErrors>SYSLIB0050,IDE0090</WarningsNotAsErrors>
<NoWarn>IDE1006</NoWarn>
<TargetFrameworks>netstandard2.0;net48;net7.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net48;net8.0</TargetFrameworks>
<CoreCompileDependsOn>PrepareResources;$(CompileDependsOn)</CoreCompileDependsOn>
</PropertyGroup>
<PropertyGroup>
Expand Down
2 changes: 2 additions & 0 deletions Core/Configuration/JsonConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@

using Newtonsoft.Json;

#if !NET8_0_OR_GREATER
using CKAN.Extensions;
#endif
using CKAN.Games.KerbalSpaceProgram;

namespace CKAN.Configuration
Expand Down
2 changes: 2 additions & 0 deletions Core/Registry/RegistryManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
using Newtonsoft.Json;

using CKAN.Versioning;
#if !NET8_0_OR_GREATER
using CKAN.Extensions;
#endif

namespace CKAN
{
Expand Down
6 changes: 3 additions & 3 deletions GUI/CKAN-GUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsNotAsErrors>CS0618</WarningsNotAsErrors>
<NoWarn>IDE1006,NU1701</NoWarn>
<TargetFrameworks>net48;net7.0-windows</TargetFrameworks>
<TargetFrameworks>net48;net8.0-windows</TargetFrameworks>
<BaseTargetFramework>$(TargetFramework.Replace("-windows", ""))</BaseTargetFramework>
<UseWindowsForms Condition=" '$(TargetFramework)' == 'net7.0-windows' ">true</UseWindowsForms>
<UseWindowsForms Condition=" '$(TargetFramework)' == 'net8.0-windows' ">true</UseWindowsForms>
<EnableWindowsTargeting>true</EnableWindowsTargeting>
<FileAlignment>512</FileAlignment>
<ErrorReport>prompt</ErrorReport>
Expand All @@ -49,7 +49,7 @@
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net7.0' ">
<ItemGroup Condition=" '$(TargetFramework)' == 'net8.0' ">
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="System.ServiceModel.Primitives" Version="6.2.0" />
<PackageReference Include="TxFileManager.NETStandard" Version="2.0.0" />
Expand Down
42 changes: 23 additions & 19 deletions GUI/Controls/EditModpack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,25 +133,27 @@ protected override void OnHelpRequested(HelpEventArgs evt)
evt.Handled = Util.TryOpenWebPage(HelpURLs.ModPacks);
}

private void AddGroup(List<RelationshipDescriptor> relationships, ListViewGroup group, IRegistryQuerier registry)
private void AddGroup(List<RelationshipDescriptor> 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<ModuleRelationshipDescriptor>()
.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<ListViewItem>()
.ToArray());
}
}

Expand Down Expand Up @@ -235,6 +237,7 @@ private void RelationshipsListView_ItemSelectionChanged(object? sender, ListView
OnSelectedItemsChanged?.Invoke(RelationshipsListView.SelectedItems);
var kinds = RelationshipsListView.SelectedItems.Cast<ListViewItem>()
.Select(lvi => lvi.Group)
.OfType<ListViewGroup>()
.Distinct()
.ToList();
if (kinds.Count == 1)
Expand Down Expand Up @@ -305,12 +308,13 @@ private void IgnoreRadioButton_CheckedChanged(object? sender, EventArgs? e)

private void MoveItemsTo(IEnumerable<ListViewItem> items, ListViewGroup group, List<RelationshipDescriptor> 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
Expand Down
6 changes: 6 additions & 0 deletions GUI/Controls/HintTextBox.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
using System;
using System.Drawing;
using System.Windows.Forms;
#if NET5_0_OR_GREATER
using System.Runtime.Versioning;
#endif

namespace CKAN.GUI
{
/// <summary>
/// A textbox which shows a "clear text" icon on the right side
/// whenever data is present.
/// </summary>
#if NET5_0_OR_GREATER
[SupportedOSPlatform("windows")]
#endif
public partial class HintTextBox : TextBox
{

Expand Down
6 changes: 6 additions & 0 deletions GUI/Controls/LeftRightRowPanel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using System.Windows.Forms;
using System.Drawing;
#if NET5_0_OR_GREATER
using System.Runtime.Versioning;
#endif

namespace CKAN.GUI
{
Expand All @@ -8,6 +11,9 @@ namespace CKAN.GUI
/// one on the right side and one on the left.
/// Intended to allow autosizing of Buttons.
/// </summary>
#if NET5_0_OR_GREATER
[SupportedOSPlatform("windows")]
#endif
public class LeftRightRowPanel : TableLayoutPanel
{
/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion GUI/Controls/ModInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 5 additions & 4 deletions GUI/Controls/ThemedTabControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions GUI/Controls/TransparentTextBox.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System.Windows.Forms;
#if NET5_0_OR_GREATER
using System.Runtime.Versioning;
#endif

namespace CKAN.GUI
{
Expand All @@ -9,6 +12,9 @@ namespace CKAN.GUI
/// Multiline is set to true.
/// Used in <see cref="MainModInfo"/>.</para>
/// </summary>
#if NET5_0_OR_GREATER
[SupportedOSPlatform("windows")]
#endif
public class TransparentTextBox : TextBox
{
public TransparentTextBox()
Expand Down
3 changes: 3 additions & 0 deletions GUI/Controls/UnmanagedFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<TreeNode>
{
public int Compare(object? a, object? b)
Expand Down
6 changes: 6 additions & 0 deletions GUI/Dialogs/GameCommandLineOptionsDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Loading

0 comments on commit c13930f

Please sign in to comment.