From 2dd097f78e13286b5ecb5adaf9b05db219434faf Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Wed, 13 Dec 2023 21:17:51 +0100 Subject: [PATCH] .NET 8 :soda: (#119) --- Launcher.props | 2 +- SS14.Launcher/Api/AuthApi.cs | 6 ---- SS14.Launcher/Models/Connector.cs | 2 +- SS14.Launcher/Utility/ZStd.cs | 54 +++++++++++++++---------------- download_net_runtime.py | 8 ++--- publish_linux.sh | 4 +-- publish_osx.sh | 4 +-- publish_windows.sh | 8 ++--- 8 files changed, 40 insertions(+), 48 deletions(-) diff --git a/Launcher.props b/Launcher.props index 520ff8cb..90d14426 100644 --- a/Launcher.props +++ b/Launcher.props @@ -7,7 +7,7 @@ 2. Download .NET runtime script. 3. Local dev SS14.Loader launching code. --> - net7.0 + net8.0 0.24.0 diff --git a/SS14.Launcher/Api/AuthApi.cs b/SS14.Launcher/Api/AuthApi.cs index 6a9a92a7..3b0dbdfd 100644 --- a/SS14.Launcher/Api/AuthApi.cs +++ b/SS14.Launcher/Api/AuthApi.cs @@ -406,10 +406,4 @@ public AuthApiException(string message) : base(message) public AuthApiException(string message, Exception inner) : base(message, inner) { } - - protected AuthApiException( - SerializationInfo info, - StreamingContext context) : base(info, context) - { - } } diff --git a/SS14.Launcher/Models/Connector.cs b/SS14.Launcher/Models/Connector.cs index a7b8470c..93eb93d2 100644 --- a/SS14.Launcher/Models/Connector.cs +++ b/SS14.Launcher/Models/Connector.cs @@ -601,7 +601,7 @@ private static async Task GetLoaderStartInfo() basePath = Path.GetFullPath(Path.Combine( LauncherPaths.DirLauncherInstall, "..", "..", "..", "..", - "SS14.Loader", "bin", "Debug", "net7.0")); + "SS14.Loader", "bin", "Debug", "net8.0")); } if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) diff --git a/SS14.Launcher/Utility/ZStd.cs b/SS14.Launcher/Utility/ZStd.cs index 1c21c53c..9813f7c3 100644 --- a/SS14.Launcher/Utility/ZStd.cs +++ b/SS14.Launcher/Utility/ZStd.cs @@ -175,12 +175,6 @@ public ZStdException(string message, Exception inner) : base(message, inner) { } - protected ZStdException( - SerializationInfo info, - StreamingContext context) : base(info, context) - { - } - public static unsafe ZStdException FromCode(nuint code) { return new ZStdException(Marshal.PtrToStringUTF8((IntPtr)ZSTD_getErrorName(code))!); @@ -291,30 +285,34 @@ public override async ValueTask ReadAsync( return 0; } - unsafe + var ret = DecompressChunk(this, buffer.Span); + if (ret > 0) + return (int)ret; + + } while (true); + + static unsafe nuint DecompressChunk(ZStdDecompressStream stream, Span buffer) + { + fixed (byte* inputPtr = stream._buffer) + fixed (byte* outputPtr = buffer) { - fixed (byte* inputPtr = _buffer) - fixed (byte* outputPtr = buffer.Span) - { - ZSTD_outBuffer outputBuf = default; - outputBuf.dst = outputPtr; - outputBuf.pos = 0; - outputBuf.size = (nuint)buffer.Length; - ZSTD_inBuffer inputBuf = default; - inputBuf.src = inputPtr; - inputBuf.pos = (nuint)_bufferPos; - inputBuf.size = (nuint)_bufferSize; - - var ret = ZSTD_decompressStream(_ctx, &outputBuf, &inputBuf); - - _bufferPos = (int)inputBuf.pos; - ZStdException.ThrowIfError(ret); - - if (outputBuf.pos > 0) - return (int)outputBuf.pos; - } + ZSTD_outBuffer outputBuf = default; + outputBuf.dst = outputPtr; + outputBuf.pos = 0; + outputBuf.size = (nuint)buffer.Length; + ZSTD_inBuffer inputBuf = default; + inputBuf.src = inputPtr; + inputBuf.pos = (nuint)stream._bufferPos; + inputBuf.size = (nuint)stream._bufferSize; + + var ret = ZSTD_decompressStream(stream._ctx, &outputBuf, &inputBuf); + + stream._bufferPos = (int)inputBuf.pos; + ZStdException.ThrowIfError(ret); + + return outputBuf.pos; } - } while (true); + } } public override long Seek(long offset, SeekOrigin origin) diff --git a/download_net_runtime.py b/download_net_runtime.py index 5317377f..3cc1ef8f 100755 --- a/download_net_runtime.py +++ b/download_net_runtime.py @@ -12,12 +12,12 @@ PLATFORM_LINUX = "linux" PLATFORM_MACOS = "mac" -DOTNET_RUNTIME_VERSION = "7.0.3" +DOTNET_RUNTIME_VERSION = "8.0.0" DOTNET_RUNTIME_DOWNLOADS = { - PLATFORM_LINUX: "https://download.visualstudio.microsoft.com/download/pr/2431d5ac-f5db-4bb1-bcf0-4a2d9725d4e4/1b0747add72af919754509f83ad08660/dotnet-runtime-7.0.3-linux-x64.tar.gz", - PLATFORM_WINDOWS: "https://download.visualstudio.microsoft.com/download/pr/e30129ab-4e46-42af-90a9-a5b597b06746/3e9993907f00eaba9da4a8d9ed168657/dotnet-runtime-7.0.3-win-x64.zip", - PLATFORM_MACOS: "https://download.visualstudio.microsoft.com/download/pr/c8f49e77-4d55-4a33-aa87-ddc034be61a2/77a50b1726446bee5a3a4dc6573568e2/dotnet-runtime-7.0.3-osx-x64.tar.gz" + PLATFORM_LINUX: "https://download.visualstudio.microsoft.com/download/pr/fc4b4447-45f2-4fd2-899a-77eb1aed7792/6fd52c0c61f064ddc7fe7684e841f491/dotnet-runtime-8.0.0-linux-x64.tar.gz", + PLATFORM_WINDOWS: "https://download.visualstudio.microsoft.com/download/pr/924f2e25-ba50-4b90-a35c-6ef73d1149a3/b9a57fa45dad7cca93a0aa937a8ba03d/dotnet-runtime-8.0.0-win-x64.zip", + PLATFORM_MACOS: "https://download.visualstudio.microsoft.com/download/pr/65e0ad28-b73d-46ab-b3ae-2d2ae4460b78/50ee103e816a255f9a5331bc2975a6ef/dotnet-runtime-8.0.0-osx-x64.tar.gz" } p = os.path.join diff --git a/publish_linux.sh b/publish_linux.sh index b4a7f815..7048a383 100755 --- a/publish_linux.sh +++ b/publish_linux.sh @@ -17,8 +17,8 @@ mkdir -p bin/publish/Linux/bin/loader mkdir -p bin/publish/Linux/dotnet cp PublishFiles/SS14.Launcher PublishFiles/SS14.desktop bin/publish/Linux/ -cp SS14.Launcher/bin/Release/net7.0/linux-x64/publish/* bin/publish/Linux/bin/ -cp SS14.Loader/bin/Release/net7.0/linux-x64/publish/* bin/publish/Linux/bin/loader +cp SS14.Launcher/bin/Release/net8.0/linux-x64/publish/* bin/publish/Linux/bin/ +cp SS14.Loader/bin/Release/net8.0/linux-x64/publish/* bin/publish/Linux/bin/loader cp -r Dependencies/dotnet/linux/* bin/publish/Linux/dotnet/ cd bin/publish/Linux diff --git a/publish_osx.sh b/publish_osx.sh index 01d3f509..f84cdb9e 100755 --- a/publish_osx.sh +++ b/publish_osx.sh @@ -21,8 +21,8 @@ mkdir -p "bin/publish/macOS/Space Station 14 Launcher.app/Contents/Resources/bin mkdir -p "bin/publish/macOS/Space Station 14 Launcher.app/Contents/Resources/bin/loader/Space Station 14.app/Contents/Resources/bin/" cp -r Dependencies/dotnet/mac/* "bin/publish/macOS/Space Station 14 Launcher.app/Contents/Resources/dotnet/" -cp -r SS14.Launcher/bin/Release/net7.0/osx-x64/publish/* "bin/publish/macOS/Space Station 14 Launcher.app/Contents/Resources/bin/" -cp -r SS14.Loader/bin/Release/net7.0/osx-x64/publish/* "bin/publish/macOS/Space Station 14 Launcher.app/Contents/Resources/bin/loader/Space Station 14.app/Contents/Resources/bin/" +cp -r SS14.Launcher/bin/Release/net8.0/osx-x64/publish/* "bin/publish/macOS/Space Station 14 Launcher.app/Contents/Resources/bin/" +cp -r SS14.Loader/bin/Release/net8.0/osx-x64/publish/* "bin/publish/macOS/Space Station 14 Launcher.app/Contents/Resources/bin/loader/Space Station 14.app/Contents/Resources/bin/" pushd bin/publish/macOS zip -r ../../../SS14.Launcher_macOS.zip * popd diff --git a/publish_windows.sh b/publish_windows.sh index 43a93d71..1937c2f1 100755 --- a/publish_windows.sh +++ b/publish_windows.sh @@ -12,8 +12,8 @@ dotnet publish SS14.Launcher/SS14.Launcher.csproj /p:FullRelease=True -c Release dotnet publish SS14.Loader/SS14.Loader.csproj -c Release --no-self-contained -r win-x64 /nologo dotnet publish SS14.Launcher.Bootstrap/SS14.Launcher.Bootstrap.csproj -c Release /nologo -./exe_set_subsystem.py "SS14.Launcher/bin/Release/net7.0/win-x64/publish/SS14.Launcher.exe" 2 -./exe_set_subsystem.py "SS14.Loader/bin/Release/net7.0/win-x64/publish/SS14.Loader.exe" 2 +./exe_set_subsystem.py "SS14.Launcher/bin/Release/net8.0/win-x64/publish/SS14.Launcher.exe" 2 +./exe_set_subsystem.py "SS14.Loader/bin/Release/net8.0/win-x64/publish/SS14.Loader.exe" 2 # Create intermediate directories. mkdir -p bin/publish/Windows/bin @@ -23,8 +23,8 @@ mkdir -p bin/publish/Windows/dotnet cp -r Dependencies/dotnet/windows/* bin/publish/Windows/dotnet cp "SS14.Launcher.Bootstrap/bin/Release/net45/publish/Space Station 14 Launcher.exe" bin/publish/Windows cp "SS14.Launcher.Bootstrap/console.bat" bin/publish/Windows -cp SS14.Launcher/bin/Release/net7.0/win-x64/publish/* bin/publish/Windows/bin -cp SS14.Loader/bin/Release/net7.0/win-x64/publish/* bin/publish/Windows/bin/loader +cp SS14.Launcher/bin/Release/net8.0/win-x64/publish/* bin/publish/Windows/bin +cp SS14.Loader/bin/Release/net8.0/win-x64/publish/* bin/publish/Windows/bin/loader pushd bin/publish/Windows zip -r ../../../SS14.Launcher_Windows.zip *