Skip to content

Commit

Permalink
C#: Upgrade to .NET 6 (5.0 -> 6.0)
Browse files Browse the repository at this point in the history
  • Loading branch information
neikeq committed Aug 22, 2022
1 parent e22dd3b commit 18f805b
Show file tree
Hide file tree
Showing 38 changed files with 232 additions and 353 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linux_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ jobs:
uses: actions/setup-dotnet@v1
if: ${{ matrix.build-mono }}
with:
dotnet-version: '5.0.x'
dotnet-version: '6.0.x'

- name: Compilation
uses: ./.github/actions/godot-build
Expand Down
2 changes: 1 addition & 1 deletion modules/mono/build_scripts/build_assemblies.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def build_godot_api(msbuild_tool, module_dir, output_dir):

core_src_dir = os.path.abspath(os.path.join(sln, os.pardir, "GodotSharp", "bin", build_config))
editor_src_dir = os.path.abspath(os.path.join(sln, os.pardir, "GodotSharpEditor", "bin", build_config))
plugins_src_dir = os.path.abspath(os.path.join(sln, os.pardir, "GodotPlugins", "bin", build_config, "net5.0"))
plugins_src_dir = os.path.abspath(os.path.join(sln, os.pardir, "GodotPlugins", "bin", build_config, "net6.0"))

if not os.path.isdir(editor_api_dir):
assert not os.path.isfile(editor_api_dir)
Expand Down
2 changes: 1 addition & 1 deletion modules/mono/build_scripts/mono_configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def check_app_host_file_exists(file):


def find_dotnet_app_host_dir(env):
dotnet_version = "5.0"
dotnet_version = "6.0"

dotnet_root = env["dotnet_root"]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{639E48BD-44E5-4091-8EDD-22D36DC0768D}</ProjectGuid>
<TargetFramework>net5.0</TargetFramework>
<LangVersion>7.2</LangVersion>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>10</LangVersion>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{A8CDAD94-C6D4-4B19-A7E7-76C53CC92984}</ProjectGuid>
<TargetFramework>net5.0</TargetFramework>
<LangVersion>7.2</LangVersion>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>10</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Build" Version="15.1.548" ExcludeAssets="runtime" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static ProjectRootElement GenGameProject(string name)
root.Sdk = GodotSdkAttrValue;

var mainGroup = root.AddPropertyGroup();
mainGroup.AddProperty("TargetFramework", "net5.0");
mainGroup.AddProperty("TargetFramework", "net6.0");
mainGroup.AddProperty("EnableDynamicLoading", "true");

