From fd6e7451d3dd739d9c052f1b3e22edf4fadbd8d8 Mon Sep 17 00:00:00 2001 From: Gleb Krasilich Date: Sun, 14 Nov 2021 21:09:32 +0300 Subject: [PATCH 01/32] Updated version to 1.0.0-alpha.1 --- version.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/version.json b/version.json index 3a4ad186..1635ec7a 100644 --- a/version.json +++ b/version.json @@ -1,4 +1,4 @@ { - "Version": "0.7.0-rc.1", - "Codename": "UstIlimsk" + "Version": "1.0.0-alpha.1", + "Codename": "Trubchevsk" } From 0b07ce428caa3220036f5724064d6090da83a3b5 Mon Sep 17 00:00:00 2001 From: Gleb Krasilich Date: Sun, 14 Nov 2021 22:15:39 +0300 Subject: [PATCH 02/32] Updated README to 0.7.0 release --- README.md | 58 +++++++++++++------------------------------------------ 1 file changed, 13 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index 49cb83b1..b7cfc1e0 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,8 @@ [![CI](https://github.com/GlebChili/GmodDotNet/workflows/CI/badge.svg?branch=master)](https://github.com/GlebChili/GmodDotNet/actions?query=workflow%3ACI) # Gmod.NET -[![Current Runtime](https://img.shields.io/badge/Current%20Runtime-0.6.0-2db94e)](https://github.com/GlebChili/GmodDotNet/wiki/GmodNET-Runtime-and-GmodNET.API-version-correspondence#gmodnet-and-gmodnetapi) [![Current API](https://img.shields.io/badge/Current%20API-0.6.0-2db94e)](https://github.com/GlebChili/GmodDotNet/wiki/GmodNET-Runtime-and-GmodNET.API-version-correspondence#gmodnet-and-gmodnetapi) -Cross-platform .NET Module/Plugin platform for Garry's Mod powered by [__.NET Core__](https://dotnet.microsoft.com/). +Cross-platform .NET Module/Plugin platform for Garry's Mod powered by [__.NET__](https://dotnet.microsoft.com/). ## About @@ -13,17 +12,13 @@ and other .NET languages which runs across all platforms (Windows, Linux, Mac Os). Gmod.NET allows you to develop cross-platform Garry's Mod extensions without need to close or reload your game or server. -## Similar projects - -Check out [gmod_csModuleLoader](https://github.com/dedady157/gmod_csModuleLoader) by [Bailey Drahoss](https://github.com/dedady157). - -## Current features - -GmodNET provides functionality to write Garry's Mod modules in C# or any other CIL-compiled language as [__.NET Core 3.1__](https://dotnet.microsoft.com/) class libraries. For more information on modules and API check out [project's wiki](https://github.com/GlebChili/GmodDotNet/wiki). Only `x86_64` version of Garry's Mod is currently supported. +Gmod.NET allows you to write Garry's Mod modules in C# or any other CIL-compiled language as [__.NET 6.0__](https://dotnet.microsoft.com/) class libraries. +For more information on modules and API check out [our documentation](https://docs.gmodnet.xyz/). +Only `x86_64` version of Garry's Mod is currently supported. ## Need help? -Check out our [wiki](https://github.com/GlebChili/GmodDotNet/wiki) or join our [discord server](https://discord.gg/9bP8nMT). +Check out [our docs](https://docs.gmodnet.xyz/) and join our [discord server](https://discord.gg/9bP8nMT). ## Building and contributing @@ -37,7 +32,7 @@ To build GmodDotNet you need to have following software installed and registered 3. Latest version of dotnet SDK -4. (On Windows) Latest version of Visual Studio 2019 with C++ package +4. (On Windows) Latest version of Visual Studio 2019 with C++ workload 5. (On macOS) Latest version of Xcode @@ -49,7 +44,7 @@ Build steps: 2. In the root of the cloned repository run `dotnet build runtime.csproj -c Debug` or `dotnet build runtime.csproj -c Release` instruction in your command prompt. -__NOTE__: `runtime.csproj` is not a real C# project file but a kind of build script. To work with the managed part of GmodDotNet open `gm_dotnet_managed/gm_dotnet_managed.sln` solution file in your IDE instead. +__NOTE__: `runtime.csproj` is not a real C# project file but a kind of build script. To work with the managed part of Gmod.NET open `gm_dotnet_managed/gm_dotnet_managed.sln` solution file in your IDE instead. `runtime.csproj` build script will produce following folders in the root of repository: @@ -59,22 +54,9 @@ __NOTE__: `runtime.csproj` is not a real C# project file but a kind of build scr 3. `nupkgs` folder contains `GmodNET.API` NuGet package. -You may also want to copy the content of `lua` folder to the corresponding destinations in `garrysmod/lua`. - -### Folder structure - -Gmod.NET is subdivided into three subprojects. - -Garry's Mod binary native module and helper libraries are -contained in `gm_dotnet_native` folder and organized as CMake project. - -Managed part is contained in `gm_dotnet_managed` folder and organized with .NET soultion file `gm_dotnet_managed.sln`. - -Bootstrap Lua scripts are contained in `lua` folder. - ### Nightly builds -You can find latest nightly builds GmodDotNet runtime at http://nightly.gmodnet.xyz/. To use nightly NuGet packages connect to [our nightly NuGet feed](https://dev.azure.com/GmodNET/gmodnet-artifacts/_packaging?_a=feed&feed=gmodnet-packages). +You can find latest nightly builds of Gmod.NET runtime at http://nightly.gmodnet.xyz/. To use our nightly NuGet packages connect to [our nightly NuGet feed](https://dev.azure.com/GmodNET/gmodnet-artifacts/_packaging?_a=feed&feed=gmodnet-packages). ## Installation and usage @@ -84,17 +66,13 @@ You can find latest nightly builds GmodDotNet runtime at http://nightly.gmodnet. 3. Create a `Modules` folder inside `garrysmod/lua/bin/`. -4. Download and copy `gm_dotnet_server.lua` to `garrysmod/lua/autorun/server` folder. - -5. Download and copy `gm_dotnet_client.lua` to `garrysmod/lua/autorun/client` folder. +4. Place your .NET module, ...deps.json file, and all dependencies in `Modules/%exact_name_of_the_module_without_dll%/` folder. -6. Place your .NET module, ...deps.json file, and all dependencies in `Modules/%exact_name_of_the_module_without_dll/` folder. +5. Load Gmod.NET runtime in game by executing Lua function `require("dotnet")`. -7. If you signed your module with [GmodNetModuleSigner](https://github.com/GlebChili/GmodNetModuleSigner), copy `[name_of_your_module].modulekey` and `[name_of_your_module].modulesign` to the same folder as above (`Modules/%exact_name_of_the_module_without_dll/`). +6. Load your module by running Lua function `dotnet.load("%exact_name_of_the_module_without_dll%")`. -8. If you want your module to be serverside (clientside) only then add file `TYPE` to `Modules/%exact_name_of_the_module_without_dll/` with content `server` (`client`). - -9. Use `gmod_net_load_all` (`gmod_net_load_all_cl` for client-side) console command to load all managed modules and `gmod_net_unload_all` (`gmod_net_unload_all_cl`) to unload them. Modules can be hot-reloaded, so one doesn't need to quit game to see changes. +For more info check out [our quick start guide](https://docs.gmodnet.xyz/articles/tutorials/hello-world/index.html). ## License @@ -102,14 +80,4 @@ Whole project is licensed under MIT License. ## Dependencies and code usage -Gmod.NET is making use of or borrows code from the following projects: - -1. [CoreCLR](https://github.com/dotnet/coreclr), [CoreFX](https://github.com/dotnet/corefx), and [core-setup](https://github.com/dotnet/core-setup) by [.NET Foundation](https://github.com/dotnet) (MIT License) - -2. [pure_lua_SHA](https://github.com/Egor-Skriptunoff/pure_lua_SHA) by [Egor Skriptunoff](https://github.com/Egor-Skriptunoff) (MIT License) - -3. [NSec](https://nsec.rocks/) by [Klaus Hartke](https://github.com/ektrah) (MIT License) - -4. [Libsodium](http://libsodium.org) by [Frank Denis](https://github.com/jedisct1) (ISC License) - -See other copyright notices in the NOTICE file. +See the NOTICE file. From 26fed1cd8c787abd9f35bcc2d07e46428dc0609e Mon Sep 17 00:00:00 2001 From: Gleb Krasilich Date: Thu, 25 Nov 2021 23:01:54 +0300 Subject: [PATCH 03/32] Updated dev tools --- .config/dotnet-tools.json | 2 +- gm_dotnet_managed/GmodNET.API/GmodNET.API.csproj | 4 ++-- gm_dotnet_managed/GmodNET/GmodNET.csproj | 4 ++-- gm_dotnet_managed/Tests/Tests.csproj | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 0ec66d33..b0c11982 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "gmodnet.versiontool": { - "version": "2.0.0", + "version": "2.1.0", "commands": [ "gmodnet-vt" ] diff --git a/gm_dotnet_managed/GmodNET.API/GmodNET.API.csproj b/gm_dotnet_managed/GmodNET.API/GmodNET.API.csproj index c0646440..48932499 100644 --- a/gm_dotnet_managed/GmodNET.API/GmodNET.API.csproj +++ b/gm_dotnet_managed/GmodNET.API/GmodNET.API.csproj @@ -26,10 +26,10 @@ - + all - + diff --git a/gm_dotnet_managed/GmodNET/GmodNET.csproj b/gm_dotnet_managed/GmodNET/GmodNET.csproj index e5ef28e3..9c5ddf7f 100644 --- a/gm_dotnet_managed/GmodNET/GmodNET.csproj +++ b/gm_dotnet_managed/GmodNET/GmodNET.csproj @@ -23,10 +23,10 @@ - + all - + diff --git a/gm_dotnet_managed/Tests/Tests.csproj b/gm_dotnet_managed/Tests/Tests.csproj index f20f5dcf..6714f19d 100644 --- a/gm_dotnet_managed/Tests/Tests.csproj +++ b/gm_dotnet_managed/Tests/Tests.csproj @@ -27,7 +27,7 @@ - + all From 36efef9fdb5d05552374897a5b8259633721892c Mon Sep 17 00:00:00 2001 From: Gleb Krasilich Date: Thu, 16 Dec 2021 22:12:21 +0300 Subject: [PATCH 04/32] Updated .NET Runtime --- global.json | 2 +- runtime.csproj | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/global.json b/global.json index 04702084..e52d340b 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "6.0.100" + "version": "6.0.101" } } diff --git a/runtime.csproj b/runtime.csproj index d4931796..d34255a6 100644 --- a/runtime.csproj +++ b/runtime.csproj @@ -4,18 +4,18 @@ net6.0 - 6.0.0 + 6.0.1 - https://download.visualstudio.microsoft.com/download/pr/3cc56ba5-399e-455a-9e36-3d384e1af246/92cc0b1f002350c18262a06f5a99bbc1/aspnetcore-runtime-6.0.0-win-x64.zip + https://download.visualstudio.microsoft.com/download/pr/820770c3-1a48-4a4f-bde3-792c925fee63/f44564603cc0592e4a3f33205a0273ba/aspnetcore-runtime-6.0.1-win-x64.zip - https://download.visualstudio.microsoft.com/download/pr/a8dd1c9d-1a47-4135-8ad8-7091ff6bbe1e/6af53c3eee71038248937daf4599f06a/aspnetcore-runtime-6.0.0-linux-x64.tar.gz + https://download.visualstudio.microsoft.com/download/pr/32230fb9-df1e-4b86-b009-12d889cbfa8a/f57a5d92327bb2936caac94bcf602c22/aspnetcore-runtime-6.0.1-linux-x64.tar.gz - https://download.visualstudio.microsoft.com/download/pr/27e5cf62-0d07-44cd-a057-425887434b9e/5f87e0c4d9be2151a2d0c9efc4530751/aspnetcore-runtime-6.0.0-osx-x64.tar.gz + https://download.visualstudio.microsoft.com/download/pr/0cd8b55e-7d7e-41c5-93f3-ebc7ffc18ddc/fd3c2698214d01e5b4b57d5d9b53b0e4/aspnetcore-runtime-6.0.1-osx-x64.tar.gz From 73cbd6d2018db81a65d5bc881f7caa3f4476a6f4 Mon Sep 17 00:00:00 2001 From: Gleb Krasilich Date: Sun, 9 Jan 2022 08:02:06 +0300 Subject: [PATCH 05/32] Use fixed runners OS version in CI (#120) --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 31ab98af..febd29b4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -127,7 +127,7 @@ jobs: windows-build: - runs-on: windows-latest + runs-on: windows-2019 steps: - name: Checkout @@ -234,7 +234,7 @@ jobs: mac-build: - runs-on: macos-latest + runs-on: macos-10.15 steps: @@ -294,7 +294,7 @@ jobs: trigger_autorebase: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 needs: [linux-build, windows-build, mac-build] From 885b85fa28fc491a7bb29b8ebfd8447a12f7a14d Mon Sep 17 00:00:00 2001 From: Gleb Krasilich Date: Fri, 11 Feb 2022 18:47:01 +0300 Subject: [PATCH 06/32] Update .NET to version 6.0.2 (#123) --- global.json | 2 +- runtime.csproj | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/global.json b/global.json index e52d340b..e0a11efb 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "6.0.101" + "version": "6.0.102" } } diff --git a/runtime.csproj b/runtime.csproj index d34255a6..53402467 100644 --- a/runtime.csproj +++ b/runtime.csproj @@ -4,18 +4,18 @@ net6.0 - 6.0.1 + 6.0.2 - https://download.visualstudio.microsoft.com/download/pr/820770c3-1a48-4a4f-bde3-792c925fee63/f44564603cc0592e4a3f33205a0273ba/aspnetcore-runtime-6.0.1-win-x64.zip + https://download.visualstudio.microsoft.com/download/pr/9f160a60-8393-4d8a-a05d-5b2276bb9b17/8bde8c2366c2afb86d30716064153b9f/aspnetcore-runtime-6.0.2-win-x64.zip - https://download.visualstudio.microsoft.com/download/pr/32230fb9-df1e-4b86-b009-12d889cbfa8a/f57a5d92327bb2936caac94bcf602c22/aspnetcore-runtime-6.0.1-linux-x64.tar.gz + https://download.visualstudio.microsoft.com/download/pr/26078483-7a4c-4113-8c39-eab5ee24f10f/3c2d24a5c71179af652cc92e8b57eb5f/aspnetcore-runtime-6.0.2-linux-x64.tar.gz - https://download.visualstudio.microsoft.com/download/pr/0cd8b55e-7d7e-41c5-93f3-ebc7ffc18ddc/fd3c2698214d01e5b4b57d5d9b53b0e4/aspnetcore-runtime-6.0.1-osx-x64.tar.gz + https://download.visualstudio.microsoft.com/download/pr/d4c3fc11-b8c5-4e5f-91e7-ee47be5737ca/35f7c55f53d8bb2e8f950b00078f57e4/aspnetcore-runtime-6.0.2-osx-x64.tar.gz From f441490081a05b090122607d7dfee08764342198 Mon Sep 17 00:00:00 2001 From: Gleb Krasilich Date: Sat, 19 Feb 2022 07:53:50 +0300 Subject: [PATCH 07/32] Update global.json SDK version to 6.0.200 --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index e0a11efb..572a2a6f 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "6.0.102" + "version": "6.0.200" } } From e982070fa562eb9a0fa297bafa99bba03319d9cb Mon Sep 17 00:00:00 2001 From: Gleb Krasilich Date: Sun, 13 Mar 2022 22:18:37 +0300 Subject: [PATCH 08/32] Update .NET to version 6.0.3 (#127) --- global.json | 2 +- runtime.csproj | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/global.json b/global.json index 572a2a6f..c009e93a 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "6.0.200" + "version": "6.0.201" } } diff --git a/runtime.csproj b/runtime.csproj index 53402467..971f6465 100644 --- a/runtime.csproj +++ b/runtime.csproj @@ -4,18 +4,18 @@ net6.0 - 6.0.2 + 6.0.3 - https://download.visualstudio.microsoft.com/download/pr/9f160a60-8393-4d8a-a05d-5b2276bb9b17/8bde8c2366c2afb86d30716064153b9f/aspnetcore-runtime-6.0.2-win-x64.zip + https://download.visualstudio.microsoft.com/download/pr/a6bebf66-144f-44a3-8b74-425466e3608d/07231c69bfd5c749d48dbea15c50545a/aspnetcore-runtime-6.0.3-win-x64.zip - https://download.visualstudio.microsoft.com/download/pr/26078483-7a4c-4113-8c39-eab5ee24f10f/3c2d24a5c71179af652cc92e8b57eb5f/aspnetcore-runtime-6.0.2-linux-x64.tar.gz + https://download.visualstudio.microsoft.com/download/pr/3af854b6-80fb-425a-972f-c7f0d693bf1b/cd458a4feae5a98646ee12a14ab34151/aspnetcore-runtime-6.0.3-linux-x64.tar.gz - https://download.visualstudio.microsoft.com/download/pr/d4c3fc11-b8c5-4e5f-91e7-ee47be5737ca/35f7c55f53d8bb2e8f950b00078f57e4/aspnetcore-runtime-6.0.2-osx-x64.tar.gz + https://download.visualstudio.microsoft.com/download/pr/2cfe2a02-dd59-4cb7-9788-76c620eaa0ff/dfd0d449289a042be9bc62e4466bf350/aspnetcore-runtime-6.0.3-osx-x64.tar.gz From 24bccac6fb36d635b5558caf39688f61be492a1e Mon Sep 17 00:00:00 2001 From: Gleb Krasilich Date: Sun, 17 Apr 2022 02:22:47 +0300 Subject: [PATCH 09/32] Updated .NET Runtime to version 6.0.4 (#130) --- global.json | 2 +- runtime.csproj | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/global.json b/global.json index c009e93a..07aaadfe 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "6.0.201" + "version": "6.0.202" } } diff --git a/runtime.csproj b/runtime.csproj index 971f6465..998e8302 100644 --- a/runtime.csproj +++ b/runtime.csproj @@ -4,18 +4,18 @@ net6.0 - 6.0.3 + 6.0.4 - https://download.visualstudio.microsoft.com/download/pr/a6bebf66-144f-44a3-8b74-425466e3608d/07231c69bfd5c749d48dbea15c50545a/aspnetcore-runtime-6.0.3-win-x64.zip + https://download.visualstudio.microsoft.com/download/pr/bfbc4558-f639-4209-a9bb-f3e9591a4e0b/696b30897550c521b07487b1ddbe67ab/aspnetcore-runtime-6.0.4-win-x64.zip - https://download.visualstudio.microsoft.com/download/pr/3af854b6-80fb-425a-972f-c7f0d693bf1b/cd458a4feae5a98646ee12a14ab34151/aspnetcore-runtime-6.0.3-linux-x64.tar.gz + https://download.visualstudio.microsoft.com/download/pr/de3f6658-5d5b-4986-aeb1-7efdf5818437/7df572051df15117a0f52be1b79e1823/aspnetcore-runtime-6.0.4-linux-x64.tar.gz - https://download.visualstudio.microsoft.com/download/pr/2cfe2a02-dd59-4cb7-9788-76c620eaa0ff/dfd0d449289a042be9bc62e4466bf350/aspnetcore-runtime-6.0.3-osx-x64.tar.gz + https://download.visualstudio.microsoft.com/download/pr/b39aa0b4-27e2-4fce-bf36-fb6d46f89e5e/6b8ca3b4c7026db460df1d49f5366f1b/aspnetcore-runtime-6.0.4-osx-x64.tar.gz From 47886760c50d03db73883d88b8656e31802d4772 Mon Sep 17 00:00:00 2001 From: Gleb Krasilich Date: Fri, 20 May 2022 20:26:59 +0300 Subject: [PATCH 10/32] Fixed a typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b7cfc1e0..a27253f0 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Cross-platform .NET Module/Plugin platform for Garry's Mod powered by [__.NET__] Gmod.NET is Garry's Mod Module/Plugin loader for C# and other .NET languages which runs across all platforms (Windows, -Linux, Mac Os). Gmod.NET allows you to develop cross-platform Garry's Mod extensions without +Linux, macOS). Gmod.NET allows you to develop cross-platform Garry's Mod extensions without need to close or reload your game or server. Gmod.NET allows you to write Garry's Mod modules in C# or any other CIL-compiled language as [__.NET 6.0__](https://dotnet.microsoft.com/) class libraries. From fd2752dab406ac2d03b82f549224e8e3c62c96af Mon Sep 17 00:00:00 2001 From: Gleb Krasilich Date: Sun, 29 May 2022 06:57:24 +0300 Subject: [PATCH 11/32] Ugrade to .NET 6.0.5 (#133) * Ugrade to .NET 6.0.5 * Fix macos link --- global.json | 2 +- runtime.csproj | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/global.json b/global.json index 07aaadfe..19c87f2a 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "6.0.202" + "version": "6.0.300" } } diff --git a/runtime.csproj b/runtime.csproj index 998e8302..45dae3ac 100644 --- a/runtime.csproj +++ b/runtime.csproj @@ -4,18 +4,18 @@ net6.0 - 6.0.4 + 6.0.5 - https://download.visualstudio.microsoft.com/download/pr/bfbc4558-f639-4209-a9bb-f3e9591a4e0b/696b30897550c521b07487b1ddbe67ab/aspnetcore-runtime-6.0.4-win-x64.zip + https://download.visualstudio.microsoft.com/download/pr/c0c10b6a-7f97-4853-afb5-44617d7cbbc4/5275bb79c31cc80cee795bb168d1f1a9/aspnetcore-runtime-6.0.5-win-x64.zip - https://download.visualstudio.microsoft.com/download/pr/de3f6658-5d5b-4986-aeb1-7efdf5818437/7df572051df15117a0f52be1b79e1823/aspnetcore-runtime-6.0.4-linux-x64.tar.gz + https://download.visualstudio.microsoft.com/download/pr/a0e9ceb8-04eb-4510-876c-795a6a123dda/6141e57558eddc2d4629c7c14c2c6fa1/aspnetcore-runtime-6.0.5-linux-x64.tar.gz - https://download.visualstudio.microsoft.com/download/pr/b39aa0b4-27e2-4fce-bf36-fb6d46f89e5e/6b8ca3b4c7026db460df1d49f5366f1b/aspnetcore-runtime-6.0.4-osx-x64.tar.gz + https://download.visualstudio.microsoft.com/download/pr/ec3ae29d-ea2a-44ec-8ef4-a114a0efc818/401eca540c50187f8da95c430099ea2e/aspnetcore-runtime-6.0.5-osx-x64.tar.gz From a078881ea117414d559bdafb0b86ae273e472aaf Mon Sep 17 00:00:00 2001 From: Gleb Krasilich Date: Mon, 20 Jun 2022 22:02:22 +0300 Subject: [PATCH 12/32] Update .NET to 6.0.6 (#136) --- global.json | 2 +- runtime.csproj | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/global.json b/global.json index 19c87f2a..2a1043b5 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "6.0.300" + "version": "6.0.301" } } diff --git a/runtime.csproj b/runtime.csproj index 45dae3ac..2adf94bd 100644 --- a/runtime.csproj +++ b/runtime.csproj @@ -4,18 +4,18 @@ net6.0 - 6.0.5 + 6.0.6 - https://download.visualstudio.microsoft.com/download/pr/c0c10b6a-7f97-4853-afb5-44617d7cbbc4/5275bb79c31cc80cee795bb168d1f1a9/aspnetcore-runtime-6.0.5-win-x64.zip + https://download.visualstudio.microsoft.com/download/pr/188ee779-2b6d-4cf0-b11e-e0514cad80b7/9558e992445f513e3b49ab2ef205c2d3/aspnetcore-runtime-6.0.6-win-x64.zip - https://download.visualstudio.microsoft.com/download/pr/a0e9ceb8-04eb-4510-876c-795a6a123dda/6141e57558eddc2d4629c7c14c2c6fa1/aspnetcore-runtime-6.0.5-linux-x64.tar.gz + https://download.visualstudio.microsoft.com/download/pr/afd5344f-a9e9-45f9-85b5-de4551c53736/c30996daa407f9bb540ebc5edfcf16fc/aspnetcore-runtime-6.0.6-linux-x64.tar.gz - https://download.visualstudio.microsoft.com/download/pr/ec3ae29d-ea2a-44ec-8ef4-a114a0efc818/401eca540c50187f8da95c430099ea2e/aspnetcore-runtime-6.0.5-osx-x64.tar.gz + https://download.visualstudio.microsoft.com/download/pr/0f5eb01e-6b46-4ef3-8c1c-7b99657a36df/7d4807a527cd5bc5a6a864f1fcd354e7/aspnetcore-runtime-6.0.6-osx-x64.tar.gz From 88d02af7745284aa972fe48e67a59564705a6650 Mon Sep 17 00:00:00 2001 From: Gleb Krasilich Date: Sat, 19 Nov 2022 17:49:53 +0300 Subject: [PATCH 13/32] [Experimental] Update to .NET 7 (#125) * Updated global.json and runtime.csproj to .NET 7 Preview 1 * Update managed part to .NET 7 * Updated .NET version to 7 preview 2 * Update .NET to 7.0.0 Preview 3 * Update to .NET 7 Preview 4 * Update to .NET 7.0.0 Preview 5 * Update to .NET 7 RTM * Update .NET header files --- global.json | 2 +- gm_dotnet_managed/GmodNET.API/GmodNET.API.csproj | 2 +- gm_dotnet_managed/GmodNET/GmodNET.csproj | 2 +- gm_dotnet_managed/Tests/Tests.csproj | 2 +- gm_dotnet_native/external_includes/netcore/hostfxr.h | 6 +++--- runtime.csproj | 10 +++++----- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/global.json b/global.json index 2a1043b5..70e3dcc5 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "6.0.301" + "version": "7.0.100" } } diff --git a/gm_dotnet_managed/GmodNET.API/GmodNET.API.csproj b/gm_dotnet_managed/GmodNET.API/GmodNET.API.csproj index 48932499..78c19640 100644 --- a/gm_dotnet_managed/GmodNET.API/GmodNET.API.csproj +++ b/gm_dotnet_managed/GmodNET.API/GmodNET.API.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 MIT GmodNET API GmodNET API library contains all necessary interfaces to write a GmodNET module. diff --git a/gm_dotnet_managed/GmodNET/GmodNET.csproj b/gm_dotnet_managed/GmodNET/GmodNET.csproj index 9c5ddf7f..0c7fc51e 100644 --- a/gm_dotnet_managed/GmodNET/GmodNET.csproj +++ b/gm_dotnet_managed/GmodNET/GmodNET.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + net7.0 GmodNET.BuidReq GmodNET managed module loader. MIT diff --git a/gm_dotnet_managed/Tests/Tests.csproj b/gm_dotnet_managed/Tests/Tests.csproj index 6714f19d..74f94255 100644 --- a/gm_dotnet_managed/Tests/Tests.csproj +++ b/gm_dotnet_managed/Tests/Tests.csproj @@ -1,7 +1,7 @@  - net6.0 + net7.0 diff --git a/gm_dotnet_native/external_includes/netcore/hostfxr.h b/gm_dotnet_native/external_includes/netcore/hostfxr.h index 49afae3d..591a8ebb 100644 --- a/gm_dotnet_native/external_includes/netcore/hostfxr.h +++ b/gm_dotnet_native/external_includes/netcore/hostfxr.h @@ -64,7 +64,7 @@ typedef void(HOSTFXR_CALLTYPE *hostfxr_error_writer_fn)(const char_t *message); // By default no callback is registered in which case the errors are written to stderr. // // Each call to the error writer is sort of like writing a single line (the EOL character is omitted). -// Multiple calls to the error writer may occure for one failure. +// Multiple calls to the error writer may occur for one failure. // // If the hostfxr invokes functions in hostpolicy as part of its operation, the error writer // will be propagated to hostpolicy for the duration of the call. This means that errors from @@ -314,10 +314,10 @@ struct hostfxr_dotnet_environment_info const char_t* hostfxr_commit_hash; size_t sdk_count; - const hostfxr_dotnet_environment_sdk_info* sdks; + const struct hostfxr_dotnet_environment_sdk_info* sdks; size_t framework_count; - const hostfxr_dotnet_environment_framework_info* frameworks; + const struct hostfxr_dotnet_environment_framework_info* frameworks; }; #endif //__HOSTFXR_H__ diff --git a/runtime.csproj b/runtime.csproj index 2adf94bd..0511ea43 100644 --- a/runtime.csproj +++ b/runtime.csproj @@ -2,20 +2,20 @@ - net6.0 + net7.0 - 6.0.6 + 7.0.0 - https://download.visualstudio.microsoft.com/download/pr/188ee779-2b6d-4cf0-b11e-e0514cad80b7/9558e992445f513e3b49ab2ef205c2d3/aspnetcore-runtime-6.0.6-win-x64.zip + https://download.visualstudio.microsoft.com/download/pr/e3c77b40-cb02-4f1a-845f-c8040de58a83/be6bba4cac270a11c2b9dbdeec0a3040/aspnetcore-runtime-7.0.0-win-x64.zip - https://download.visualstudio.microsoft.com/download/pr/afd5344f-a9e9-45f9-85b5-de4551c53736/c30996daa407f9bb540ebc5edfcf16fc/aspnetcore-runtime-6.0.6-linux-x64.tar.gz + https://download.visualstudio.microsoft.com/download/pr/4bbb4d31-70ba-4def-b747-4358be873982/3dbca5b64c2ffb88641c0e42bdeb297a/aspnetcore-runtime-7.0.0-linux-x64.tar.gz - https://download.visualstudio.microsoft.com/download/pr/0f5eb01e-6b46-4ef3-8c1c-7b99657a36df/7d4807a527cd5bc5a6a864f1fcd354e7/aspnetcore-runtime-6.0.6-osx-x64.tar.gz + https://download.visualstudio.microsoft.com/download/pr/5ea36935-090e-4ca4-841f-49371b408d9d/6e0c2c4721dabbb9a237d6b6ed17df75/aspnetcore-runtime-7.0.0-osx-x64.tar.gz From d47725468c0ada5c17709272be5e57cb41274dd7 Mon Sep 17 00:00:00 2001 From: Gleb Krasilich Date: Sat, 19 Nov 2022 18:00:59 +0300 Subject: [PATCH 14/32] Update DocFX version --- .github/workflows/azure-static-web-apps-nightly-docs.yml | 2 +- .github/workflows/deploy-production-docs-to-zure.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/azure-static-web-apps-nightly-docs.yml b/.github/workflows/azure-static-web-apps-nightly-docs.yml index b2a5396e..dc4a0f4e 100644 --- a/.github/workflows/azure-static-web-apps-nightly-docs.yml +++ b/.github/workflows/azure-static-web-apps-nightly-docs.yml @@ -14,7 +14,7 @@ jobs: name: Build Docs steps: - name: Install DocFX - run: choco install docfx --version=2.58.9 -y + run: choco install docfx --version=2.59.4 -y - name: Checkout branch if: github.event_name == 'push' diff --git a/.github/workflows/deploy-production-docs-to-zure.yml b/.github/workflows/deploy-production-docs-to-zure.yml index f3a460dc..c109773d 100644 --- a/.github/workflows/deploy-production-docs-to-zure.yml +++ b/.github/workflows/deploy-production-docs-to-zure.yml @@ -9,7 +9,7 @@ jobs: name: Build Docs steps: - name: Install DocFX - run: choco install docfx --version=2.58.9 -y + run: choco install docfx --version=2.59.4 -y - name: Checkout uses: actions/checkout@v2.3.4 From 2d267cd83e5a7efdf09fb73920eee819cd69fb81 Mon Sep 17 00:00:00 2001 From: Gleb Krasilich Date: Sat, 19 Nov 2022 18:23:05 +0300 Subject: [PATCH 15/32] Update .NET version mentions in docs --- .../articles/overview/core_concepts/core_concepts.md | 2 +- .../articles/tutorials/hello-world-detailed/index.md | 2 +- docfx_project/articles/tutorials/hello-world/index.md | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/docfx_project/articles/overview/core_concepts/core_concepts.md b/docfx_project/articles/overview/core_concepts/core_concepts.md index a1bc3a4c..e0cfbf87 100644 --- a/docfx_project/articles/overview/core_concepts/core_concepts.md +++ b/docfx_project/articles/overview/core_concepts/core_concepts.md @@ -5,7 +5,7 @@ title: "Core Concepts" # Core Concepts -Gmod.NET modules are essentially .NET (currently version 6.0) class libraries which reference [GmodNET.API nuget package](https://www.nuget.org/packages/GmodNET.API/) as their dependency. +Gmod.NET modules are essentially .NET (currently version 7.0) class libraries which reference [GmodNET.API nuget package](https://www.nuget.org/packages/GmodNET.API/) as their dependency. Each module should contain one or more implementation of [GmodNET.API.IModule](xref:GmodNET.API.IModule) interface. Gmod.NET runtime will instantiate each class derived from `IModule` by calling its parameterless constructor. diff --git a/docfx_project/articles/tutorials/hello-world-detailed/index.md b/docfx_project/articles/tutorials/hello-world-detailed/index.md index 517f2b84..0aff854f 100644 --- a/docfx_project/articles/tutorials/hello-world-detailed/index.md +++ b/docfx_project/articles/tutorials/hello-world-detailed/index.md @@ -4,7 +4,7 @@ title: "A comprehensive introduction to Visual Studio, C# and the 'Hello World' --- > [!WARNING] -> This article was written for an earlier version of Gmod.NET. In order to use the latest version of Gmod.NET you need to have **.NET 6** instead of **.NET 5** and **Visual Studio 2022** instead of **Visual Studio 2019**. +> This article was written for an earlier version of Gmod.NET. In order to use the latest version of Gmod.NET you need to have **.NET 7** instead of **.NET 5** and **Visual Studio 2022** instead of **Visual Studio 2019**. # A comprehensive introduction to Visual Studio, C# and the Hello World code At the end of this tutorial you will have created and installed your own module that simply states: 'Hello World!' in the console. We will write a bit of C# (pronounce C-Sharp) code and learn about the basics of C# with regards to Gmod.NET module making. diff --git a/docfx_project/articles/tutorials/hello-world/index.md b/docfx_project/articles/tutorials/hello-world/index.md index 76b7cc95..61295c7c 100644 --- a/docfx_project/articles/tutorials/hello-world/index.md +++ b/docfx_project/articles/tutorials/hello-world/index.md @@ -3,6 +3,9 @@ uid: tutorial_hello_world title: "A quick start with 'Hello World'" --- +> [!WARNING] +> This article was written for an earlier version of Gmod.NET. In order to use the latest version of Gmod.NET you need to have **.NET 7** instead of **.NET 6**. + # A quick start with 'Hello World' At the end of this tutorial you will have created and installed your own module that simply states: 'Hello World!' in the console. We will write our module using a bit of C# (pronounce C-Sharp) code. @@ -16,7 +19,7 @@ At the end of this tutorial you will have created and installed your own module * .NET SDK * NuGet Package manager * C# and Visual Basic - * .NET 6.0 Runtime + * .NET 7.0 Runtime * Windows 10 or newer. * An internet connection * A copy of [Garry's Mod installed through Steam](https://store.steampowered.com/app/4000/garrys_mod) From f666864751a66d1607340dc3617cb8ac6afcdf0a Mon Sep 17 00:00:00 2001 From: Gleb Krasilich Date: Sun, 15 Jan 2023 03:33:09 +0300 Subject: [PATCH 16/32] Update .NET to version 7.0.2 --- global.json | 2 +- runtime.csproj | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/global.json b/global.json index 70e3dcc5..9b920806 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "7.0.100" + "version": "7.0.102" } } diff --git a/runtime.csproj b/runtime.csproj index 0511ea43..f645661b 100644 --- a/runtime.csproj +++ b/runtime.csproj @@ -4,18 +4,18 @@ net7.0 - 7.0.0 + 7.0.2 - https://download.visualstudio.microsoft.com/download/pr/e3c77b40-cb02-4f1a-845f-c8040de58a83/be6bba4cac270a11c2b9dbdeec0a3040/aspnetcore-runtime-7.0.0-win-x64.zip + https://download.visualstudio.microsoft.com/download/pr/79dbfb6e-78b4-4e2c-a3a9-040666d6b407/ad24076fc19fdfa6c7acdd6bad8a1fc5/aspnetcore-runtime-7.0.2-win-x64.zip - https://download.visualstudio.microsoft.com/download/pr/4bbb4d31-70ba-4def-b747-4358be873982/3dbca5b64c2ffb88641c0e42bdeb297a/aspnetcore-runtime-7.0.0-linux-x64.tar.gz + https://download.visualstudio.microsoft.com/download/pr/1d8c4b4c-aec9-451b-9bd3-bf7cdbd28477/def6c1a7a9cfd4590698d4f338da2803/aspnetcore-runtime-7.0.2-linux-x64.tar.gz - https://download.visualstudio.microsoft.com/download/pr/5ea36935-090e-4ca4-841f-49371b408d9d/6e0c2c4721dabbb9a237d6b6ed17df75/aspnetcore-runtime-7.0.0-osx-x64.tar.gz + https://download.visualstudio.microsoft.com/download/pr/035d61f7-0418-4834-8364-eec4d3c3d112/b1fd356e10f14ee2c930e023654186f3/aspnetcore-runtime-7.0.2-osx-x64.tar.gz From 106ce53020360c7939ec26bc467d166fe1ebce5b Mon Sep 17 00:00:00 2001 From: Gleb Krasilich Date: Sun, 15 Jan 2023 04:00:46 +0300 Subject: [PATCH 17/32] Use docfx 2.60 --- .../azure-static-web-apps-nightly-docs.yml | 30 +++++++------------ 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/.github/workflows/azure-static-web-apps-nightly-docs.yml b/.github/workflows/azure-static-web-apps-nightly-docs.yml index dc4a0f4e..9ed001b3 100644 --- a/.github/workflows/azure-static-web-apps-nightly-docs.yml +++ b/.github/workflows/azure-static-web-apps-nightly-docs.yml @@ -10,12 +10,9 @@ on: jobs: build_docs: if: (github.event_name == 'push' || (github.event_name == 'pull_request_target' && github.event.action != 'closed' && github.event.action != 'unlabeled' && contains(github.event.pull_request.labels.*.name, 'pr-generate-docs-preview'))) && github.repository_owner == 'GmodNET' - runs-on: windows-latest + runs-on: ubuntu-latest name: Build Docs steps: - - name: Install DocFX - run: choco install docfx --version=2.59.4 -y - - name: Checkout branch if: github.event_name == 'push' uses: actions/checkout@v2.3.4 @@ -28,14 +25,20 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Install .NET SDK - uses: actions/setup-dotnet@v1.8.1 + - name: Setup .NET Core SDK + uses: actions/setup-dotnet@v3.0.3 + with: + dotnet-version: 6.0.x + global-json-file: "./global.json" + + - name: Install DocFX + run: dotnet tool update -g docfx - name: Build docs with DocFX shell: pwsh run: | $env:GITHUB_ACTIONS='false' - docfx .\docfx_project\docfx.json + docfx ./docfx_project/docfx.json - name: Upload docs as artifact uses: actions/upload-artifact@v2.2.4 @@ -43,17 +46,6 @@ jobs: name: site path: docfx_project/_site/ - deploy_docs: - needs: build_docs - runs-on: ubuntu-latest - name: Deploy Docs - steps: - - name: Dowload docs build - uses: actions/download-artifact@v2.0.10 - with: - name: site - path: site - - name: Deploy docs uses: Azure/static-web-apps-deploy@v1 with: @@ -62,7 +54,7 @@ jobs: action: "upload" ###### Repository/Build Configurations - These values can be configured to match your app requirements. ###### # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig - app_location: "./site" # App source code path + app_location: "./docfx_project/_site/" # App source code path api_location: "" # Api source code path - optional output_location: "" # Built app content directory - optional skip_app_build: true From a61c7d1d6c5e42ecc3097a274490bf5ff0c720d8 Mon Sep 17 00:00:00 2001 From: Gleb Krasilich Date: Sun, 15 Jan 2023 05:15:19 +0300 Subject: [PATCH 18/32] Fix for cref error of docfx --- docfx_project/docfx.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docfx_project/docfx.json b/docfx_project/docfx.json index 6f364ded..933f0994 100644 --- a/docfx_project/docfx.json +++ b/docfx_project/docfx.json @@ -83,6 +83,7 @@ "disableGitFeatures": false, "xrefService": [ "https://xref.docs.microsoft.com/query?uid={uid}" - ] + ], + "repositoryRoot": "../" } } \ No newline at end of file From d73bba043ca0a633d41ce91e7b48ce6348235e7f Mon Sep 17 00:00:00 2001 From: Gleb Krasilich Date: Sun, 15 Jan 2023 05:21:25 +0300 Subject: [PATCH 19/32] Another fix for previous commit --- .github/workflows/azure-static-web-apps-nightly-docs.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/azure-static-web-apps-nightly-docs.yml b/.github/workflows/azure-static-web-apps-nightly-docs.yml index 9ed001b3..137ab9ab 100644 --- a/.github/workflows/azure-static-web-apps-nightly-docs.yml +++ b/.github/workflows/azure-static-web-apps-nightly-docs.yml @@ -34,6 +34,9 @@ jobs: - name: Install DocFX run: dotnet tool update -g docfx + - name: Build Gmod.NET solution + run: dotnet build runtime.csproj -c Release + - name: Build docs with DocFX shell: pwsh run: | From 94a9bc63759b2d88a537a6bca5dd39c8775e3ace Mon Sep 17 00:00:00 2001 From: Gleb Krasilich Date: Sun, 15 Jan 2023 19:52:02 +0300 Subject: [PATCH 20/32] Revert "Another fix for previous commit" This reverts commit d73bba043ca0a633d41ce91e7b48ce6348235e7f. --- .github/workflows/azure-static-web-apps-nightly-docs.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/azure-static-web-apps-nightly-docs.yml b/.github/workflows/azure-static-web-apps-nightly-docs.yml index 137ab9ab..9ed001b3 100644 --- a/.github/workflows/azure-static-web-apps-nightly-docs.yml +++ b/.github/workflows/azure-static-web-apps-nightly-docs.yml @@ -34,9 +34,6 @@ jobs: - name: Install DocFX run: dotnet tool update -g docfx - - name: Build Gmod.NET solution - run: dotnet build runtime.csproj -c Release - - name: Build docs with DocFX shell: pwsh run: | From 7fab0abbd55b2c16eecd15866fcfa8ee34344eb9 Mon Sep 17 00:00:00 2001 From: Gleb Krasilich Date: Sun, 15 Jan 2023 19:52:09 +0300 Subject: [PATCH 21/32] Revert "Fix for cref error of docfx" This reverts commit a61c7d1d6c5e42ecc3097a274490bf5ff0c720d8. --- docfx_project/docfx.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docfx_project/docfx.json b/docfx_project/docfx.json index 933f0994..6f364ded 100644 --- a/docfx_project/docfx.json +++ b/docfx_project/docfx.json @@ -83,7 +83,6 @@ "disableGitFeatures": false, "xrefService": [ "https://xref.docs.microsoft.com/query?uid={uid}" - ], - "repositoryRoot": "../" + ] } } \ No newline at end of file From 25c9aebe25f740bcfa5ea2b36a905a63319dd2cd Mon Sep 17 00:00:00 2001 From: Gleb Krasilich Date: Wed, 18 Jan 2023 22:44:01 +0300 Subject: [PATCH 22/32] DocFX is now local tool and should work without warnings in GitHub Actions --- .config/dotnet-tools.json | 6 ++++++ .github/workflows/azure-static-web-apps-nightly-docs.yml | 9 ++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index b0c11982..d4ed8435 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -13,6 +13,12 @@ "commands": [ "dotnet-script" ] + }, + "docfx": { + "version": "2.60.1", + "commands": [ + "docfx" + ] } } } \ No newline at end of file diff --git a/.github/workflows/azure-static-web-apps-nightly-docs.yml b/.github/workflows/azure-static-web-apps-nightly-docs.yml index 9ed001b3..88c82d03 100644 --- a/.github/workflows/azure-static-web-apps-nightly-docs.yml +++ b/.github/workflows/azure-static-web-apps-nightly-docs.yml @@ -25,20 +25,19 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Setup .NET Core SDK + - name: Setup .NET SDK uses: actions/setup-dotnet@v3.0.3 with: - dotnet-version: 6.0.x global-json-file: "./global.json" - - name: Install DocFX - run: dotnet tool update -g docfx + - name: Restore dotnet tools + run: dotnet tool restore - name: Build docs with DocFX shell: pwsh run: | $env:GITHUB_ACTIONS='false' - docfx ./docfx_project/docfx.json + dotnet docfx ./docfx_project/docfx.json - name: Upload docs as artifact uses: actions/upload-artifact@v2.2.4 From 7dbc5d072e7e2866092cf661847d0c2fa6f11f0f Mon Sep 17 00:00:00 2001 From: Gleb Krasilich Date: Wed, 18 Jan 2023 22:51:43 +0300 Subject: [PATCH 23/32] Force DocFX to use latest .NET runtime --- .github/workflows/azure-static-web-apps-nightly-docs.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/azure-static-web-apps-nightly-docs.yml b/.github/workflows/azure-static-web-apps-nightly-docs.yml index 88c82d03..bd2c16c6 100644 --- a/.github/workflows/azure-static-web-apps-nightly-docs.yml +++ b/.github/workflows/azure-static-web-apps-nightly-docs.yml @@ -33,10 +33,12 @@ jobs: - name: Restore dotnet tools run: dotnet tool restore + # We force DocFX to use latest runtime (and latest SDK) by setting DOTNET_ROLL_FORWARD='LatestMajor' env var - name: Build docs with DocFX shell: pwsh run: | $env:GITHUB_ACTIONS='false' + $env:DOTNET_ROLL_FORWARD='LatestMajor' dotnet docfx ./docfx_project/docfx.json - name: Upload docs as artifact From c7429ed38aa722684c701f2fc8029200e7156b8d Mon Sep 17 00:00:00 2001 From: Gleb Krasilich Date: Wed, 18 Jan 2023 23:19:54 +0300 Subject: [PATCH 24/32] Update deploy-production-docs-to-zure.yml --- .../deploy-production-docs-to-zure.yml | 35 ++++++++----------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/.github/workflows/deploy-production-docs-to-zure.yml b/.github/workflows/deploy-production-docs-to-zure.yml index c109773d..a772ca00 100644 --- a/.github/workflows/deploy-production-docs-to-zure.yml +++ b/.github/workflows/deploy-production-docs-to-zure.yml @@ -4,24 +4,28 @@ on: workflow_dispatch: jobs: - build_docs: - runs-on: windows-latest - name: Build Docs + build_and_deploy_docs: + runs-on: ubuntu-latest + name: Build and deploy docs steps: - - name: Install DocFX - run: choco install docfx --version=2.59.4 -y - - name: Checkout uses: actions/checkout@v2.3.4 - - name: Install .NET SDK - uses: actions/setup-dotnet@v1.8.1 + - name: Setup .NET SDK + uses: actions/setup-dotnet@v3.0.3 + with: + global-json-file: "./global.json" + - name: Restore dotnet tools + run: dotnet tool restore + + # We force DocFX to use latest runtime (and latest SDK) by setting DOTNET_ROLL_FORWARD='LatestMajor' env var - name: Build docs with DocFX shell: pwsh run: | $env:GITHUB_ACTIONS='false' - docfx .\docfx_project\docfx.json + $env:DOTNET_ROLL_FORWARD='LatestMajor' + dotnet docfx ./docfx_project/docfx.json - name: Upload docs as artifact uses: actions/upload-artifact@v2.2.4 @@ -29,17 +33,6 @@ jobs: name: site path: docfx_project/_site/ - deploy_docs: - needs: build_docs - runs-on: ubuntu-latest - name: Deploy Docs - steps: - - name: Dowload docs build - uses: actions/download-artifact@v2.0.10 - with: - name: site - path: site - - name: Deploy docs uses: Azure/static-web-apps-deploy@v1 with: @@ -48,7 +41,7 @@ jobs: action: "upload" ###### Repository/Build Configurations - These values can be configured to match your app requirements. ###### # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig - app_location: "./site" # App source code path + app_location: "./docfx_project/_site/" # App source code path api_location: "" # Api source code path - optional output_location: "" # Built app content directory - optional skip_app_build: true From 71779544a1dc56a5b6122a981705bf329298f803 Mon Sep 17 00:00:00 2001 From: Gleb Krasilich Date: Wed, 18 Jan 2023 23:23:32 +0300 Subject: [PATCH 25/32] Update azure-static-web-apps-nightly-docs.yml --- .github/workflows/azure-static-web-apps-nightly-docs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/azure-static-web-apps-nightly-docs.yml b/.github/workflows/azure-static-web-apps-nightly-docs.yml index bd2c16c6..f4dcb842 100644 --- a/.github/workflows/azure-static-web-apps-nightly-docs.yml +++ b/.github/workflows/azure-static-web-apps-nightly-docs.yml @@ -8,10 +8,10 @@ on: types: [opened, synchronize, reopened, closed, labeled, unlabeled] jobs: - build_docs: + build_and_deploy_docs: if: (github.event_name == 'push' || (github.event_name == 'pull_request_target' && github.event.action != 'closed' && github.event.action != 'unlabeled' && contains(github.event.pull_request.labels.*.name, 'pr-generate-docs-preview'))) && github.repository_owner == 'GmodNET' runs-on: ubuntu-latest - name: Build Docs + name: Build and Deploy Nightly Docs steps: - name: Checkout branch if: github.event_name == 'push' From 4f6b084c7a1660a441e6805bd5b3775f57a06c80 Mon Sep 17 00:00:00 2001 From: Gleb Krasilich Date: Tue, 24 Jan 2023 02:04:30 +0300 Subject: [PATCH 26/32] Update DocFX to 2.60.2 --- .config/dotnet-tools.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index d4ed8435..f2b0876f 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -15,7 +15,7 @@ ] }, "docfx": { - "version": "2.60.1", + "version": "2.60.2", "commands": [ "docfx" ] From 7f118d64e6a6a708d2ca92fdf149bdd5319f857a Mon Sep 17 00:00:00 2001 From: Gleb Krasilich Date: Tue, 24 Jan 2023 04:46:41 +0300 Subject: [PATCH 27/32] Retarget GmodNET.API to net6.0 tfm (#140) --- gm_dotnet_managed/GmodNET.API/GmodNET.API.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gm_dotnet_managed/GmodNET.API/GmodNET.API.csproj b/gm_dotnet_managed/GmodNET.API/GmodNET.API.csproj index 78c19640..48932499 100644 --- a/gm_dotnet_managed/GmodNET.API/GmodNET.API.csproj +++ b/gm_dotnet_managed/GmodNET.API/GmodNET.API.csproj @@ -1,7 +1,7 @@  - net7.0 + net6.0 MIT GmodNET API GmodNET API library contains all necessary interfaces to write a GmodNET module. From a3708b6a1893c3c30791814403a255f4f1e0d636 Mon Sep 17 00:00:00 2001 From: Gleb Krasilich Date: Wed, 25 Jan 2023 07:37:54 +0300 Subject: [PATCH 28/32] Null annotations and `in string` args (#142) * Deleted `in` arg modifiers from GmodNET.API * Removed `in` arg modifiers form the core GmodNET runtime * Enabled nullable annotations for GmodNET.API * Enabled nullable annotations in GmodNET core * Update Startup.cs --- .../GmodNET.API/GmodNET.API.csproj | 2 + gm_dotnet_managed/GmodNET.API/ILua.cs | 28 +- .../GmodNET.API/ModuleAssemblyLoadContext.cs | 2 +- .../GmodNET/GameConsoleWriter.cs | 18 +- gm_dotnet_managed/GmodNET/GloabalContext.cs | 11 +- gm_dotnet_managed/GmodNET/GmodNET.csproj | 2 + .../GmodNetModuleAssemblyLoadContext.cs | 16 +- gm_dotnet_managed/GmodNET/Lua.cs | 280 +++++++++++++++++- gm_dotnet_managed/GmodNET/LuaInterop.cs | 125 ++++---- .../GmodNET/ManagedFunctionMetaMethods.cs | 7 +- gm_dotnet_managed/GmodNET/RuntimeServices.cs | 2 +- gm_dotnet_managed/GmodNET/Startup.cs | 17 +- 12 files changed, 405 insertions(+), 105 deletions(-) diff --git a/gm_dotnet_managed/GmodNET.API/GmodNET.API.csproj b/gm_dotnet_managed/GmodNET.API/GmodNET.API.csproj index 48932499..d446bec2 100644 --- a/gm_dotnet_managed/GmodNET.API/GmodNET.API.csproj +++ b/gm_dotnet_managed/GmodNET.API/GmodNET.API.csproj @@ -2,6 +2,8 @@ net6.0 + enable + Nullable MIT GmodNET API GmodNET API library contains all necessary interfaces to write a GmodNET module. diff --git a/gm_dotnet_managed/GmodNET.API/ILua.cs b/gm_dotnet_managed/GmodNET.API/ILua.cs index 4a6a1b15..b34afe40 100644 --- a/gm_dotnet_managed/GmodNET.API/ILua.cs +++ b/gm_dotnet_managed/GmodNET.API/ILua.cs @@ -61,8 +61,8 @@ public interface ILua /// } /// /// - /// - public void GetField(int iStackPos, in string key); + /// + public void GetField(int iStackPos, string key); /// /// Does a table key-value assignment t[k] = v, @@ -102,8 +102,8 @@ public interface ILua /// } /// /// - /// - public void SetField(int iStackPos, in string key); + /// + public void SetField(int iStackPos, string key); /// /// Creates a new table and pushes it to the top of the stack. @@ -375,7 +375,7 @@ public interface ILua /// See lua_pushstring function in the Lua manual: https://www.lua.org/manual/5.1/manual.html /// /// A string to push. - public void PushString(in string str); + public void PushString(string str); /// /// Pushes a given double-precision number to the Lua stack. @@ -593,7 +593,7 @@ public interface ILua /// Creates a new Lua type, pushes its metatable onto the stack, and returns new type’s id. /// /// - /// allows you to extend Lua and Garry’s Mod type system with custom types. + /// allows you to extend Lua and Garry’s Mod type system with custom types. /// Returned type id can be used with . /// /// See section "Metatables" in the Lua manual for more information about types and metatables: https://www.lua.org/manual/5.1/manual.html @@ -601,7 +601,7 @@ public interface ILua /// A name for the new type. /// A type id for newly created type. /// - public int CreateMetaTable(in string name); + public int CreateMetaTable(string name); /// /// Pushes a metatable of the given type onto the stack. @@ -668,7 +668,7 @@ public interface ILua /// and k is an object on top of the stack. /// /// - /// Unlike , allows to get a value from the table when the key in the key-value pair is not a string. + /// Unlike , allows to get a value from the table when the key in the key-value pair is not a string. /// /// Pops a key object from the stack. /// @@ -676,7 +676,7 @@ public interface ILua /// /// A stack position of the table to get a value from. /// - /// The following example shows how can be used to get a value from the table instead of . + /// The following example shows how can be used to get a value from the table instead of . /// /// public static int GetTableExample(ILua lua) /// { @@ -691,7 +691,7 @@ public interface ILua /// } /// /// - /// + /// public void GetTable(int iStackPos); /// @@ -701,7 +701,7 @@ public interface ILua /// and k is a key at stack index -2. /// /// - /// Unlike , allows to add a key-value pair to a table with the key not being a string. + /// Unlike , allows to add a key-value pair to a table with the key not being a string. /// /// Pops both the key and the value from the stack. /// @@ -709,7 +709,7 @@ public interface ILua /// /// A stack position of the table to add a key-value pair to. /// - /// The following example shows how can be used instead of . + /// The following example shows how can be used instead of . /// /// public static int SetTableExample(ILua lua) /// { @@ -723,7 +723,7 @@ public interface ILua /// } /// /// - /// + /// public void SetTable(int iStackPos); /// @@ -882,7 +882,7 @@ public class GmodLuaException : Exception /// /// A Lua exception code. Must be one of the values defined by Lua specification. /// A Lua exception message. - public GmodLuaException(int lua_error_code, string lua_error_message) : base(lua_error_message) + public GmodLuaException(int lua_error_code, string? lua_error_message) : base(lua_error_message) { this.error_code = lua_error_code; } diff --git a/gm_dotnet_managed/GmodNET.API/ModuleAssemblyLoadContext.cs b/gm_dotnet_managed/GmodNET.API/ModuleAssemblyLoadContext.cs index 17099846..6d4f083a 100644 --- a/gm_dotnet_managed/GmodNET.API/ModuleAssemblyLoadContext.cs +++ b/gm_dotnet_managed/GmodNET.API/ModuleAssemblyLoadContext.cs @@ -21,7 +21,7 @@ public abstract class ModuleAssemblyLoadContext : AssemblyLoadContext /// /// Get current custom native library resolver delegate. /// - public abstract Func CustomNativeLibraryResolver {get; } + public abstract Func? CustomNativeLibraryResolver { get; } /// /// Initializes a new instance of the class with a value that indicates whether unloading is enabled. diff --git a/gm_dotnet_managed/GmodNET/GameConsoleWriter.cs b/gm_dotnet_managed/GmodNET/GameConsoleWriter.cs index 6eb016e2..47a06a21 100644 --- a/gm_dotnet_managed/GmodNET/GameConsoleWriter.cs +++ b/gm_dotnet_managed/GmodNET/GameConsoleWriter.cs @@ -110,11 +110,11 @@ public GameConsoleWriter(ILua lua) private delegate void MsgFunc(string str); - private static MsgFunc Msg; + private static MsgFunc? Msg; - public override void Write(string value) + public override void Write(string? value) { - if (!String.IsNullOrEmpty(value)) + if (!String.IsNullOrEmpty(value) && Msg is not null) { Msg(value); } @@ -123,7 +123,7 @@ public override void Write(char value) { Write(value.ToString()); } - public override void Write(char[] value) + public override void Write(char[]? value) { Write(new string(value)); } @@ -135,7 +135,7 @@ public override void Write(ReadOnlySpan buffer) { Write(new string(buffer)); } - public override void Write(StringBuilder value) + public override void Write(StringBuilder? value) { if (value != null) { @@ -143,7 +143,7 @@ public override void Write(StringBuilder value) } } // \n begins here - public override void WriteLine(string value) + public override void WriteLine(string? value) { if (!String.IsNullOrEmpty(value)) { @@ -158,7 +158,7 @@ public override void WriteLine(char value) { Write(value.ToString() + NewLine); } - public override void WriteLine(char[] buffer) + public override void WriteLine(char[]? buffer) { Write(new string(buffer) + NewLine); } @@ -170,7 +170,7 @@ public override void WriteLine(ReadOnlySpan buffer) { Write(new string(buffer) + NewLine); } - public override void WriteLine(StringBuilder value) + public override void WriteLine(StringBuilder? value) { if (value != null) { @@ -213,7 +213,7 @@ public override void WriteLine(decimal value) { Write(value.ToString() + NewLine); } - public override void WriteLine(object value) + public override void WriteLine(object? value) { if (value == null) { diff --git a/gm_dotnet_managed/GmodNET/GloabalContext.cs b/gm_dotnet_managed/GmodNET/GloabalContext.cs index 4f01f2cb..b7256910 100644 --- a/gm_dotnet_managed/GmodNET/GloabalContext.cs +++ b/gm_dotnet_managed/GmodNET/GloabalContext.cs @@ -103,9 +103,12 @@ int LoadModule(ILua lua) foreach (Type t in module_types) { - IModule current_module = (IModule)Activator.CreateInstance(t); - modules.Add(current_module); - gc_handles.Add(GCHandle.Alloc(current_module)); + IModule? current_module = Activator.CreateInstance(t) as IModule; + if (current_module is not null) + { + modules.Add(current_module); + gc_handles.Add(GCHandle.Alloc(current_module)); + } } if (modules.Count == 0) @@ -150,7 +153,7 @@ WeakReference UnloadHelper(string module_name) { foreach (GCHandle h in module_contexts[module_name].Item2) { - ((IModule)h.Target).Unload(lua); + (h.Target as IModule)?.Unload(lua); h.Free(); } diff --git a/gm_dotnet_managed/GmodNET/GmodNET.csproj b/gm_dotnet_managed/GmodNET/GmodNET.csproj index 0c7fc51e..0c80f978 100644 --- a/gm_dotnet_managed/GmodNET/GmodNET.csproj +++ b/gm_dotnet_managed/GmodNET/GmodNET.csproj @@ -3,6 +3,8 @@ Exe net7.0 + enable + Nullable GmodNET.BuidReq GmodNET managed module loader. MIT diff --git a/gm_dotnet_managed/GmodNET/GmodNetModuleAssemblyLoadContext.cs b/gm_dotnet_managed/GmodNET/GmodNetModuleAssemblyLoadContext.cs index a929658d..d76d4d3e 100644 --- a/gm_dotnet_managed/GmodNET/GmodNetModuleAssemblyLoadContext.cs +++ b/gm_dotnet_managed/GmodNET/GmodNetModuleAssemblyLoadContext.cs @@ -14,7 +14,7 @@ internal class GmodNetModuleAssemblyLoadContext : ModuleAssemblyLoadContext { private AssemblyDependencyResolver resolver; private string module_name; - private Func customNativeLibraryResolver; + private Func? customNativeLibraryResolver; private List native_libray_handles; public override string ModuleName @@ -25,13 +25,7 @@ public override string ModuleName } } - public override Func CustomNativeLibraryResolver - { - get - { - return customNativeLibraryResolver; - } - } + public override Func? CustomNativeLibraryResolver => customNativeLibraryResolver; public override void SetCustomNativeLibraryResolver(Func resolver) { @@ -65,14 +59,14 @@ internal GmodNetModuleAssemblyLoadContext(string module_name) : base(module_name }; } - protected override System.Reflection.Assembly Load(System.Reflection.AssemblyName assemblyName) + protected override System.Reflection.Assembly? Load(System.Reflection.AssemblyName assemblyName) { if(assemblyName.Name == "GmodNET.API") { return null; } - string path = resolver.ResolveAssemblyToPath(assemblyName); + string? path = resolver.ResolveAssemblyToPath(assemblyName); if (string.IsNullOrEmpty(path)) { return null; @@ -98,7 +92,7 @@ protected override IntPtr LoadUnmanagedDll (string unmanagedDllName) } else { - string unmanaged_dep_path = resolver.ResolveUnmanagedDllToPath(unmanagedDllName); + string? unmanaged_dep_path = resolver.ResolveUnmanagedDllToPath(unmanagedDllName); if(String.IsNullOrEmpty(unmanaged_dep_path)) { diff --git a/gm_dotnet_managed/GmodNET/Lua.cs b/gm_dotnet_managed/GmodNET/Lua.cs index 13d7ea68..e6242bf6 100644 --- a/gm_dotnet_managed/GmodNET/Lua.cs +++ b/gm_dotnet_managed/GmodNET/Lua.cs @@ -20,11 +20,21 @@ internal Lua(IntPtr ptr) public int Top() { + if (top is null) + { + throw new LuaInteropDelegateIsNullException(nameof(top)); + } + return top(ptr); } public void Push(int iStackPos) { + if (push is null) + { + throw new LuaInteropDelegateIsNullException(nameof(push)); + } + if (iStackPos == 0) { throw new ArgumentOutOfRangeException("iStackPos", "iStackPos can't be zero!"); @@ -34,6 +44,11 @@ public void Push(int iStackPos) public void Pop(int IAmt = 1) { + if (pop is null) + { + throw new LuaInteropDelegateIsNullException(nameof(pop)); + } + if (IAmt < 0) { throw new ArgumentOutOfRangeException("iAmt", "Can't pop negative number of items from the stack"); @@ -46,8 +61,13 @@ public void Pop(int IAmt = 1) pop(ptr, IAmt); } - public void GetField(int iStackPos, in string key) + public void GetField(int iStackPos, string key) { + if (get_field is null) + { + throw new LuaInteropDelegateIsNullException(nameof(get_field)); + } + if (iStackPos == 0) { throw new ArgumentOutOfRangeException("iStackPos", "iStackPos can't be zero!"); @@ -62,8 +82,13 @@ public void GetField(int iStackPos, in string key) } } - public void SetField(int iStackPos, in string key) + public void SetField(int iStackPos, string key) { + if (set_field is null) + { + throw new LuaInteropDelegateIsNullException(nameof(set_field)); + } + if (iStackPos == 0) { throw new ArgumentOutOfRangeException("iStackPos", "iStackPos can't be zero!"); @@ -80,11 +105,21 @@ public void SetField(int iStackPos, in string key) public void CreateTable() { + if (create_table is null) + { + throw new LuaInteropDelegateIsNullException(nameof(create_table)); + } + create_table(ptr); } public void SetMetaTable(int iStackPos) { + if (set_metatable is null) + { + throw new LuaInteropDelegateIsNullException(nameof(set_metatable)); + } + if (iStackPos == 0) { throw new ArgumentOutOfRangeException("iStackPos", "iStackPos can't be zero!"); @@ -94,6 +129,11 @@ public void SetMetaTable(int iStackPos) public bool GetMetaTable(int iStackPos) { + if (get_metatable is null) + { + throw new LuaInteropDelegateIsNullException(nameof(get_metatable)); + } + if (iStackPos == 0) { throw new ArgumentOutOfRangeException("iStackPos", "iStackPos can't be zero!"); @@ -113,16 +153,31 @@ public bool GetMetaTable(int iStackPos) [Obsolete("Unsafe. Use Lua.PCall instead.", false)] public void Call(int iArgs, int iResults) { + if (call is null) + { + throw new LuaInteropDelegateIsNullException(nameof(call)); + } + call(ptr, iArgs, iResults); } public int PCall(int IArgs, int IResults, int ErrorFunc) { + if (pcall is null) + { + throw new LuaInteropDelegateIsNullException(nameof(pcall)); + } + return pcall(ptr, IArgs, IResults, ErrorFunc); } public bool Equal(int iA, int iB) { + if (equal is null) + { + throw new LuaInteropDelegateIsNullException(nameof(equal)); + } + if(iA == 0 || iB == 0) { throw new ArgumentException("Neither iA or iB can't be 0"); @@ -141,6 +196,11 @@ public bool Equal(int iA, int iB) public bool RawEqual(int iA, int iB) { + if (raw_equal is null) + { + throw new LuaInteropDelegateIsNullException(nameof(raw_equal)); + } + if(iA == 0 || iB == 0) { throw new ArgumentException("Neither iA or iB can't be 0"); @@ -159,6 +219,11 @@ public bool RawEqual(int iA, int iB) public void Insert(int iStackPos) { + if (insert is null) + { + throw new LuaInteropDelegateIsNullException(nameof(insert)); + } + if (iStackPos == 0) { throw new ArgumentOutOfRangeException("iStackPos", "iStackPos can't be zero!"); @@ -168,6 +233,11 @@ public void Insert(int iStackPos) public void Remove(int iStackPos) { + if (remove is null) + { + throw new LuaInteropDelegateIsNullException(nameof(remove)); + } + if (iStackPos == 0) { throw new ArgumentOutOfRangeException("iStackPos", "iStackPos can't be zero!"); @@ -177,6 +247,11 @@ public void Remove(int iStackPos) public int Next(int iStackPos) { + if (next is null) + { + throw new LuaInteropDelegateIsNullException(nameof(next)); + } + if (iStackPos == 0) { throw new ArgumentOutOfRangeException("iStackPos", "iStackPos can't be zero!"); @@ -187,6 +262,11 @@ public int Next(int iStackPos) [Obsolete("BUG: LuaJIT exception mechanism is incompatible with CoreCLR.", true)] public void ThrowError(in string error_message) { + if (throw_error is null) + { + throw new LuaInteropDelegateIsNullException(nameof(throw_error)); + } + byte[] buff = Encoding.UTF8.GetBytes(error_message + "\0"); unsafe { @@ -200,6 +280,11 @@ public void ThrowError(in string error_message) [Obsolete("BUG: LuaJIT exception mechanism is incompatible with CoreCLR.", true)] public void CheckType(int iStackPos, int IType) { + if (check_type is null) + { + throw new LuaInteropDelegateIsNullException(nameof(check_type)); + } + if (iStackPos == 0) { throw new ArgumentOutOfRangeException("iStackPos", "iStackPos can't be zero!"); @@ -210,6 +295,11 @@ public void CheckType(int iStackPos, int IType) [Obsolete("BUG: LuaJIT exception mechanism is incompatible with CoreCLR.", true)] public void ArgError(int iArgNum, in string error_message) { + if (arg_error is null) + { + throw new LuaInteropDelegateIsNullException(nameof(arg_error)); + } + byte[] buff = Encoding.UTF8.GetBytes(error_message); unsafe { @@ -222,6 +312,11 @@ public void ArgError(int iArgNum, in string error_message) public string GetString(int iStackPos) { + if (get_string is null) + { + throw new LuaInteropDelegateIsNullException(nameof(get_string)); + } + if (iStackPos == 0) { throw new ArgumentOutOfRangeException("iStackPos", "iStackPos can't be zero!"); @@ -241,6 +336,11 @@ public string GetString(int iStackPos) public double GetNumber(int iStackPos) { + if (get_number is null) + { + throw new LuaInteropDelegateIsNullException(nameof(get_number)); + } + if (iStackPos == 0) { throw new ArgumentOutOfRangeException("iStackPos", "iStackPos can't be zero!"); @@ -250,6 +350,11 @@ public double GetNumber(int iStackPos) public bool GetBool(int iStackPos) { + if (get_bool is null) + { + throw new LuaInteropDelegateIsNullException(nameof(get_bool)); + } + if (iStackPos == 0) { throw new ArgumentOutOfRangeException("iStackPos", "iStackPos can't be zero!"); @@ -268,6 +373,11 @@ public bool GetBool(int iStackPos) public IntPtr GetCFunction(int iStackPos) { + if (get_c_function is null) + { + throw new LuaInteropDelegateIsNullException(nameof(get_c_function)); + } + if (iStackPos == 0) { throw new ArgumentOutOfRangeException("iStackPos", "iStackPos can't be zero!"); @@ -277,11 +387,21 @@ public IntPtr GetCFunction(int iStackPos) public void PushNil() { + if (push_nil is null) + { + throw new LuaInteropDelegateIsNullException(nameof(push_nil)); + } + push_nil(ptr); } - public void PushString(in string str) + public void PushString(string str) { + if (push_string is null) + { + throw new LuaInteropDelegateIsNullException(nameof(push_string)); + } + byte[] buff = Encoding.UTF8.GetBytes(str); unsafe @@ -295,11 +415,21 @@ public void PushString(in string str) public void PushNumber(double val) { + if (push_number is null) + { + throw new LuaInteropDelegateIsNullException(nameof(push_number)); + } + push_number(ptr, val); } public void PushBool(bool val) { + if (push_bool is null) + { + throw new LuaInteropDelegateIsNullException(nameof(push_bool)); + } + int tmp; if(val) @@ -316,6 +446,11 @@ public void PushBool(bool val) public unsafe void PushCFunction(IntPtr native_func_ptr) { + if (push_c_function is null) + { + throw new LuaInteropDelegateIsNullException(nameof(push_c_function)); + } + if(native_func_ptr == IntPtr.Zero) { throw new ArgumentNullException("native_func_ptr", "Parameter can't be nullptr."); @@ -326,6 +461,11 @@ public unsafe void PushCFunction(IntPtr native_func_ptr) public unsafe void PushCFunction(delegate* unmanaged[Cdecl] function_pointer) { + if (push_c_function is null) + { + throw new LuaInteropDelegateIsNullException(nameof(push_c_function)); + } + IntPtr int_ptr = (IntPtr)function_pointer; if (int_ptr == IntPtr.Zero) @@ -338,31 +478,61 @@ public unsafe void PushCFunction(delegate* unmanaged[Cdecl] functio public void PushCClosure(IntPtr native_func_ptr, int iVars) { + if (push_c_closure is null) + { + throw new LuaInteropDelegateIsNullException(nameof(push_c_closure)); + } + push_c_closure(ptr, native_func_ptr, iVars); } public int ReferenceCreate() { + if (reference_create is null) + { + throw new LuaInteropDelegateIsNullException(nameof(reference_create)); + } + return reference_create(ptr); } public void ReferenceFree(int reference) { + if (reference_free is null) + { + throw new LuaInteropDelegateIsNullException(nameof(reference_free)); + } + reference_free(ptr, reference); } public void ReferencePush(int reference) { + if (reference_push is null) + { + throw new LuaInteropDelegateIsNullException(nameof(reference_push)); + } + reference_push(ptr, reference); } public void PushSpecial(SPECIAL_TABLES table) { + if (push_special is null) + { + throw new LuaInteropDelegateIsNullException(nameof(push_special)); + } + push_special(ptr, (int)table); } public bool IsType(int iStackPos, int iType) { + if (is_type is null) + { + throw new LuaInteropDelegateIsNullException(nameof(is_type)); + } + if (iStackPos == 0) { throw new ArgumentOutOfRangeException("iStackPos", "iStackPos can't be zero!"); @@ -386,6 +556,11 @@ public bool IsType(int iStackPos, TYPES type) public int GetType(int iStackPos) { + if (get_type is null) + { + throw new LuaInteropDelegateIsNullException(nameof(get_type)); + } + if (iStackPos == 0) { throw new ArgumentOutOfRangeException("iStackPos", "iStackPos can't be zero!"); @@ -395,6 +570,11 @@ public int GetType(int iStackPos) public string GetTypeName(int iType) { + if (get_type_name is null) + { + throw new LuaInteropDelegateIsNullException(nameof(get_type_name)); + } + int len = 0; unsafe @@ -414,6 +594,11 @@ public string GetTypeName(TYPES type) public int ObjLen(int iStackPos) { + if (obj_len is null) + { + throw new LuaInteropDelegateIsNullException(nameof(obj_len)); + } + if (iStackPos == 0) { throw new ArgumentOutOfRangeException("iStackPos", "iStackPos can't be zero!"); @@ -423,6 +608,11 @@ public int ObjLen(int iStackPos) public Vector3 GetAngle(int iStackPos) { + if (get_angle is null) + { + throw new LuaInteropDelegateIsNullException(nameof(get_angle)); + } + if (iStackPos == 0) { throw new ArgumentOutOfRangeException("iStackPos", "iStackPos can't be zero!"); @@ -441,6 +631,11 @@ public Vector3 GetAngle(int iStackPos) public Vector3 GetVector(int iStackPos) { + if (get_vector is null) + { + throw new LuaInteropDelegateIsNullException(nameof(get_vector)); + } + if (iStackPos == 0) { throw new ArgumentOutOfRangeException("iStackPos", "iStackPos can't be zero!"); @@ -459,21 +654,41 @@ public Vector3 GetVector(int iStackPos) public void PushAngle(Vector3 ang) { + if (push_angle is null) + { + throw new LuaInteropDelegateIsNullException(nameof(push_angle)); + } + push_angle(ptr, ang.X, ang.Y, ang.Z); } public void PushVector(Vector3 vec) { + if (push_vector is null) + { + throw new LuaInteropDelegateIsNullException(nameof(push_vector)); + } + push_vector(ptr, vec.X, vec.Y, vec.Z); } public void SetState(IntPtr lua_state) { + if (set_state is null) + { + throw new LuaInteropDelegateIsNullException(nameof(set_state)); + } + set_state(ptr, lua_state); } - public int CreateMetaTable(in string name) + public int CreateMetaTable(string name) { + if (create_metatable is null) + { + throw new LuaInteropDelegateIsNullException(nameof(create_metatable)); + } + byte[] buff = Encoding.UTF8.GetBytes(name); unsafe @@ -487,6 +702,11 @@ public int CreateMetaTable(in string name) public bool PushMetaTable(int iType) { + if (push_metatable is null) + { + throw new LuaInteropDelegateIsNullException(nameof(push_metatable)); + } + int tmp = push_metatable(ptr, iType); if(tmp == 0) @@ -506,11 +726,21 @@ public bool PushMetaTable(TYPES type) public void PushUserType(IntPtr data_pointer, int iType) { + if (push_user_type is null) + { + throw new LuaInteropDelegateIsNullException(nameof(push_user_type)); + } + push_user_type(ptr, data_pointer, iType); } public void SetUserType(int iStackPos, IntPtr data_pointer) { + if (set_user_type is null) + { + throw new LuaInteropDelegateIsNullException(nameof(set_user_type)); + } + if (iStackPos == 0) { throw new ArgumentOutOfRangeException("iStackPos", "iStackPos can't be zero!"); @@ -519,7 +749,12 @@ public void SetUserType(int iStackPos, IntPtr data_pointer) } public IntPtr GetUserType(int iStackPos, int iType) - { + { + if (get_user_type is null) + { + throw new LuaInteropDelegateIsNullException(nameof(get_user_type)); + } + if (iStackPos == 0) { throw new ArgumentOutOfRangeException("iStackPos", "iStackPos can't be zero!"); @@ -529,6 +764,11 @@ public IntPtr GetUserType(int iStackPos, int iType) public void GetTable(int iStackPos) { + if (get_table is null) + { + throw new LuaInteropDelegateIsNullException(nameof(get_table)); + } + if (iStackPos == 0) { throw new ArgumentOutOfRangeException("iStackPos", "iStackPos can't be zero!"); @@ -538,6 +778,11 @@ public void GetTable(int iStackPos) public void SetTable(int iStackPos) { + if (set_table is null) + { + throw new LuaInteropDelegateIsNullException(nameof(set_table)); + } + if (iStackPos == 0) { throw new ArgumentOutOfRangeException("iStackPos", "iStackPos can't be zero!"); @@ -547,6 +792,11 @@ public void SetTable(int iStackPos) public void RawGet(int iStackPos) { + if (raw_get is null) + { + throw new LuaInteropDelegateIsNullException(nameof(raw_get)); + } + if (iStackPos == 0) { throw new ArgumentOutOfRangeException("iStackPos", "iStackPos can't be zero!"); @@ -556,6 +806,11 @@ public void RawGet(int iStackPos) public void RawSet(int iStackPos) { + if (raw_set is null) + { + throw new LuaInteropDelegateIsNullException(nameof(raw_set)); + } + if (iStackPos == 0) { throw new ArgumentOutOfRangeException("iStackPos", "iStackPos can't be zero!"); @@ -565,12 +820,22 @@ public void RawSet(int iStackPos) public void PushUserData(IntPtr data) { + if (push_user_data is null) + { + throw new LuaInteropDelegateIsNullException(nameof(push_user_data)); + } + push_user_data(ptr, data); } [Obsolete("BUG: LuaJIT exception mechanism is incompatible with CoreCLR.", true)] public string CheckString(int iStackPos) { + if (check_string is null) + { + throw new LuaInteropDelegateIsNullException(nameof(check_string)); + } + int str_len = 0; unsafe { @@ -591,6 +856,11 @@ public string CheckString(int iStackPos) [Obsolete("BUG: LuaJIT exception mechanism is incompatible with CoreCLR.", true)] public double CheckNumber(int iStackPos) { + if (check_number is null) + { + throw new LuaInteropDelegateIsNullException(nameof(check_number)); + } + return check_number(ptr, iStackPos); } diff --git a/gm_dotnet_managed/GmodNET/LuaInterop.cs b/gm_dotnet_managed/GmodNET/LuaInterop.cs index b381ab1c..e527034a 100644 --- a/gm_dotnet_managed/GmodNET/LuaInterop.cs +++ b/gm_dotnet_managed/GmodNET/LuaInterop.cs @@ -9,121 +9,134 @@ namespace GmodNET [SuppressUnmanagedCodeSecurity] internal static class LuaInterop { - static internal Func top; + static internal Func? top; - static internal Action push; + static internal Action? push; - static internal Action pop; + static internal Action? pop; - static internal Action get_field; + static internal Action? get_field; - static internal Action set_field; + static internal Action? set_field; - static internal Action create_table; + static internal Action? create_table; - static internal Action set_metatable; + static internal Action? set_metatable; - static internal Func get_metatable; + static internal Func? get_metatable; - static internal Action call; + static internal Action? call; - static internal Func pcall; + static internal Func? pcall; - static internal Func equal; + static internal Func? equal; - static internal Func raw_equal; + static internal Func? raw_equal; - static internal Action insert; + static internal Action? insert; - static internal Action remove; + static internal Action? remove; - static internal Func next; + static internal Func? next; - static internal Action throw_error; + static internal Action? throw_error; - static internal Action check_type; + static internal Action? check_type; - static internal Action arg_error; + static internal Action? arg_error; - static internal Func get_string; + static internal Func? get_string; - static internal Func get_number; + static internal Func? get_number; - static internal Func get_bool; + static internal Func? get_bool; - static internal Func get_c_function; + static internal Func? get_c_function; - static internal Action push_nil; + static internal Action? push_nil; - static internal Action push_string; + static internal Action? push_string; - static internal Action push_number; + static internal Action? push_number; - static internal Action push_bool; + static internal Action? push_bool; - static internal Action push_c_function; + static internal Action? push_c_function; - static internal Action push_c_closure; + static internal Action? push_c_closure; - static internal Func reference_create; + static internal Func? reference_create; - static internal Action reference_free; + static internal Action? reference_free; - static internal Action reference_push; + static internal Action? reference_push; - static internal Action push_special; + static internal Action? push_special; - static internal Func is_type; + static internal Func? is_type; - static internal Func get_type; + static internal Func? get_type; - static internal Func get_type_name; + static internal Func? get_type_name; - static internal Func obj_len; + static internal Func? obj_len; - static internal Action get_angle; + static internal Action? get_angle; - static internal Action get_vector; + static internal Action? get_vector; - static internal Action push_angle; + static internal Action? push_angle; - static internal Action push_vector; + static internal Action? push_vector; - static internal Action set_state; + static internal Action? set_state; - static internal Func create_metatable; + static internal Func? create_metatable; - static internal Func push_metatable; + static internal Func? push_metatable; - static internal Action push_user_type; + static internal Action? push_user_type; - static internal Action set_user_type; + static internal Action? set_user_type; - static internal Func get_user_type; + static internal Func? get_user_type; - static internal Func get_iluabase_from_the_lua_state; + static internal Func? get_iluabase_from_the_lua_state; - static internal Action get_table; + static internal Action? get_table; - static internal Action set_table; + static internal Action? set_table; - static internal Action raw_get; + static internal Action? raw_get; - static internal Action raw_set; + static internal Action? raw_set; - static internal Action push_user_data; + static internal Action? push_user_data; - static internal Func check_string; + static internal Func? check_string; - static internal Func check_number; + static internal Func? check_number; - static internal Action push_c_function_safe; + static internal Action? push_c_function_safe; internal static ILua ExtructLua(IntPtr lua_state) - { + { + if (get_iluabase_from_the_lua_state is null) + { + throw new LuaInteropDelegateIsNullException(nameof(get_iluabase_from_the_lua_state)); + } + IntPtr tmp_ptr = LuaInterop.get_iluabase_from_the_lua_state(lua_state); return new Lua(tmp_ptr); } } + + internal class LuaInteropDelegateIsNullException : Exception + { + public LuaInteropDelegateIsNullException(string nameOfDelegate) : base($"Delegate {nameOfDelegate} is null. Critical Gmod.NET runtime error occurred") + { + + } + } } diff --git a/gm_dotnet_managed/GmodNET/ManagedFunctionMetaMethods.cs b/gm_dotnet_managed/GmodNET/ManagedFunctionMetaMethods.cs index 2120590c..009d93f9 100644 --- a/gm_dotnet_managed/GmodNET/ManagedFunctionMetaMethods.cs +++ b/gm_dotnet_managed/GmodNET/ManagedFunctionMetaMethods.cs @@ -28,7 +28,12 @@ internal static int ManagedDelegateExecutor(IntPtr lua_state) IntPtr managed_delegate_handle = lua.GetUserType(GmodInterop.GetUpvalueIndex(1, false), managed_delegate_type_id); - Func managed_delegate = (Func)GCHandle.FromIntPtr(managed_delegate_handle).Target; + Func? managed_delegate = GCHandle.FromIntPtr(managed_delegate_handle).Target as Func; + + if (managed_delegate is null) + { + throw new Exception("Unable to get managed delegate from GCHandle"); + } return Math.Max(0, managed_delegate(lua)); } diff --git a/gm_dotnet_managed/GmodNET/RuntimeServices.cs b/gm_dotnet_managed/GmodNET/RuntimeServices.cs index 87be015a..ef97f442 100644 --- a/gm_dotnet_managed/GmodNET/RuntimeServices.cs +++ b/gm_dotnet_managed/GmodNET/RuntimeServices.cs @@ -12,7 +12,7 @@ internal static class RuntimeServices { internal static T CreateNativeCaller(IntPtr native_pointer) where T : Delegate { - MethodInfo invoke_info = typeof(T).GetMethod("Invoke"); + MethodInfo invoke_info = typeof(T).GetMethod("Invoke")!; // T is constrained to Delegates only, so Invoke method is always present. var return_type = invoke_info.ReturnType; var parameters_types = invoke_info.GetParameters().Select(param => param.ParameterType).Prepend(typeof(object)).ToArray(); diff --git a/gm_dotnet_managed/GmodNET/Startup.cs b/gm_dotnet_managed/GmodNET/Startup.cs index a971cf2a..03996b2f 100644 --- a/gm_dotnet_managed/GmodNET/Startup.cs +++ b/gm_dotnet_managed/GmodNET/Startup.cs @@ -27,9 +27,20 @@ internal static unsafe IntPtr Main(IntPtr lua_base, IntPtr native_version_string { try { - string full_assembly_version = FileVersionInfo.GetVersionInfo(typeof(Startup).Assembly.Location).ProductVersion; - string friendly_version = full_assembly_version.Split("+")[0]; - string version_codename = full_assembly_version.Split("+")[1].Split(".")[1]; + string full_assembly_version = FileVersionInfo.GetVersionInfo(typeof(Startup).Assembly.Location).ProductVersion ?? string.Empty; + + string friendly_version; + string version_codename; + + try + { + friendly_version = full_assembly_version.Split("+")[0]; + version_codename = full_assembly_version.Split("+")[1].Split(".")[1]; + } + catch + { + throw new Exception("Unable to parse version number according to specification"); + } string native_version = Encoding.UTF8.GetString((byte*)native_version_string.ToPointer(), version_string_length); From 73a55ce0d497a1cef55f89030daf82d5b5a80cfd Mon Sep 17 00:00:00 2001 From: Gleb Krasilich Date: Wed, 25 Jan 2023 07:49:00 +0300 Subject: [PATCH 29/32] Upgrade to version 1.0.0-rc; housekeeping --- LICENSE | 2 +- gm_dotnet_managed/GmodNET.API/GmodNET.API.csproj | 6 +++--- gm_dotnet_managed/GmodNET/GmodNET.csproj | 2 +- version.json | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/LICENSE b/LICENSE index da8e467d..f67892df 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2018 - 2020 Gleb Krasilich +Copyright (c) 2018 - 2023 Gleb Krasilich and GmodNET contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/gm_dotnet_managed/GmodNET.API/GmodNET.API.csproj b/gm_dotnet_managed/GmodNET.API/GmodNET.API.csproj index d446bec2..eac47395 100644 --- a/gm_dotnet_managed/GmodNET.API/GmodNET.API.csproj +++ b/gm_dotnet_managed/GmodNET.API/GmodNET.API.csproj @@ -5,15 +5,15 @@ enable Nullable MIT - GmodNET API - GmodNET API library contains all necessary interfaces to write a GmodNET module. + GmodNET.API + GmodNET.API library contains all necessary interfaces to write a Gmod.NET module. https://github.com/GmodNET/GmodDotNet Git garrysmod; GmodNET https://github.com/GmodNET/GmodDotNet gmodnetlogo.png GmodNET - Copyright (c) 2018 - 2021 Gleb Krasilich, GmodNET + Copyright (c) 2018 - 2023 Gleb Krasilich, GmodNET true true Portable diff --git a/gm_dotnet_managed/GmodNET/GmodNET.csproj b/gm_dotnet_managed/GmodNET/GmodNET.csproj index 0c80f978..66333857 100644 --- a/gm_dotnet_managed/GmodNET/GmodNET.csproj +++ b/gm_dotnet_managed/GmodNET/GmodNET.csproj @@ -12,7 +12,7 @@ Git GmodNET $(Description) - Copyright (c) 2018 - 2021 Gleb Krasilich, GmodNET + Copyright (c) 2018 - 2023 Gleb Krasilich, GmodNET true true Portable diff --git a/version.json b/version.json index 1635ec7a..e9f657ce 100644 --- a/version.json +++ b/version.json @@ -1,4 +1,4 @@ { - "Version": "1.0.0-alpha.1", + "Version": "1.0.0-rc", "Codename": "Trubchevsk" } From c8bb94b0ca3112f1ca4465af19e98da177932431 Mon Sep 17 00:00:00 2001 From: Gleb Krasilich Date: Wed, 25 Jan 2023 07:52:02 +0300 Subject: [PATCH 30/32] Updated .NET mentions in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a27253f0..1e149ecb 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ and other .NET languages which runs across all platforms (Windows, Linux, macOS). Gmod.NET allows you to develop cross-platform Garry's Mod extensions without need to close or reload your game or server. -Gmod.NET allows you to write Garry's Mod modules in C# or any other CIL-compiled language as [__.NET 6.0__](https://dotnet.microsoft.com/) class libraries. +Gmod.NET allows you to write Garry's Mod modules in C# or any other CIL-compiled language as [__.NET__](https://dotnet.microsoft.com/) class libraries. For more information on modules and API check out [our documentation](https://docs.gmodnet.xyz/). Only `x86_64` version of Garry's Mod is currently supported. From b5a484d5d6f7518abe54a857bfe5ae3f7b14cd11 Mon Sep 17 00:00:00 2001 From: Gleb Krasilich Date: Wed, 25 Jan 2023 08:25:59 +0300 Subject: [PATCH 31/32] Updated ci.yml --- .github/workflows/ci.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index febd29b4..d206fe6f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,7 +2,8 @@ name: CI on: pull_request: - push: {} + push: + branches: release: types: [published] @@ -385,9 +386,11 @@ jobs: file_glob: true - name: Restore dotnet version tool + if: ${{ github.event_name == 'push' }} run: dotnet tool restore - name: Generate token for GmodNET/runtime-nightly repo + if: ${{ github.event_name == 'push' }} id: generate_token_for_github_nightly uses: tibdex/github-app-token@v1.3.0 with: @@ -396,26 +399,32 @@ jobs: repository: GmodNET/runtime-nightly - name: Get current version + if: ${{ github.event_name == 'push' }} id: get_version run: echo "::set-output name=version::$(dotnet gmodnet-vt getVersion version.json --skip-build-data)" - name: Get current head + if: ${{ github.event_name == 'push' }} id: get_git_head run: echo "::set-output name=head_name::'$(dotnet gmodnet-vt getBranchName version.json)'" - name: Add new git remote for nightly builds + if: ${{ github.event_name == 'push' }} run: | git fetch --unshallow origin git config --local --unset-all http.https://github.com/.extraheader git remote add nightly https://x-access-token:${{ steps.generate_token_for_github_nightly.outputs.token }}@github.com/GmodNET/runtime-nightly.git - name: Apply git tag + if: ${{ github.event_name == 'push' }} run: git tag ${{ steps.get_version.outputs.version }} - name: Push tag to nightly builds repo + if: ${{ github.event_name == 'push' }} run: git push nightly ${{ steps.get_version.outputs.version }} --force - name: Upload build artifacts to nightly repo releases + if: ${{ github.event_name == 'push' }} uses: svenstaro/upload-release-action@2.2.1 with: repo_token: ${{ steps.generate_token_for_github_nightly.outputs.token }} @@ -426,6 +435,7 @@ jobs: file_glob: true - name: Send Discord message + if: ${{ github.event_name == 'push' }} working-directory: csx env: DOTNET_ROLL_FORWARD: Major From fa9c86f2ba64b81d5994772e9f4ac45c300432a0 Mon Sep 17 00:00:00 2001 From: Gleb Krasilich Date: Wed, 25 Jan 2023 08:38:48 +0300 Subject: [PATCH 32/32] Set up release 1.0.0 --- version.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.json b/version.json index e9f657ce..fca5373e 100644 --- a/version.json +++ b/version.json @@ -1,4 +1,4 @@ { - "Version": "1.0.0-rc", + "Version": "1.0.0", "Codename": "Trubchevsk" }