Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Update Project to .NET 8.0 and Resolve Associated Warnings #75

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions .github/workflows/install_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ jobs:
# Godot.
GODOT_SYMLINK="$(dotnet run -- godot env path)"

echo "🕵️‍♂️ Godot symlink path: $GODOT_SYMLINK"

# Make sure we can use Godot.
$GODOT_SYMLINK --version
"$GODOT_SYMLINK" --version

echo "✅ Godot location is in path!"

Expand Down Expand Up @@ -138,8 +140,10 @@ jobs:
# Godot.
GODOT_SYMLINK="$(dotnet run -- godot env path)"

echo "🕵️‍♂️ Godot symlink path: $GODOT_SYMLINK"

# Make sure we can use Godot.
$GODOT_SYMLINK --version
"$GODOT_SYMLINK" --version

echo "✅ Godot location is in path!"

Expand All @@ -162,10 +166,10 @@ jobs:
- name: 🧐 Make sure we can build a .NET Godot game
working-directory: TestPackage/TestPackage.Tests
run: |
GODOT="$(dotnet ../../GodotEnv/bin/Debug/net6.0/Chickensoft.GodotEnv.dll godot env get)"
GODOT="$(dotnet ../../GodotEnv/bin/Debug/net8.0/Chickensoft.GodotEnv.dll godot env get)"

dotnet build
$GODOT --headless --run-tests --quit-on-finish
"$GODOT" --headless --run-tests --quit-on-finish

echo "✅ Built and executed .NET test project."

