Skip to content

Commit b61759e

Browse files
authored
Upgrade to C# 14 (CnCNet#877)
1 parent a28c4df commit b61759e

File tree

6 files changed

+50
-44
lines changed

6 files changed

+50
-44
lines changed
Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,64 @@
11
using System.Collections.Generic;
22
using System.Linq;
3-
using System.Runtime.CompilerServices;
43

54
using Rampastring.Tools;
65

76
namespace ClientCore.Extensions
87
{
98
public static class IniFileExtensions
109
{
11-
// Clone() method is not officially available now. https://github.com/Rampastring/Rampastring.Tools/issues/12
12-
public static IniFile Clone(this IniFile oldIniFile)
10+
extension(IniFile iniFile)
1311
{
14-
var newIni = new IniFile();
15-
foreach (string sectionName in oldIniFile.GetSections())
12+
// Clone() method is not officially available now. https://github.com/Rampastring/Rampastring.Tools/issues/12
13+
public IniFile Clone()
1614
{
17-
IniSection oldSection = oldIniFile.GetSection(sectionName);
18-
newIni.AddSection(oldSection.Clone());
19-
}
20-
21-
return newIni;
22-
}
15+
var newIni = new IniFile();
16+
foreach (string sectionName in iniFile.GetSections())
17+
{
18+
IniSection oldSection = iniFile.GetSection(sectionName);
19+
newIni.AddSection(oldSection.Clone());
20+
}
2321

24-
public static IniSection Clone(this IniSection oldSection)
25-
{
26-
IniSection newSection = new(oldSection.SectionName);
22+
return newIni;
23+
}
2724

28-
foreach ((var key, var value) in oldSection.Keys)
25+
public IniSection GetOrAddSection(string sectionName)
2926
{
30-
newSection.AddKey(key, value);
27+
var section = iniFile.GetSection(sectionName);
28+
if (section != null)
29+
return section;
30+
31+
section = new IniSection(sectionName);
32+
iniFile.AddSection(section);
33+
return section;
3134
}
3235

33-
return newSection;
36+
public string[] GetStringListValue(string section, string key, string defaultValue, char[] separators = null)
37+
=> (iniFile.GetSection(section)?.GetStringValue(key, defaultValue) ?? defaultValue)
38+
.SplitWithCleanup();
39+
3440
}
3541

36-
public static IniSection GetOrAddSection(this IniFile iniFile, string sectionName)
42+
extension(IniSection iniSection)
3743
{
38-
var section = iniFile.GetSection(sectionName);
39-
if (section != null)
40-
return section;
44+
public IniSection Clone()
45+
{
46+
IniSection newSection = new(iniSection.SectionName);
4147

42-
section = new IniSection(sectionName);
43-
iniFile.AddSection(section);
44-
return section;
45-
}
48+
foreach ((var key, var value) in iniSection.Keys)
49+
{
50+
newSection.AddKey(key, value);
51+
}
4652

47-
public static void RemoveAllKeys(this IniSection iniSection)
48-
{
49-
var keys = new List<KeyValuePair<string, string>>(iniSection.Keys);
50-
foreach (KeyValuePair<string, string> iniSectionKey in keys)
51-
iniSection.RemoveKey(iniSectionKey.Key);
52-
}
53+
return newSection;
54+
}
5355

54-
public static string[] GetStringListValue(this IniFile iniFile, string section, string key, string defaultValue, char[] separators = null)
55-
=> (iniFile.GetSection(section)?.GetStringValue(key, defaultValue) ?? defaultValue)
56-
.SplitWithCleanup();
56+
public void RemoveAllKeys()
57+
{
58+
var keys = new List<KeyValuePair<string, string>>(iniSection.Keys);
59+
foreach (KeyValuePair<string, string> iniSectionKey in keys)
60+
iniSection.RemoveKey(iniSectionKey.Key);
61+
}
62+
}
5763
}
5864
}

