From 91c578815cbee3f0b4565100284192c6ce56fe24 Mon Sep 17 00:00:00 2001 From: Luke Date: Sat, 11 Jan 2025 11:19:16 +1000 Subject: [PATCH 01/11] Update net6 refs to net9 --- .github/workflows/ci-otapi3.yml | 12 ++++++------ .vscode/launch.json | 6 +++--- .vscode/tasks.json | 2 +- Dockerfile | 2 +- README.md | 4 ++-- README_cn.md | 4 ++-- TShockAPI/TShockAPI.csproj | 2 +- TShockInstaller/TShockInstaller.csproj | 2 +- TShockLauncher.Tests/TShockLauncher.Tests.csproj | 2 +- TShockLauncher/TShockLauncher.csproj | 8 ++++---- TShockPluginManager/Nuget.cs | 2 +- TShockPluginManager/TShockPluginManager.csproj | 2 +- appveyor.yml | 2 +- 13 files changed, 25 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci-otapi3.yml b/.github/workflows/ci-otapi3.yml index f5599ffcf..a0a4a07b6 100644 --- a/.github/workflows/ci-otapi3.yml +++ b/.github/workflows/ci-otapi3.yml @@ -39,27 +39,27 @@ jobs: - name: Produce installer run: | cd TShockInstaller - dotnet publish -r ${{ matrix.arch }} -f net6.0 -c Release -p:PublishSingleFile=true --self-contained true + dotnet publish -r ${{ matrix.arch }} -f net9.0 -c Release -p:PublishSingleFile=true --self-contained true - name: Produce build run: | cd TShockLauncher - dotnet publish -r ${{ matrix.arch }} -f net6.0 -c Release -p:PublishSingleFile=true --self-contained false + dotnet publish -r ${{ matrix.arch }} -f net9.0 -c Release -p:PublishSingleFile=true --self-contained false - name: Chmod scripts if: ${{ matrix.arch != 'win-x64' }} run: | - chmod +x TShockLauncher/bin/Release/net6.0/${{ matrix.arch }}/publish/TShock.Server + chmod +x TShockLauncher/bin/Release/net9.0/${{ matrix.arch }}/publish/TShock.Server - name: Copy installer run: | - cp TShockInstaller/bin/Release/net6.0/${{ matrix.arch }}/publish/* TShockLauncher/bin/Release/net6.0/${{ matrix.arch }}/publish/ + cp TShockInstaller/bin/Release/net9.0/${{ matrix.arch }}/publish/* TShockLauncher/bin/Release/net9.0/${{ matrix.arch }}/publish/ # preserve file perms: https://github.com/actions/upload-artifact#maintaining-file-permissions-and-case-sensitive-files - name: Tarball artifact (non-Windows) if: ${{ matrix.arch != 'win-x64' }} run: | - cd TShockLauncher/bin/Release/net6.0/${{ matrix.arch }}/publish/ + cd TShockLauncher/bin/Release/net9.0/${{ matrix.arch }}/publish/ tar -cvf ../../../../../../TShock-Beta-${{ matrix.arch }}-Release.tar * - name: Upload artifact (non-Windows) @@ -74,4 +74,4 @@ jobs: if: ${{ matrix.arch == 'win-x64' }} with: name: TShock-Beta-${{ matrix.arch }}-Release - path: TShockLauncher/bin/Release/net6.0/${{ matrix.arch }}/publish/ + path: TShockLauncher/bin/Release/net9.0/${{ matrix.arch }}/publish/ diff --git a/.vscode/launch.json b/.vscode/launch.json index a4795b3ae..78bc651ff 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -9,12 +9,12 @@ "type": "coreclr", "request": "launch", "preLaunchTask": "build", - "program": "${workspaceFolder}/TShockLauncher/bin/Debug/net6.0/TShock.Run.dll", + "program": "${workspaceFolder}/TShockLauncher/bin/Debug/net9.0/TShock.Run.dll", "windows": { - "program": "${workspaceFolder}/TShockLauncher/bin/Debug/net6.0/TShock.dll", + "program": "${workspaceFolder}/TShockLauncher/bin/Debug/net9.0/TShock.dll", }, "args": [], - "cwd": "${workspaceFolder}/TShockLauncher/bin/Debug/net6.0/", + "cwd": "${workspaceFolder}/TShockLauncher/bin/Debug/net9.0/", "console": "integratedTerminal", "stopAtEntry": false }, diff --git a/.vscode/tasks.json b/.vscode/tasks.json index e8db5b188..a90811166 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -35,7 +35,7 @@ { "label": "Remote Publish", "options": { - "cwd": "TShockLauncher/bin/Debug/net6.0/linux-arm64" + "cwd": "TShockLauncher/bin/Debug/net9.0/linux-arm64" }, "command": "C:\\Program Files\\PuTTY\\pscp.exe", "type": "process", diff --git a/Dockerfile b/Dockerfile index 87024fb9e..f9071c0b4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -27,7 +27,7 @@ RUN \ *) echo "Error: Unsupported platform ${TARGETPLATFORM}" && exit 1 \ ;; \ esac && \ - dotnet publish -o output/ -r "${ARCH}" -v m -f net6.0 -c Release -p:PublishSingleFile=true --self-contained false + dotnet publish -o output/ -r "${ARCH}" -v m -f net9.0 -c Release -p:PublishSingleFile=true --self-contained false # Runtime image FROM --platform=${TARGETPLATFORM} mcr.microsoft.com/dotnet/runtime:6.0 AS runner diff --git a/README.md b/README.md index 0369df531..bf738a077 100644 --- a/README.md +++ b/README.md @@ -32,9 +32,9 @@ If you want to run the `TShockLauncher` (which runs a server), run: To produce a packaged release (suitable for distribution), run: 1. `cd TShockLauncher` -1. `dotnet publish -r win-x64 -f net6.0 -c Release -p:PublishSingleFile=true --self-contained false` +1. `dotnet publish -r win-x64 -f net9.0 -c Release -p:PublishSingleFile=true --self-contained false` -Note that in this example, you'd be building for `win-x64`. You can build for `win-x64`, `osx-x64`, `linux-x64`, `linux-arm64`, `linux-arm`. Your release will be in the `TShockLauncher/bin/Release/net6.0/` folder under the architecture you specified. +Note that in this example, you'd be building for `win-x64`. You can build for `win-x64`, `osx-x64`, `linux-x64`, `linux-arm64`, `linux-arm`. Your release will be in the `TShockLauncher/bin/Release/net9.0/` folder under the architecture you specified. ### Working with Terraria diff --git a/README_cn.md b/README_cn.md index 65c5eba61..a31c9345e 100644 --- a/README_cn.md +++ b/README_cn.md @@ -30,9 +30,9 @@ TShock是为泰拉瑞亚服务器和社区开发的一个工具箱。这个工 如果要生成打包后的发行版,运行: 1. `cd TShockLauncher` -1. `dotnet publish -r win-x64 -f net6.0 -c Release -p:PublishSingleFile=true --self-contained false` +1. `dotnet publish -r win-x64 -f net9.0 -c Release -p:PublishSingleFile=true --self-contained false` -注意在这个例子中你将会生成`win-x64`架构的版本。你也可以生成`win-x64`、`osx-x64`、`linux-x64`、`linux-arm64`、`linux-arm`的版本。你可以在`TShockLauncher/bin/Release/net6.0/`文件夹下对应架构的文件夹里找到生成后的发行版。 +注意在这个例子中你将会生成`win-x64`架构的版本。你也可以生成`win-x64`、`osx-x64`、`linux-x64`、`linux-arm64`、`linux-arm`的版本。你可以在`TShockLauncher/bin/Release/net9.0/`文件夹下对应架构的文件夹里找到生成后的发行版。 ### 跟泰拉瑞亚本体代码交互 diff --git a/TShockAPI/TShockAPI.csproj b/TShockAPI/TShockAPI.csproj index 9da8cd085..30389bb4f 100644 --- a/TShockAPI/TShockAPI.csproj +++ b/TShockAPI/TShockAPI.csproj @@ -3,7 +3,7 @@ Library - net6.0 + net9.0 true True @@ -37,15 +37,15 @@ - + PreserveNewest true - + PreserveNewest true - + PreserveNewest true diff --git a/TShockPluginManager/Nuget.cs b/TShockPluginManager/Nuget.cs index 9fdefb6b1..4e22209be 100644 --- a/TShockPluginManager/Nuget.cs +++ b/TShockPluginManager/Nuget.cs @@ -53,7 +53,7 @@ public class Nugetter public Nugetter() { FrameworkReducer = new FrameworkReducer(); - NuGetFramework = NuGetFramework.ParseFolder("net6.0"); + NuGetFramework = NuGetFramework.ParseFolder("net9.0"); Settings = NuGet.Configuration.Settings.LoadDefaultSettings(root: null); PathContext = NuGetPathContext.Create(Settings); PackageSourceProvider = new PackageSourceProvider(Settings); diff --git a/TShockPluginManager/TShockPluginManager.csproj b/TShockPluginManager/TShockPluginManager.csproj index 1d53f320b..10dad2f97 100644 --- a/TShockPluginManager/TShockPluginManager.csproj +++ b/TShockPluginManager/TShockPluginManager.csproj @@ -1,7 +1,7 @@ - net6.0 + net9.0 enable enable diff --git a/appveyor.yml b/appveyor.yml index a96c0049f..7b71d778a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -9,5 +9,5 @@ build_script: dotnet test artifacts: -- path: ./TShockLauncher/bin/Debug/net6.0 +- path: ./TShockLauncher/bin/Debug/net9.0 name: TShockAVDebug From d404b5a64c3aa404d24b3a3ee2c00859c188b890 Mon Sep 17 00:00:00 2001 From: Luke Date: Sat, 11 Jan 2025 11:20:51 +1000 Subject: [PATCH 02/11] Update to OTAPI 3.2.4 --- TShockLauncher/TShockLauncher.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TShockLauncher/TShockLauncher.csproj b/TShockLauncher/TShockLauncher.csproj index 64d835ba7..80cd8bd55 100644 --- a/TShockLauncher/TShockLauncher.csproj +++ b/TShockLauncher/TShockLauncher.csproj @@ -32,11 +32,11 @@ - + - + PreserveNewest true From b08801e9a774fd3f2486a0c8aaeba89d6888d471 Mon Sep 17 00:00:00 2001 From: Luke Date: Sat, 11 Jan 2025 14:13:50 +1000 Subject: [PATCH 03/11] Update vscode launch profile --- .vscode/launch.json | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 78bc651ff..43386a5d1 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -9,10 +9,7 @@ "type": "coreclr", "request": "launch", "preLaunchTask": "build", - "program": "${workspaceFolder}/TShockLauncher/bin/Debug/net9.0/TShock.Run.dll", - "windows": { - "program": "${workspaceFolder}/TShockLauncher/bin/Debug/net9.0/TShock.dll", - }, + "program": "${workspaceFolder}/TShockLauncher/bin/Debug/net9.0/TShock.Server.dll", "args": [], "cwd": "${workspaceFolder}/TShockLauncher/bin/Debug/net9.0/", "console": "integratedTerminal", From d9de3c1fc00c443b6ca7b3bc0456ad3009d56763 Mon Sep 17 00:00:00 2001 From: Luke Date: Sat, 11 Jan 2025 14:14:04 +1000 Subject: [PATCH 04/11] Update installer runtime urls for net9 --- TShockInstaller/Program.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/TShockInstaller/Program.cs b/TShockInstaller/Program.cs index 03606b519..09ad8bf63 100644 --- a/TShockInstaller/Program.cs +++ b/TShockInstaller/Program.cs @@ -27,11 +27,11 @@ string? url = null; if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) - url = $"https://dotnetcli.azureedge.net/dotnet/Runtime/6.0.11/dotnet-runtime-6.0.11-osx-{arch}.tar.gz"; + url = $"https://dotnetcli.azureedge.net/dotnet/Runtime/9.0.0/dotnet-runtime-9.0.0-osx-{arch}.tar.gz"; else if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - url = $"https://dotnetcli.azureedge.net/dotnet/Runtime/6.0.11/dotnet-runtime-6.0.11-win-{arch}.zip"; + url = $"https://dotnetcli.azureedge.net/dotnet/Runtime/9.0.0/dotnet-runtime-9.0.0-win-{arch}.zip"; else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) - url = $"https://dotnetcli.azureedge.net/dotnet/Runtime/6.0.11/dotnet-runtime-6.0.11-linux-{arch}.tar.gz"; + url = $"https://dotnetcli.azureedge.net/dotnet/Runtime/9.0.0/dotnet-runtime-9.0.0-linux-{arch}.tar.gz"; if(url is null) { From 6a3e8c3d5df5db0cd8a0683100453f930a39d36c Mon Sep 17 00:00:00 2001 From: Luke Date: Sat, 11 Jan 2025 14:32:24 +1000 Subject: [PATCH 05/11] Improve launcher assembly resolution This addresses dev instances unable to resolve binaries, and types being requested by the plugin manager before the resolver is attached --- TShockLauncher/Program.cs | 23 +++++++++++------------ TShockLauncher/TShockLauncher.csproj | 8 +++++++- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/TShockLauncher/Program.cs b/TShockLauncher/Program.cs index 4a1393702..84ddedc17 100644 --- a/TShockLauncher/Program.cs +++ b/TShockLauncher/Program.cs @@ -27,22 +27,12 @@ You should have received a copy of the GNU General Public License */ using System.Reflection; -using TShockPluginManager; - -if (args.Length > 0 && args[0].ToLower() == "plugins") -{ - var items = args.ToList(); - items.RemoveAt(0); - await NugetCLI.Main(items); - return; -} - Dictionary _cache = new Dictionary(); System.Runtime.Loader.AssemblyLoadContext.Default.Resolving += Default_Resolving; -Start(); +await StartAsync(); /// /// Resolves a module from the ./bin folder, either with a .dll by preference or .exe @@ -53,6 +43,7 @@ You should have received a copy of the GNU General Public License if (_cache.TryGetValue(arg2.Name, out Assembly? asm) && asm is not null) return asm; var loc = Path.Combine(AppContext.BaseDirectory, "bin", arg2.Name + ".dll"); + if (File.Exists(loc)) asm = arg1.LoadFromAssemblyPath(loc); @@ -70,7 +61,15 @@ You should have received a copy of the GNU General Public License /// Initiates the TSAPI server. /// /// This method exists so that the resolver can attach before TSAPI needs its dependencies. -void Start() +async Task StartAsync() { + if (args.Length > 0 && args[0].ToLower() == "plugins") + { + var items = args.ToList(); + items.RemoveAt(0); + await TShockPluginManager.NugetCLI.Main(items); + return; + } + TerrariaApi.Server.Program.Main(args); } diff --git a/TShockLauncher/TShockLauncher.csproj b/TShockLauncher/TShockLauncher.csproj index 80cd8bd55..0e1c5b761 100644 --- a/TShockLauncher/TShockLauncher.csproj +++ b/TShockLauncher/TShockLauncher.csproj @@ -91,7 +91,13 @@ - + + + + + + + From 337f15c0efc40a7ea906e6a13d93f476fcc5c6b0 Mon Sep 17 00:00:00 2001 From: Luke Date: Sat, 11 Jan 2025 14:35:38 +1000 Subject: [PATCH 06/11] Remote reset patch and MM dep This is addressed in https://github.com/SignatureBeef/Open-Terraria-API/tree/24d30d37b3eb1f606c6616a357c91aa23626420a --- TShockAPI/TShock.cs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index bcd72aa36..054e31dfa 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -428,8 +428,6 @@ public override void Initialize() Hooks.AccountHooks.AccountDelete += OnAccountDelete; Hooks.AccountHooks.AccountCreate += OnAccountCreate; - On.Terraria.RemoteClient.Reset += RemoteClient_Reset; - GetDataHandlers.InitGetDataHandler(); Commands.InitCommands(); @@ -498,12 +496,6 @@ void SafeError(string message) } } - private static void RemoteClient_Reset(On.Terraria.RemoteClient.orig_Reset orig, RemoteClient client) - { - client.ClientUUID = null; - orig(client); - } - private static void OnAchievementInitializerLoad(ILContext il) { // Modify AchievementInitializer.Load to remove the Main.netMode == 2 check (occupies the first 4 IL instructions) From 90f1d49887d5338e0b87f80b0872e10530334df4 Mon Sep 17 00:00:00 2001 From: Luke Date: Sat, 11 Jan 2025 14:39:14 +1000 Subject: [PATCH 07/11] Replace AchievementInitializer MM IL with static hook --- TShockAPI/TShock.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/TShockAPI/TShock.cs b/TShockAPI/TShock.cs index 054e31dfa..2be5cfe7c 100644 --- a/TShockAPI/TShock.cs +++ b/TShockAPI/TShock.cs @@ -447,7 +447,7 @@ public override void Initialize() // Initialize the AchievementManager, which is normally only done on clients. Game._achievements = new AchievementManager(); - IL.Terraria.Initializers.AchievementInitializer.Load += OnAchievementInitializerLoad; + OTAPI.Hooks.Initializers.AchievementInitializerLoad += OnAchievementInitializerLoad; // Actually call AchievementInitializer.Load, which is also normally only done on clients. AchievementInitializer.Load(); @@ -496,11 +496,9 @@ void SafeError(string message) } } - private static void OnAchievementInitializerLoad(ILContext il) + private static void OnAchievementInitializerLoad(object sender, OTAPI.Hooks.Initializers.AchievementInitializerLoadEventArgs args) { - // Modify AchievementInitializer.Load to remove the Main.netMode == 2 check (occupies the first 4 IL instructions) - for (var i = 0; i < 4; i++) - il.Body.Instructions.RemoveAt(0); + args.ShouldLoad = true; } protected void CrashReporter_HeapshotRequesting(object sender, EventArgs e) @@ -524,7 +522,7 @@ protected override void Dispose(bool disposing) } SaveManager.Instance.Dispose(); - IL.Terraria.Initializers.AchievementInitializer.Load -= OnAchievementInitializerLoad; + OTAPI.Hooks.Initializers.AchievementInitializerLoad -= OnAchievementInitializerLoad; ModuleManager.Dispose(); From 756f3138dd4ed642eadba5d8db296009dcc28f6b Mon Sep 17 00:00:00 2001 From: Luke Date: Sat, 11 Jan 2025 14:43:05 +1000 Subject: [PATCH 08/11] Update workflows actions to @v4 and net9 --- .github/workflows/ci-otapi3-nuget.yml | 6 +++--- .github/workflows/ci-otapi3.yml | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci-otapi3-nuget.yml b/.github/workflows/ci-otapi3-nuget.yml index 04b03a951..7834ccf01 100644 --- a/.github/workflows/ci-otapi3-nuget.yml +++ b/.github/workflows/ci-otapi3-nuget.yml @@ -11,13 +11,13 @@ jobs: environment: release steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: 'recursive' - name: Setup .NET - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v4 with: - dotnet-version: 6.0.400 + dotnet-version: 9.0.x - name: Restore dependencies run: dotnet restore - name: Build diff --git a/.github/workflows/ci-otapi3.yml b/.github/workflows/ci-otapi3.yml index a0a4a07b6..f7e500370 100644 --- a/.github/workflows/ci-otapi3.yml +++ b/.github/workflows/ci-otapi3.yml @@ -7,13 +7,13 @@ jobs: runs-on: windows-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: 'recursive' - - uses: actions/setup-dotnet@v3 + - uses: actions/setup-dotnet@v4 with: - dotnet-version: '6.0.100' + dotnet-version: 9.0.x - name: Run tests run: dotnet test @@ -25,13 +25,13 @@ jobs: arch: ["win-x64", "osx-x64", "linux-x64", "linux-arm64", "linux-arm"] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: 'recursive' - - uses: actions/setup-dotnet@v3 + - uses: actions/setup-dotnet@v4 with: - dotnet-version: '6.0.100' + dotnet-version: 9.0.x - name: Install msgfmt run: sudo apt-get install -y gettext @@ -63,14 +63,14 @@ jobs: tar -cvf ../../../../../../TShock-Beta-${{ matrix.arch }}-Release.tar * - name: Upload artifact (non-Windows) - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: ${{ matrix.arch != 'win-x64' }} with: name: TShock-Beta-${{ matrix.arch }}-Release path: TShock-Beta-${{ matrix.arch }}-Release.tar - name: Upload artifact (Windows) - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 if: ${{ matrix.arch == 'win-x64' }} with: name: TShock-Beta-${{ matrix.arch }}-Release From 9b6a245c2c07d6d98eb5d6364534b8094a9f1dc2 Mon Sep 17 00:00:00 2001 From: Luke Date: Sat, 11 Jan 2025 14:44:50 +1000 Subject: [PATCH 09/11] Update dockerfile to use dotnet/sdk:9.0 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index f9071c0b4..4640b1689 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # TARGETPLATFORM and BUILDPLATFORM are automatically filled in by Docker buildx. # They should not be set in the global scope manually. -FROM --platform=${BUILDPLATFORM} mcr.microsoft.com/dotnet/sdk:6.0 AS builder +FROM --platform=${BUILDPLATFORM} mcr.microsoft.com/dotnet/sdk:9.0 AS builder # Copy build context WORKDIR /TShock From 0c4c7db52e5ec77a09c924b5d71ba4526a5e4f60 Mon Sep 17 00:00:00 2001 From: Luke Date: Sat, 11 Jan 2025 19:56:38 +1000 Subject: [PATCH 10/11] Update nuget packages --- TShockAPI/TShockAPI.csproj | 6 +++--- TShockLauncher.Tests/GroupTests.cs | 6 +++--- TShockLauncher.Tests/ServerInitTests.cs | 2 +- TShockLauncher.Tests/TShockLauncher.Tests.csproj | 13 ++++++++----- TShockLauncher/TShockLauncher.csproj | 6 +++--- TShockPluginManager/TShockPluginManager.csproj | 10 +++++----- 6 files changed, 23 insertions(+), 20 deletions(-) diff --git a/TShockAPI/TShockAPI.csproj b/TShockAPI/TShockAPI.csproj index 30389bb4f..41bc03ff8 100644 --- a/TShockAPI/TShockAPI.csproj +++ b/TShockAPI/TShockAPI.csproj @@ -33,9 +33,9 @@ - - - + + + diff --git a/TShockLauncher.Tests/GroupTests.cs b/TShockLauncher.Tests/GroupTests.cs index 5eff651fa..01a058ca9 100644 --- a/TShockLauncher.Tests/GroupTests.cs +++ b/TShockLauncher.Tests/GroupTests.cs @@ -21,17 +21,17 @@ public void TestPermissions() groups.AddPermissions("test", new() { "abc" }); var hasperm = groups.GetGroupByName("test").Permissions.Contains("abc"); - Assert.IsTrue(hasperm); + Assert.That(hasperm, Is.True); groups.DeletePermissions("test", new() { "abc" }); hasperm = groups.GetGroupByName("test").Permissions.Contains("abc"); - Assert.IsFalse(hasperm); + Assert.That(hasperm, Is.False); groups.DeleteGroup("test"); var g = groups.GetGroupByName("test"); - Assert.IsNull(g); + Assert.That(g, Is.Null); } } diff --git a/TShockLauncher.Tests/ServerInitTests.cs b/TShockLauncher.Tests/ServerInitTests.cs index dc5f67318..e0926c660 100644 --- a/TShockLauncher.Tests/ServerInitTests.cs +++ b/TShockLauncher.Tests/ServerInitTests.cs @@ -27,7 +27,7 @@ public void EnsureBoots() On.Terraria.Main.DedServ -= cb; - Assert.IsTrue(hit); + Assert.That(hit, Is.True); } } diff --git a/TShockLauncher.Tests/TShockLauncher.Tests.csproj b/TShockLauncher.Tests/TShockLauncher.Tests.csproj index e58ca178f..9be3968af 100644 --- a/TShockLauncher.Tests/TShockLauncher.Tests.csproj +++ b/TShockLauncher.Tests/TShockLauncher.Tests.csproj @@ -7,11 +7,14 @@ - - - - - + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/TShockLauncher/TShockLauncher.csproj b/TShockLauncher/TShockLauncher.csproj index 0e1c5b761..875e62876 100644 --- a/TShockLauncher/TShockLauncher.csproj +++ b/TShockLauncher/TShockLauncher.csproj @@ -30,10 +30,10 @@ - - + + - + diff --git a/TShockPluginManager/TShockPluginManager.csproj b/TShockPluginManager/TShockPluginManager.csproj index 10dad2f97..7ad2429f1 100644 --- a/TShockPluginManager/TShockPluginManager.csproj +++ b/TShockPluginManager/TShockPluginManager.csproj @@ -7,12 +7,12 @@ - - - + + + - - + + From 7ffb431550f6deb8b5d0b3000a9234740f170c67 Mon Sep 17 00:00:00 2001 From: Luke Date: Sat, 11 Jan 2025 20:00:23 +1000 Subject: [PATCH 11/11] Update server init test to static hook --- TShockLauncher.Tests/ServerInitTests.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/TShockLauncher.Tests/ServerInitTests.cs b/TShockLauncher.Tests/ServerInitTests.cs index e0926c660..2ab72bd11 100644 --- a/TShockLauncher.Tests/ServerInitTests.cs +++ b/TShockLauncher.Tests/ServerInitTests.cs @@ -14,18 +14,19 @@ public class ServerInitTests public void EnsureBoots() { var are = new AutoResetEvent(false); - On.Terraria.Main.hook_DedServ cb = (On.Terraria.Main.orig_DedServ orig, Terraria.Main instance) => + HookEvents.HookDelegate cb = (instance, args) => { + args.ContinueExecution = false; are.Set(); Debug.WriteLine("Server init process successful"); }; - On.Terraria.Main.DedServ += cb; + HookEvents.Terraria.Main.DedServ += cb; - new Thread(() => TerrariaApi.Server.Program.Main(new string[] { })).Start(); + new Thread(() => TerrariaApi.Server.Program.Main([])).Start(); var hit = are.WaitOne(TimeSpan.FromSeconds(10)); - On.Terraria.Main.DedServ -= cb; + HookEvents.Terraria.Main.DedServ -= cb; Assert.That(hit, Is.True); }