Expand Down
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/GodotEnv/bin/Debug/net6.0/Chickensoft.GodotEnv.dll",
"program": "${workspaceFolder}/GodotEnv/bin/Debug/net8.0/Chickensoft.GodotEnv.dll",
"args": [
"--debug",
"${input:args}"
Expand Down
2 changes: 1 addition & 1 deletion GodotEnv.Tests/Chickensoft.GodotEnv.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RollForward>Major</RollForward>
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
Expand Down
8 changes: 4 additions & 4 deletions GodotEnv.Tests/src/MainTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class MainTest {
[Fact]
public async Task CallsCliFx()
=> await Should.NotThrowAsync(
async () => await GodotEnv.Main(new string[] { "not-a-command" })
async () => await GodotEnv.Main(["not-a-command"])
);

[Fact]
Expand All @@ -24,8 +24,8 @@ public void CreateExecutionContextParsesArgs() {
args, config, workingDir, addonsContext.Object,
godotContext.Object
);
context.CliArgs.ShouldBe(new string[] { "a" });
context.CommandArgs.ShouldBe(new string[] { "b" });
context.CliArgs.ShouldBe(["a"]);
context.CommandArgs.ShouldBe(["b"]);
context.Config.ShouldBe(config);
context.WorkingDir.ShouldBe(workingDir);
context.Addons.ShouldBe(addonsContext.Object);
Expand All @@ -34,7 +34,7 @@ public void CreateExecutionContextParsesArgs() {
}

public class GodotEnvActivatorTest {
private class ITestCommand(IExecutionContext executionContext) :
private sealed class ITestCommand(IExecutionContext executionContext) :
ICliCommand {
public IExecutionContext ExecutionContext { get; } = executionContext;
}
Expand Down
19 changes: 10 additions & 9 deletions GodotEnv.Tests/src/common/clients/FileClientTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,9 @@ public void CombineCombinesPathComponents() {
fs.Setup(fs => fs.Path).Returns(path.Object);
path.Setup(path => path.DirectorySeparatorChar)
.Returns('/');
var expectedArgs = new[] { "a", "b" };
path.Setup(path => path.Combine(
It.Is<string[]>(args => args.SequenceEqual(new[] { "a", "b" })))
It.Is<string[]>(args => args.SequenceEqual(expectedArgs)))
).Returns("a/b");

var computer = new Mock<IComputer>();
Expand Down Expand Up @@ -366,11 +367,11 @@ public void FileThatExistsFindsFirstPossibleName() {
fs, computer.Object, new Mock<IProcessRunner>().Object
);

client.FileThatExists(new string[] { "0.txt", "b.txt", "a.txt" }, "/")
client.FileThatExists(["0.txt", "b.txt", "a.txt"], "/")
.ShouldBe("/b.txt");
client.FileThatExists(new string[] { "0.txt", "a.txt", "b.txt" }, "/")
client.FileThatExists(["0.txt", "a.txt", "b.txt"], "/")
.ShouldBe("/a.txt");
client.FileThatExists(new string[] { "0.txt", "1.txt" }, "/")
client.FileThatExists(["0.txt", "1.txt"], "/")
.ShouldBeNull();
}

Expand Down Expand Up @@ -462,7 +463,7 @@ public void ReadJsonFileReadsFromFirstFileItFounds() {

client.ReadJsonFile(
"",
new string[] { "model_a.json", "model_b.json" },
["model_a.json", "model_b.json"],
out var filename,
new TestJsonModel(name: "default")
).ShouldBe(new TestJsonModel(name: "test"));
Expand All @@ -484,7 +485,7 @@ public void ReadJsonFileThrowsIfDeserializedValueIsNull() {
var e = Should.Throw<IOException>(
() => client.ReadJsonFile(
"",
new string[] { "model.json" },
["model.json"],
out var filename,
new TestJsonModel(name: "default")
)
Expand All @@ -507,7 +508,7 @@ public void ReadJsonFileThrowsIOExceptionOnOtherError() {
Should.Throw<IOException>(
() => client.ReadJsonFile(
"",
new string[] { "model.json", "model_a.json", "model_b.json" },
["model.json", "model_a.json", "model_b.json"],
out var filename,
new TestJsonModel(name: "default")
)
Expand All @@ -527,7 +528,7 @@ public void ReadJsonFileChecksOtherPossibleFilenames() {

client.ReadJsonFile(
"",
new string[] { "model.json", "model_a.json", "model_b.json" },
["model.json", "model_a.json", "model_b.json"],
out var filename,
new TestJsonModel(name: "default")
).ShouldBe(new TestJsonModel(name: "alternative"));
Expand All @@ -546,7 +547,7 @@ public void ReadJsonFileReturnsDefaultValues() {

client.ReadJsonFile(
"",
new string[] { "model.json", "model_a.json", "model_b.json" },
["model.json", "model_a.json", "model_b.json"],
out var filename,
new TestJsonModel(name: "default")
).ShouldBe(new TestJsonModel(name: "default"));
Expand Down
4 changes: 2 additions & 2 deletions GodotEnv.Tests/src/common/models/ExecutionContextTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ namespace Chickensoft.GodotEnv.Tests;
public class ExecutionContextTest {
private const string VERSION = "1.2.3";
private const string WORKING_DIR = "/";
private readonly string[] _cliArgs = new string[] { "a", "b" };
private readonly string[] _commandArgs = new string[] { "c", "d" };
private readonly string[] _cliArgs = ["a", "b"];
private readonly string[] _commandArgs = ["c", "d"];

[Fact]
public void Initializes() {
Expand Down
4 changes: 2 additions & 2 deletions GodotEnv.Tests/src/common/utilities/ProcessRunnerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class ProcessRunnerTest {
public async Task RunsProcessOnWindows() {
var runner = new ProcessRunner();
var result = await runner.Run(
Environment.CurrentDirectory, "cmd", new[] { "/c echo \"hello\"" }
Environment.CurrentDirectory, "cmd", ["/c echo \"hello\""]
);
result.ExitCode.ShouldBe(0);
result.Succeeded.ShouldBe(true);
Expand All @@ -21,7 +21,7 @@ public async Task RunsProcessOnWindows() {
public async Task RunsProcessOnMacLinux() {
var runner = new ProcessRunner();
var result = await runner.Run(
Environment.CurrentDirectory, "echo", new[] { "hello" }
Environment.CurrentDirectory, "echo", ["hello"]
);
result.ExitCode.ShouldBe(0);
result.Succeeded.ShouldBe(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ public void LoadsAddonsFile() {

var value = new AddonsFile();

var expectedArgs = new[] { "addons.json", "addons.jsonc" };
fileClient.Setup(client => client.ReadJsonFile(
projectPath,
It.Is<string[]>(
value => value.SequenceEqual(
new string[] { "addons.json", "addons.jsonc" }
)
value => value.SequenceEqual(expectedArgs)
),
out filename,
It.IsAny<AddonsFile>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Chickensoft.GodotEnv.Tests;
using Xunit;

public class AddonsRepositoryTest {
private class Subject(
private sealed class Subject(
IConsole console,
Mock<IFileClient> client,
Mock<ILog> log,
Expand Down Expand Up @@ -361,7 +361,7 @@ public async Task InstallAddonFromCacheCopiesCachedAddonToAddonsPath() {
);

cli.Runs(addonInstallPath, new ProcessResult(0), "git", "init");
cli.Runs(addonInstallPath, new ProcessResult(0),
cli.Runs(addonInstallPath, new ProcessResult(0),
"git", "config", "--local", "user.email", "godotenv@godotenv.com"
);
cli.Runs(addonInstallPath, new ProcessResult(0),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Chickensoft.GodotEnv.Tests.features.godot.domain;
namespace Chickensoft.GodotEnv.Tests.Features.Godot.Domain;

using System;
using System.Collections.Generic;
Expand All @@ -14,9 +14,9 @@ namespace Chickensoft.GodotEnv.Tests.features.godot.domain;
using Xunit;

public class GodotChecksumClientTest {
private static readonly string GODOT_4_3_DEV_5_MACOS_CHECKSUM = "0fdd44c725980c463d86b14aeb47fc41a35ff9005e9df9a9c821168b21d60f845d80313e93c892565daadef04d02c6f6fbb6a9d9a26374db9caa8cd4d9354d7c";
private const string GODOT_4_3_DEV_5_MACOS_CHECKSUM = "0fdd44c725980c463d86b14aeb47fc41a35ff9005e9df9a9c821168b21d60f845d80313e93c892565daadef04d02c6f6fbb6a9d9a26374db9caa8cd4d9354d7c";

private static readonly string GODOT_ENV_STRING_CHECKSUM =
private const string GODOT_ENV_STRING_CHECKSUM =
"3a2e1fa23f9e99ff976803d6fb1283707e015b7904040f604a6a10240c1eba138c6feed88e9ec5db72aee81c6f9b1eba99292e346eab054004e2427a4d4b39b8";

private static string GetChecksumFileUrl(string version) =>
Expand Down Expand Up @@ -179,8 +179,7 @@ private static async Task<Mock<INetworkClient>> GetMockChecksumFileNetworkClient
string godotReleaseJson;
await using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName)
?? throw new FileNotFoundException("Failed to get test release JSON file.")) {
using (var reader = new StreamReader(stream))
{
using (var reader = new StreamReader(stream)) {
godotReleaseJson = await reader.ReadToEndAsync();
}
}
Expand All @@ -191,8 +190,9 @@ private static async Task<Mock<INetworkClient>> GetMockChecksumFileNetworkClient
It.IsAny<string>()
))
.ReturnsAsync(() => {
var response = new HttpResponseMessage(HttpStatusCode.OK);
response.Content = new StringContent(godotReleaseJson);
var response = new HttpResponseMessage(HttpStatusCode.OK) {
Content = new StringContent(godotReleaseJson)
};
return response;
});
return networkClient;
Expand Down
76 changes: 38 additions & 38 deletions GodotEnv.Tests/src/features/godot/models/GodotEnvironmentTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Chickensoft.GodotEnv.Tests.features.godot.models;
namespace Chickensoft.GodotEnv.Tests.Features.Godot.Models;

using Chickensoft.GodotEnv.Features.Godot.Models;
using Common.Clients;
Expand All @@ -8,89 +8,89 @@ namespace Chickensoft.GodotEnv.Tests.features.godot.models;
using Xunit;

public class GodotEnvironmentTest {
private readonly Mock<IComputer> computer = new();
private readonly Mock<IFileClient> fileClient = new();
private readonly SemanticVersion version4 = new("4", "1", "2");
private readonly SemanticVersion version3 = new("3", "5", "3");
private readonly Mock<IComputer> _computer = new();
private readonly Mock<IFileClient> _fileClient = new();
private readonly SemanticVersion _version4 = new("4", "1", "2");
private readonly SemanticVersion _version3 = new("3", "5", "3");

[Fact]
public void GetsExpectedMacDownloadUrl() {
var platform = new MacOS(fileClient.Object, computer.Object);
var platform = new MacOS(_fileClient.Object, _computer.Object);

var downloadUrl = platform.GetDownloadUrl(version4, false, false);
downloadUrl.ShouldBe(GetExpectedDownloadUrl(version4, "stable_macos.universal"));
var downloadUrl = platform.GetDownloadUrl(_version4, false, false);
downloadUrl.ShouldBe(GetExpectedDownloadUrl(_version4, "stable_macos.universal"));

downloadUrl = platform.GetDownloadUrl(version3, false, false);
downloadUrl.ShouldBe(GetExpectedDownloadUrl(version3, "stable_osx.universal"));
downloadUrl = platform.GetDownloadUrl(_version3, false, false);
downloadUrl.ShouldBe(GetExpectedDownloadUrl(_version3, "stable_osx.universal"));
}

[Fact]
public void GetsExpectedMacMonoDownloadUrl() {
var platform = new MacOS(fileClient.Object, computer.Object);
var platform = new MacOS(_fileClient.Object, _computer.Object);

var downloadUrl = platform.GetDownloadUrl(version4, true, false);
downloadUrl.ShouldBe(GetExpectedDownloadUrl(version4, "stable_mono_macos.universal"));
var downloadUrl = platform.GetDownloadUrl(_version4, true, false);
downloadUrl.ShouldBe(GetExpectedDownloadUrl(_version4, "stable_mono_macos.universal"));

downloadUrl = platform.GetDownloadUrl(version3, true, false);
downloadUrl.ShouldBe(GetExpectedDownloadUrl(version3, "stable_mono_osx.universal"));
downloadUrl = platform.GetDownloadUrl(_version3, true, false);
downloadUrl.ShouldBe(GetExpectedDownloadUrl(_version3, "stable_mono_osx.universal"));
}

[Fact]
public void GetsExpectedWindowsDownloadUrl() {
var platform = new Windows(fileClient.Object, computer.Object);
var platform = new Windows(_fileClient.Object, _computer.Object);

var downloadUrl = platform.GetDownloadUrl(version4, false, false);
var downloadUrl = platform.GetDownloadUrl(_version4, false, false);
downloadUrl.ShouldBe($"{GodotEnvironment.GODOT_URL_PREFIX}4.1.2-stable/Godot_v4.1.2-stable_win64.exe.zip");

downloadUrl = platform.GetDownloadUrl(version3, false, false);
downloadUrl.ShouldBe($"{GodotEnvironment.GODOT_URL_PREFIX}{version3.VersionString}-stable/Godot_v{version3.VersionString}-stable_win64.exe.zip");
downloadUrl = platform.GetDownloadUrl(_version3, false, false);
downloadUrl.ShouldBe($"{GodotEnvironment.GODOT_URL_PREFIX}{_version3.VersionString}-stable/Godot_v{_version3.VersionString}-stable_win64.exe.zip");
}

[Fact]
public void GetsExpectedWindowsMonoDownloadUrl() {
var platform = new Windows(fileClient.Object, computer.Object);
var platform = new Windows(_fileClient.Object, _computer.Object);

var downloadUrl = platform.GetDownloadUrl(version4, true, false);
downloadUrl.ShouldBe(GetExpectedDownloadUrl(version4, "stable_mono_win64"));
var downloadUrl = platform.GetDownloadUrl(_version4, true, false);
downloadUrl.ShouldBe(GetExpectedDownloadUrl(_version4, "stable_mono_win64"));

downloadUrl = platform.GetDownloadUrl(version3, true, false);
downloadUrl.ShouldBe(GetExpectedDownloadUrl(version3, "stable_mono_win64"));
downloadUrl = platform.GetDownloadUrl(_version3, true, false);
downloadUrl.ShouldBe(GetExpectedDownloadUrl(_version3, "stable_mono_win64"));
}

[Fact]
public void GetsExpectedLinuxDownloadUrl() {
var platform = new Linux(fileClient.Object, computer.Object);
var platform = new Linux(_fileClient.Object, _computer.Object);

var downloadUrl = platform.GetDownloadUrl(version4, false, false);
downloadUrl.ShouldBe(GetExpectedDownloadUrl(version4, "stable_linux.x86_64"));
var downloadUrl = platform.GetDownloadUrl(_version4, false, false);
downloadUrl.ShouldBe(GetExpectedDownloadUrl(_version4, "stable_linux.x86_64"));

downloadUrl = platform.GetDownloadUrl(version3, false, false);
downloadUrl.ShouldBe(GetExpectedDownloadUrl(version3, "stable_x11.64"));
downloadUrl = platform.GetDownloadUrl(_version3, false, false);
downloadUrl.ShouldBe(GetExpectedDownloadUrl(_version3, "stable_x11.64"));
}

[Fact]
public void GetsExpectedLinuxMonoDownloadUrl() {
var platform = new Linux(fileClient.Object, computer.Object);
var platform = new Linux(_fileClient.Object, _computer.Object);

var downloadUrl = platform.GetDownloadUrl(version4, true, false);
downloadUrl.ShouldBe(GetExpectedDownloadUrl(version4, "stable_mono_linux_x86_64"));
var downloadUrl = platform.GetDownloadUrl(_version4, true, false);
downloadUrl.ShouldBe(GetExpectedDownloadUrl(_version4, "stable_mono_linux_x86_64"));

downloadUrl = platform.GetDownloadUrl(version3, true, false);
downloadUrl.ShouldBe(GetExpectedDownloadUrl(version3, "stable_mono_x11_64"));
downloadUrl = platform.GetDownloadUrl(_version3, true, false);
downloadUrl.ShouldBe(GetExpectedDownloadUrl(_version3, "stable_mono_x11_64"));
}

[Fact]
public void GetsExpectedTemplatesDownloadUrl() {
var platform = new MacOS(fileClient.Object, computer.Object);
var downloadUrl = platform.GetDownloadUrl(version4, false, true);
var platform = new MacOS(_fileClient.Object, _computer.Object);
var downloadUrl = platform.GetDownloadUrl(_version4, false, true);

downloadUrl.ShouldBe($"{GodotEnvironment.GODOT_URL_PREFIX}4.1.2-stable/Godot_v4.1.2-stable_export_templates.tpz");
}

[Fact]
public void GetsExpectedTemplatesMonoDownloadUrl() {
var platform = new MacOS(fileClient.Object, computer.Object);
var downloadUrl = platform.GetDownloadUrl(version4, true, true);
var platform = new MacOS(_fileClient.Object, _computer.Object);
var downloadUrl = platform.GetDownloadUrl(_version4, true, true);

downloadUrl.ShouldBe($"{GodotEnvironment.GODOT_URL_PREFIX}4.1.2-stable/Godot_v4.1.2-stable_mono_export_templates.tpz");
}
Expand Down
2 changes: 1 addition & 1 deletion GodotEnv/Chickensoft.GodotEnv.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RollForward>Major</RollForward>
<LangVersion>preview</LangVersion>
<PackAsTool>true</PackAsTool>
Expand Down
Loading