DXClient.sln

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 17
4-
VisualStudioVersion = 17.2.32408.312
3+
# Visual Studio Version 18
4+
VisualStudioVersion = 18.0.11217.181
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DXMainClient", "DXMainClient\DXMainClient.csproj", "{97458C1E-2E6C-4C5C-93C7-16A6712802E9}"
77
EndProject

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<PropertyGroup>
3-
<LangVersion>12.0</LangVersion>
3+
<LangVersion>14.0</LangVersion>
44
<ComVisible>false</ComVisible>
55
<CLSCompliant>false</CLSCompliant>
66
<ImplicitUsings>disable</ImplicitUsings>

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ To build this project, you must use Git to clone the repository, instead of down
2727
git submodule update --init --recursive
2828
```
2929

30-
Building the solution for **any** platform requires Visual Studio 2022 17.8 or newer and/or the .NET SDK 8.0.200. A modern version of Visual Studio Code, MonoDevelop or Visual Studio for Mac could also work, but are not officially supported.
31-
To debug WindowsXNA builds the .NET SDK 8.0 x86 is additionally required.
30+
Building the solution for **any** platform requires the .NET SDK 10.0.100. Editing the source code requires Visual Studio 2026 or newer, or Rider 2025.3 or newer. A modern version of Visual Studio Code also works, but is not officially supported.
31+
To debug WindowsXNA builds the .NET SDK 10.0 x86 is additionally required.
3232
When using the included build scripts PowerShell 7.2 or newer is required.[^install-powershell]
3333

3434
## Compiling and debugging
3535

36-
* Compiling itself is simple: assuming you have the .NET 8.0 SDK installed, you can just open the solution with Visual Studio and compile it right away.
36+
* Compiling itself is simple: assuming you have the .NET SDK 10.0 installed, you can just open the solution with Visual Studio and compile it right away.
3737
* When built as a debug build, the client executable expects to reside in the same directory with the target project's main game executable. Resources should exist in a "Resources" sub-directory in the same directory. The repository contains sample resources and post-build commands for copying them so that you can immediately run the client in debug mode by just hitting the Debug button in Visual Studio.
3838
* When built in release mode, the client executables expect to reside in the `Resources` sub-directory itself for .NET 4.8, named `clientdx.exe`, `clientogl.exe` and `clientxna.exe`. Each `.exe` file or `.dll` file expects a `.pdb` file for diagnostics purpose. It's advised not to delete these `.pdb` files. Keep all `.pdb` files even for end users.
3939
* The `Scripts` directory has automated build scripts that build the client for all platforms and copy the output files to a folder named `Compiled` in the project root. You can then copy the contents of this `Compiled` directory into the `Resources` sub-directory of any target project.
@@ -89,7 +89,7 @@ Refer to [Docs/Build.md](/Docs/Build.md) for more information about building the
8989
* [.NET 8.0 Desktop Runtime x86](https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/runtime-desktop-8.0.0-windows-x86-installer).
9090

9191
Windows 7 SP1 and Windows 8.x additionally require:
92-
* Microsoft Visual C++ 2015-2019 Redistributable [64-bit](https://aka.ms/vs/16/release/vc_redist.x64.exe) / [32-bit](https://aka.ms/vs/16/release/vc_redist.x86.exe).
92+
* Microsoft Visual C++ 2015-2019 Redistributable [64-bit](https://aka.ms/vs/16/release/vc_redist.x64.exe) / [32-bit](https://aka.ms/vs/16/release/vc_redist.x86.exe). Note: the latest version of this redistributable is named "Microsoft Visual C++ 2015-2026 Redistributable", available [here](https://learn.microsoft.com/cpp/windows/latest-supported-vc-redist). We recommend using the latest version instead of the 2015-2019 version.
9393

9494
Windows 7 SP1 additionally requires:
9595
* KB3063858 [64-bit](https://www.microsoft.com/download/details.aspx?id=47442) / [32-bit](https://www.microsoft.com/download/details.aspx?id=47409).

Scripts/build.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ function Script:Invoke-BuildProject {
112112
# $Private:ArgumentList.Add('--arch=x86')
113113
# }
114114

115-
& 'dotnet' $Private:ArgumentList
115+
& 'dotnet' $Private:ArgumentList
116116
if ($LASTEXITCODE) {
117-
throw "Build failed for ${Engine}$Script:ConfigurationSuffix $Framework"
117+
throw "Build failed for ${Engine}$Script:ConfigurationSuffix $Framework (exit code $LASTEXITCODE)"
118118
}
119119
}
120120
else {

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
33
"rollForward": "latestFeature",
4-
"version": "8.0.200"
4+
"version": "10.0.100"
55
}
66
}

0 commit comments

Comments
 (0)