string sanitizedName = IdentifierUtils.SanitizeQualifiedIdentifier(name, allowEmptyIdentifiers: true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<!-- Specify compile items manually to avoid including dangling generated items. -->
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Text;
using System.Threading.Tasks;
Expand Down Expand Up @@ -42,9 +41,9 @@ private static Process LaunchBuild(BuildInfo buildInfo, Action<string> stdOutHan
var process = new Process { StartInfo = startInfo };

if (stdOutHandler != null)
process.OutputDataReceived += (s, e) => stdOutHandler.Invoke(e.Data);
process.OutputDataReceived += (_, e) => stdOutHandler.Invoke(e.Data);
if (stdErrHandler != null)
process.ErrorDataReceived += (s, e) => stdErrHandler.Invoke(e.Data);
process.ErrorDataReceived += (_, e) => stdErrHandler.Invoke(e.Data);

process.Start();

Expand Down Expand Up @@ -102,9 +101,9 @@ private static Process LaunchPublish(BuildInfo buildInfo, Action<string> stdOutH
var process = new Process { StartInfo = startInfo };

if (stdOutHandler != null)
process.OutputDataReceived += (s, e) => stdOutHandler.Invoke(e.Data);
process.OutputDataReceived += (_, e) => stdOutHandler.Invoke(e.Data);
if (stdErrHandler != null)
process.ErrorDataReceived += (s, e) => stdErrHandler.Invoke(e.Data);
process.ErrorDataReceived += (_, e) => stdErrHandler.Invoke(e.Data);

process.Start();

Expand Down
4 changes: 2 additions & 2 deletions modules/mono/editor/GodotTools/GodotTools/GodotTools.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{27B00618-A6F2-4828-B922-05CAEB08C286}</ProjectGuid>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<EnableDynamicLoading>true</EnableDynamicLoading>
<LangVersion>9</LangVersion>
<LangVersion>10</LangVersion>
<!-- The Godot editor uses the Debug Godot API assemblies -->
<GodotApiConfiguration>Debug</GodotApiConfiguration>
<GodotSourceRootPath>$(SolutionDir)/../../../../</GodotSourceRootPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,6 @@ public static extern bool godot_icall_EditorProgress_Step(in godot_string task,
[DllImport(GodotDllName)]
private static extern void godot_icall_Internal_FullExportTemplatesDir(out godot_string dest);

[DllImport(GodotDllName)]
private static extern void godot_icall_Internal_SimplifyGodotPath(in godot_string path, out godot_string dest);

[DllImport(GodotDllName)]
private static extern bool godot_icall_Internal_IsMacOSAppBundleInstalled(in godot_string bundleId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace GodotTools.Utils
{
public static class FsPathUtils
{
private static readonly string _resourcePath = ProjectSettings.GlobalizePath("res://");
private static readonly string ResourcePath = ProjectSettings.GlobalizePath("res://");

private static bool PathStartsWithAlreadyNorm(this string childPath, string parentPath)
{
Expand All @@ -34,7 +34,7 @@ public static bool PathStartsWith(this string childPath, string parentPath)
public static string LocalizePathWithCaseChecked(string path)
{
string pathNorm = path.NormalizePath() + Path.DirectorySeparatorChar;
string resourcePathNorm = _resourcePath.NormalizePath() + Path.DirectorySeparatorChar;
string resourcePathNorm = ResourcePath.NormalizePath() + Path.DirectorySeparatorChar;

if (!pathNorm.PathStartsWithAlreadyNorm(resourcePathNorm))
return null;
Expand Down
48 changes: 20 additions & 28 deletions modules/mono/editor/GodotTools/GodotTools/Utils/OS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Runtime.Versioning;
using System.Text;
using GodotTools.Internals;

Expand Down Expand Up @@ -131,43 +132,34 @@ private static bool IsAnyOS(IEnumerable<string> names)
new[] { Names.MacOS, Names.Server, Names.Haiku, Names.Android, Names.iOS }
.Concat(LinuxBSDPlatforms).ToArray();

private static readonly Lazy<bool> _isWindows = new Lazy<bool>(() => IsOS(Names.Windows));
private static readonly Lazy<bool> _isMacOS = new Lazy<bool>(() => IsOS(Names.MacOS));
private static readonly Lazy<bool> _isLinuxBSD = new Lazy<bool>(() => IsAnyOS(LinuxBSDPlatforms));
private static readonly Lazy<bool> _isServer = new Lazy<bool>(() => IsOS(Names.Server));
private static readonly Lazy<bool> _isUWP = new Lazy<bool>(() => IsOS(Names.UWP));
private static readonly Lazy<bool> _isHaiku = new Lazy<bool>(() => IsOS(Names.Haiku));
private static readonly Lazy<bool> _isAndroid = new Lazy<bool>(() => IsOS(Names.Android));
private static readonly Lazy<bool> _isiOS = new Lazy<bool>(() => IsOS(Names.iOS));
private static readonly Lazy<bool> _isHTML5 = new Lazy<bool>(() => IsOS(Names.HTML5));
private static readonly Lazy<bool> _isUnixLike = new Lazy<bool>(() => IsAnyOS(UnixLikePlatforms));
private static readonly Lazy<bool> _isWindows = new(() => IsOS(Names.Windows));
private static readonly Lazy<bool> _isMacOS = new(() => IsOS(Names.MacOS));
private static readonly Lazy<bool> _isLinuxBSD = new(() => IsAnyOS(LinuxBSDPlatforms));
private static readonly Lazy<bool> _isServer = new(() => IsOS(Names.Server));
private static readonly Lazy<bool> _isUWP = new(() => IsOS(Names.UWP));
private static readonly Lazy<bool> _isHaiku = new(() => IsOS(Names.Haiku));
private static readonly Lazy<bool> _isAndroid = new(() => IsOS(Names.Android));
private static readonly Lazy<bool> _isiOS = new(() => IsOS(Names.iOS));
private static readonly Lazy<bool> _isHTML5 = new(() => IsOS(Names.HTML5));
private static readonly Lazy<bool> _isUnixLike = new(() => IsAnyOS(UnixLikePlatforms));

// TODO SupportedOSPlatformGuard once we target .NET 6
// [SupportedOSPlatformGuard("windows")]
public static bool IsWindows => _isWindows.Value || IsUWP;
[SupportedOSPlatformGuard("windows")] public static bool IsWindows => _isWindows.Value || IsUWP;

// [SupportedOSPlatformGuard("osx")]
public static bool IsMacOS => _isMacOS.Value;
[SupportedOSPlatformGuard("osx")] public static bool IsMacOS => _isMacOS.Value;

// [SupportedOSPlatformGuard("linux")]
public static bool IsLinuxBSD => _isLinuxBSD.Value;
[SupportedOSPlatformGuard("linux")] public static bool IsLinuxBSD => _isLinuxBSD.Value;

// [SupportedOSPlatformGuard("linux")]
public static bool IsServer => _isServer.Value;
[SupportedOSPlatformGuard("linux")] public static bool IsServer => _isServer.Value;

// [SupportedOSPlatformGuard("windows")]
public static bool IsUWP => _isUWP.Value;
[SupportedOSPlatformGuard("windows")] public static bool IsUWP => _isUWP.Value;

public static bool IsHaiku => _isHaiku.Value;

// [SupportedOSPlatformGuard("android")]
public static bool IsAndroid => _isAndroid.Value;
[SupportedOSPlatformGuard("android")] public static bool IsAndroid => _isAndroid.Value;

// [SupportedOSPlatformGuard("ios")]
public static bool IsiOS => _isiOS.Value;
[SupportedOSPlatformGuard("ios")] public static bool IsiOS => _isiOS.Value;

// [SupportedOSPlatformGuard("browser")]
public static bool IsHTML5 => _isHTML5.Value;
[SupportedOSPlatformGuard("browser")] public static bool IsHTML5 => _isHTML5.Value;
public static bool IsUnixLike => _isUnixLike.Value;

public static char PathSep => IsWindows ? ';' : ':';
Expand Down Expand Up @@ -204,7 +196,7 @@ private static string PathWhichWindows([NotNull] string name)

string nameExt = Path.GetExtension(name);
bool hasPathExt = !string.IsNullOrEmpty(nameExt) &&
windowsExts.Contains(nameExt, StringComparer.OrdinalIgnoreCase);
windowsExts.Contains(nameExt, StringComparer.OrdinalIgnoreCase);

searchDirs.Add(System.IO.Directory.GetCurrentDirectory()); // last in the list

Expand Down
Loading

0 comments on commit 18f805b

Please sign in to comment.