├── Rust └── .gitkeep ├── Carbon.Core ├── .nugets │ └── .gitkeep ├── Carbon.Tests │ ├── .gitignore │ ├── Static │ │ ├── carbon │ │ │ ├── plugins │ │ │ │ ├── cszip_dev │ │ │ │ │ └── Tests │ │ │ │ │ │ ├── Tests.Empty.cs │ │ │ │ │ │ ├── Tests.cs │ │ │ │ │ │ └── Tests.Permission.cs │ │ │ │ └── TestsConflict.cs │ │ │ ├── config.profiler.json │ │ │ └── config.json │ │ └── server.cfg │ ├── .env.example │ ├── README.md │ ├── Carbon.Tests.csproj │ ├── AppSettings.cs │ ├── .run │ │ └── Carbon.Tests (DEV+ENV).run.xml │ ├── Utils.cs │ ├── Program.cs │ └── Services │ │ ├── ProcessRunner.cs │ │ ├── ProcessLifetimeManager.cs │ │ └── TestServerRunner.cs ├── Carbon.Tools │ ├── Carbon.Runner │ │ ├── Program.cs │ │ ├── Attributes.cs │ │ ├── .idea │ │ │ └── .idea.Carbon.Runner │ │ │ │ └── .idea │ │ │ │ ├── encodings.xml │ │ │ │ ├── indexLayout.xml │ │ │ │ ├── .gitignore │ │ │ │ └── vcs.xml │ │ ├── Executors │ │ │ ├── Git.cs │ │ │ ├── Pwsh.cs │ │ │ ├── DotNet.cs │ │ │ ├── Directories.cs │ │ │ ├── Archive.cs │ │ │ ├── Copy.cs │ │ │ ├── Program.cs │ │ │ └── Files.cs │ │ ├── Carbon.Runner.csproj │ │ ├── Carbon.Runner.sln │ │ └── Executor.cs │ ├── Carbon.Publicizer.Shared │ │ ├── BuiltInPatches.cs │ │ ├── ModifierBank.cs │ │ ├── Carbon.Publicizer.Shared.shproj │ │ ├── Carbon.Publicizer.Shared.projitems │ │ ├── Patches │ │ │ ├── Rust.Harmony.cs │ │ │ └── Assembly-CSharp.cs │ │ ├── Config.cs │ │ └── Modifier.cs │ ├── Carbon.Generator │ │ ├── Program.cs │ │ ├── Arguments.cs │ │ └── Carbon.Generator.csproj │ ├── Carbon.Publicizer │ │ ├── Carbon.Publicizer.csproj │ │ └── Program.cs │ └── Carbon.Generator.Shared │ │ ├── Carbon.Generator.Shared.projitems │ │ ├── HookStringPool.cs │ │ └── Carbon.Generator.Shared.shproj ├── .msbuild │ ├── AssemblyName.props │ ├── Protocol.props │ ├── Metadata.props │ ├── Common.props │ ├── References.props │ └── Configurations.props ├── omnisharp.json ├── Carbon.Polyfills │ ├── .gitignore │ ├── Carbon.Polyfills.csproj │ └── src │ │ ├── System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute.cs │ │ ├── System.Runtime.CompilerServices.IsExternalInit.cs │ │ ├── System.Runtime.CompilerServices.ParamCollectionAttribute.cs │ │ ├── System.Diagnostics.CodeAnalysis.SetsRequiredMembersAttribute.cs │ │ ├── System.Runtime.CompilerServices.InterpolatedStringHandlerAttribute.cs │ │ ├── System.Diagnostics.CodeAnalysis.AllowNullAttribute.cs │ │ ├── System.Diagnostics.CodeAnalysis.DisallowNullAttribute.cs │ │ ├── System.Runtime.CompilerServices.RequiresLocationAttribute.cs │ │ ├── System.Diagnostics.CodeAnalysis.MaybeNullAttribute.cs │ │ ├── System.Runtime.CompilerServices.RequiredMemberAttribute.cs │ │ ├── RuntimeSupported │ │ ├── System.Runtime.Versioning.TargetPlatformAttribute.cs │ │ ├── System.Diagnostics.DebuggerDisableUserUnhandledExceptionsAttribute.cs │ │ ├── System.Runtime.InteropServices.WasmImportLinkageAttribute.cs │ │ ├── System.Runtime.CompilerServices.UnsafeAccessorKind.cs │ │ ├── System.Diagnostics.StackTraceHiddenAttribute.cs │ │ ├── System.Runtime.Versioning.SupportedOSPlatformGuardAttribute.cs │ │ ├── System.Runtime.Versioning.UnsupportedOSPlatformGuardAttribute.cs │ │ ├── System.Runtime.CompilerServices.DisableRuntimeMarshallingAttribute.cs │ │ ├── System.Diagnostics.CodeAnalysis.FeatureGuardAttribute.cs │ │ ├── System.Diagnostics.CodeAnalysis.FeatureSwitchDefinitionAttribute.cs │ │ ├── System.Runtime.Versioning.SupportedOSPlatformAttribute.cs │ │ ├── System.Runtime.Versioning.UnsupportedOSPlatformAttribute.cs │ │ ├── System.Runtime.Versioning.ObsoletedOSPlatformAttribute.cs │ │ ├── System.Runtime.CompilerServices.InlineArrayAttribute.cs │ │ ├── System.Runtime.InteropServices.UnmanagedCallersOnlyAttribute.cs │ │ ├── System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute.cs │ │ ├── System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute.cs │ │ └── System.Diagnostics.CodeAnalysis.RequiresAssemblyFilesAttribute.cs │ │ ├── System.Diagnostics.CodeAnalysis.NotNullAttribute.cs │ │ ├── System.Runtime.CompilerServices.SkipLocalsInitAttribute.cs │ │ ├── System.Diagnostics.CodeAnalysis.ConstantExpectedAttribute.cs │ │ ├── System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute.cs │ │ ├── System.Diagnostics.CodeAnalysis.NotNullWhenAttribute.cs │ │ ├── System.Runtime.CompilerServices.CallerArgumentExpressionAttribute.cs │ │ ├── System.Diagnostics.CodeAnalysis.DoesNotReturnIfAttribute.cs │ │ ├── System.Diagnostics.CodeAnalysis.NotNullIfNotNullAttribute.cs │ │ ├── System.Runtime.CompilerServices.OverloadResolutionPriorityAttribute.cs │ │ ├── System.Diagnostics.CodeAnalysis.MemberNotNullAttribute.cs │ │ ├── System.Runtime.CompilerServices.AsyncMethodBuilderAttribute.cs │ │ ├── System.Runtime.CompilerServices.ModuleInitializerAttribute.cs │ │ ├── System.Diagnostics.CodeAnalysis.UnscopedRefAttribute.cs │ │ ├── System.Runtime.CompilerServices.CompilerFeatureRequiredAttribute.cs │ │ ├── System.Runtime.Versioning.RequiresPreviewFeaturesAttribute.cs │ │ ├── System.Runtime.CompilerServices.CollectionBuilderAttribute.cs │ │ ├── System.Runtime.CompilerServices.InterpolatedStringHandlerArgumentAttribute.cs │ │ └── System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute.cs ├── Carbon │ ├── src │ │ ├── Hooks │ │ │ └── Structs.cs │ │ ├── Utilities │ │ │ └── ServerLog.cs │ │ └── Processors │ │ │ └── CarbonProcessor.cs │ └── Carbon.csproj └── .nuspec ├── .github ├── CODEOWNERS ├── FUNDING.yml └── workflows │ ├── production-build.yml │ ├── preview-build.yml │ ├── qa-build.yml │ ├── rust-aux01-build.yml │ ├── rust-aux02-build.yml │ ├── rust-aux03-build.yml │ ├── rust-release-build.yml │ ├── rust-staging-build.yml │ └── edge-build.yml ├── Tools ├── UnityDoorstop │ ├── linux │ │ ├── x64 │ │ │ ├── .doorstop_version │ │ │ └── libdoorstop.so │ │ └── x86 │ │ │ ├── .doorstop_version │ │ │ └── libdoorstop.so │ └── windows │ │ ├── x64 │ │ ├── .doorstop_version │ │ ├── doorstop.dll │ │ ├── doorstop.exp │ │ └── doorstop.lib │ │ └── x86 │ │ ├── .doorstop_version │ │ ├── doorstop.dll │ │ ├── doorstop.exp │ │ └── doorstop.lib ├── Helpers │ ├── 258550_refs.txt │ ├── doorstop_config.ini │ ├── carbon.sh │ ├── environment.sh │ └── Carbon.targets └── Build │ ├── linux │ ├── update_aux02.sh │ ├── update_aux03.sh │ ├── update_aux01.sh │ ├── update_release.sh │ ├── update_staging.sh │ ├── build_debug.sh │ ├── build_minimal.sh │ ├── build_release.sh │ ├── build_native.sh │ ├── publish_git.sh │ ├── bootstrap.sh │ ├── build_profiler.sh │ ├── update.sh │ └── build.sh │ ├── win │ ├── update.bat │ ├── update_aux02.bat │ ├── update_aux03.bat │ ├── update_aux01.bat │ ├── update_release.bat │ ├── update_staging.bat │ ├── build_debug.bat │ ├── build_release.bat │ ├── build_minimal.bat │ ├── build_debug_noarchive.bat │ ├── build_minimal_noarchive.bat │ ├── build_release_noarchive.bat │ ├── bootstrap.bat │ ├── build_native.bat │ ├── build_profiler.bat │ └── build_profiler_noarchive.bat │ └── runners │ ├── nuget.cs │ ├── bootstrap.cs │ ├── git.cs │ ├── profiler.cs │ ├── update.cs │ └── build.cs ├── NuGet-ICON.png ├── setup.bat ├── .gitattributes ├── .devcontainer └── devcontainer.json ├── .gitignore ├── Carbon.code-workspace ├── NuGet-README.md └── .gitmodules /Rust/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Carbon.Core/.nugets/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @jbrazio @raulssorban -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | patreon: CarbonMod 2 | -------------------------------------------------------------------------------- /Tools/UnityDoorstop/linux/x64/.doorstop_version: -------------------------------------------------------------------------------- 1 | 4.0.0 -------------------------------------------------------------------------------- /Tools/UnityDoorstop/linux/x86/.doorstop_version: -------------------------------------------------------------------------------- 1 | 4.0.0 -------------------------------------------------------------------------------- /Tools/UnityDoorstop/windows/x64/.doorstop_version: -------------------------------------------------------------------------------- 1 | 4.0.0 -------------------------------------------------------------------------------- /Tools/UnityDoorstop/windows/x86/.doorstop_version: -------------------------------------------------------------------------------- 1 | 4.0.0 -------------------------------------------------------------------------------- /Tools/Helpers/258550_refs.txt: -------------------------------------------------------------------------------- 1 | regex:RustDedicated_Data/Managed -------------------------------------------------------------------------------- /NuGet-ICON.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarbonCommunity/Carbon/HEAD/NuGet-ICON.png -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tests/.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | .env.* 3 | *.env 4 | !.env.example 5 | 6 | .dev 7 | .idea 8 | -------------------------------------------------------------------------------- /Tools/Build/linux/update_aux02.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | "$(cd -- "$(dirname "$0")" >/dev/null 2>&1; pwd -P)/update.sh" aux02 -------------------------------------------------------------------------------- /Tools/Build/linux/update_aux03.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | "$(cd -- "$(dirname "$0")" >/dev/null 2>&1; pwd -P)/update.sh" aux03 -------------------------------------------------------------------------------- /Tools/Build/linux/update_aux01.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | "$(cd -- "$(dirname "$0")" >/dev/null 2>&1; pwd -P)/update.sh" aux01-staging -------------------------------------------------------------------------------- /Tools/Build/linux/update_release.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | "$(cd -- "$(dirname "$0")" >/dev/null 2>&1; pwd -P)/update.sh" release -------------------------------------------------------------------------------- /Tools/Build/linux/update_staging.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | "$(cd -- "$(dirname "$0")" >/dev/null 2>&1; pwd -P)/update.sh" staging -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tests/Static/carbon/plugins/cszip_dev/Tests/Tests.Empty.cs: -------------------------------------------------------------------------------- 1 | namespace Carbon.Plugins; 2 | 3 | public partial class Tests; -------------------------------------------------------------------------------- /Tools/UnityDoorstop/linux/x64/libdoorstop.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarbonCommunity/Carbon/HEAD/Tools/UnityDoorstop/linux/x64/libdoorstop.so -------------------------------------------------------------------------------- /Tools/UnityDoorstop/linux/x86/libdoorstop.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarbonCommunity/Carbon/HEAD/Tools/UnityDoorstop/linux/x86/libdoorstop.so -------------------------------------------------------------------------------- /Tools/UnityDoorstop/windows/x64/doorstop.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarbonCommunity/Carbon/HEAD/Tools/UnityDoorstop/windows/x64/doorstop.dll -------------------------------------------------------------------------------- /Tools/UnityDoorstop/windows/x64/doorstop.exp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarbonCommunity/Carbon/HEAD/Tools/UnityDoorstop/windows/x64/doorstop.exp -------------------------------------------------------------------------------- /Tools/UnityDoorstop/windows/x64/doorstop.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarbonCommunity/Carbon/HEAD/Tools/UnityDoorstop/windows/x64/doorstop.lib -------------------------------------------------------------------------------- /Tools/UnityDoorstop/windows/x86/doorstop.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarbonCommunity/Carbon/HEAD/Tools/UnityDoorstop/windows/x86/doorstop.dll -------------------------------------------------------------------------------- /Tools/UnityDoorstop/windows/x86/doorstop.exp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarbonCommunity/Carbon/HEAD/Tools/UnityDoorstop/windows/x86/doorstop.exp -------------------------------------------------------------------------------- /Tools/UnityDoorstop/windows/x86/doorstop.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CarbonCommunity/Carbon/HEAD/Tools/UnityDoorstop/windows/x86/doorstop.lib -------------------------------------------------------------------------------- /setup.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | set SUPERROOT="%cd%\Tools\Build\win" 4 | 5 | cd %SUPERROOT% 6 | call bootstrap.bat 7 | 8 | cd %SUPERROOT% 9 | call build_debug_noarchive.bat -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tools/Carbon.Runner/Program.cs: -------------------------------------------------------------------------------- 1 | using Carbon.Runner; 2 | 3 | InternalRunner.Run(args.Length > 0 ? args[0] : string.Empty, args, true); 4 | Console.ReadLine(); 5 | -------------------------------------------------------------------------------- /Tools/Build/linux/build_debug.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | BASE="$(cd -- "$(dirname "$0")" >/dev/null 2>&1; pwd -P)" 4 | 5 | "${BASE}/build.sh" Debug 6 | "${BASE}/build.sh" DebugUnix -------------------------------------------------------------------------------- /Tools/Build/linux/build_minimal.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | BASE="$(cd -- "$(dirname "$0")" >/dev/null 2>&1; pwd -P)" 4 | 5 | "${BASE}/build.sh" Minimal 6 | "${BASE}/build.sh" MinimalUnix -------------------------------------------------------------------------------- /Tools/Build/linux/build_release.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | BASE="$(cd -- "$(dirname "$0")" >/dev/null 2>&1; pwd -P)" 4 | 5 | "${BASE}/build.sh" Release 6 | "${BASE}/build.sh" ReleaseUnix -------------------------------------------------------------------------------- /Tools/Build/win/update.bat: -------------------------------------------------------------------------------- 1 | @echo OFF 2 | 3 | set ROOT=%cd% 4 | cd ../../.. 5 | 6 | dotnet run --project Carbon.Core/Carbon.Tools/Carbon.Runner Tools/Build/runners/update.cs 7 | cd %ROOT% -------------------------------------------------------------------------------- /Tools/Build/win/update_aux02.bat: -------------------------------------------------------------------------------- 1 | @echo OFF 2 | 3 | set ROOT=%cd% 4 | cd ../../.. 5 | 6 | dotnet run --project Carbon.Core/Carbon.Tools/Carbon.Runner Tools/Build/runners/update.cs aux02 7 | cd %ROOT% -------------------------------------------------------------------------------- /Tools/Build/win/update_aux03.bat: -------------------------------------------------------------------------------- 1 | @echo OFF 2 | 3 | set ROOT=%cd% 4 | cd ../../.. 5 | 6 | dotnet run --project Carbon.Core/Carbon.Tools/Carbon.Runner Tools/Build/runners/update.cs aux03 7 | cd %ROOT% -------------------------------------------------------------------------------- /Tools/Build/win/update_aux01.bat: -------------------------------------------------------------------------------- 1 | @echo OFF 2 | 3 | set ROOT=%cd% 4 | cd ../../.. 5 | 6 | dotnet run --project Carbon.Core/Carbon.Tools/Carbon.Runner Tools/Build/runners/update.cs aux01-staging 7 | cd %ROOT% -------------------------------------------------------------------------------- /Tools/Build/win/update_release.bat: -------------------------------------------------------------------------------- 1 | @echo OFF 2 | 3 | set ROOT=%cd% 4 | cd ../../.. 5 | 6 | dotnet run --project Carbon.Core/Carbon.Tools/Carbon.Runner Tools/Build/runners/update.cs release 7 | cd %ROOT% -------------------------------------------------------------------------------- /Tools/Build/win/update_staging.bat: -------------------------------------------------------------------------------- 1 | @echo OFF 2 | 3 | set ROOT=%cd% 4 | cd ../../.. 5 | 6 | dotnet run --project Carbon.Core/Carbon.Tools/Carbon.Runner Tools/Build/runners/update.cs staging 7 | cd %ROOT% -------------------------------------------------------------------------------- /Tools/Build/win/build_debug.bat: -------------------------------------------------------------------------------- 1 | @echo OFF 2 | 3 | set ROOT=%cd% 4 | cd ../../.. 5 | 6 | dotnet run --project Carbon.Core/Carbon.Tools/Carbon.Runner Tools/Build/runners/build.cs Debug EDGE edge_build 7 | cd %ROOT% -------------------------------------------------------------------------------- /Tools/Build/win/build_release.bat: -------------------------------------------------------------------------------- 1 | @echo OFF 2 | 3 | set ROOT=%cd% 4 | cd ../../.. 5 | 6 | dotnet run --project Carbon.Core/Carbon.Tools/Carbon.Runner Tools/Build/runners/build.cs Release EDGE edge_build 7 | cd %ROOT% -------------------------------------------------------------------------------- /Tools/Build/win/build_minimal.bat: -------------------------------------------------------------------------------- 1 | @echo OFF 2 | 3 | set ROOT=%cd% 4 | cd ../../.. 5 | 6 | dotnet run --project Carbon.Core/Carbon.Tools/Carbon.Runner Tools/Build/runners/build.cs Minimal MINIMAL edge_build 7 | cd %ROOT% -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tools/Carbon.Publicizer.Shared/BuiltInPatches.cs: -------------------------------------------------------------------------------- 1 | namespace Carbon.Publicizer; 2 | 3 | #pragma warning disable 4 | 5 | public static class BuiltInPatches 6 | { 7 | public static Patch[] Current; 8 | } 9 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tools/Carbon.Runner/Attributes.cs: -------------------------------------------------------------------------------- 1 | namespace Carbon.Runner; 2 | 3 | [AttributeUsage(AttributeTargets.Method)] 4 | public class Expose(string help) : Attribute 5 | { 6 | public string Help = help; 7 | } 8 | -------------------------------------------------------------------------------- /Tools/Build/win/build_debug_noarchive.bat: -------------------------------------------------------------------------------- 1 | @echo OFF 2 | 3 | set ROOT=%cd% 4 | cd ../../.. 5 | 6 | dotnet run --project Carbon.Core/Carbon.Tools/Carbon.Runner Tools/Build/runners/build.cs Debug EDGE edge_build -noarchive 7 | cd %ROOT% -------------------------------------------------------------------------------- /Tools/Build/win/build_minimal_noarchive.bat: -------------------------------------------------------------------------------- 1 | @echo OFF 2 | 3 | set ROOT=%cd% 4 | cd ../../.. 5 | 6 | dotnet run --project Carbon.Core/Carbon.Tools/Carbon.Runner Tools/Build/runners/build.cs Minimal MINIMAL edge_build -noarchive 7 | cd %ROOT% -------------------------------------------------------------------------------- /Tools/Build/win/build_release_noarchive.bat: -------------------------------------------------------------------------------- 1 | @echo OFF 2 | 3 | set ROOT=%cd% 4 | cd ../../.. 5 | 6 | dotnet run --project Carbon.Core/Carbon.Tools/Carbon.Runner Tools/Build/runners/build.cs Release EDGE edge_build -noarchive 7 | cd %ROOT% -------------------------------------------------------------------------------- /Carbon.Core/.msbuild/AssemblyName.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $(Product) 5 | 6 | 7 | -------------------------------------------------------------------------------- /Carbon.Core/.msbuild/Protocol.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 2025.12.04.1 5 | 6 | 7 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tools/Carbon.Runner/.idea/.idea.Carbon.Runner/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | 3 | *.bat text eol=crlf 4 | *.cs text eol=crlf diff=csharp 5 | *.dll binary 6 | *.exe binary 7 | *.json text eol=crlf 8 | *.sh text eol=lf 9 | *.so binary 10 | *.yml text eol=crlf -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tools/Carbon.Runner/Executors/Git.cs: -------------------------------------------------------------------------------- 1 | namespace Carbon.Runner.Executors; 2 | 3 | public class Git : Program 4 | { 5 | public override string Name => "Git"; 6 | 7 | public Git() 8 | { 9 | programFile = "git"; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tools/Carbon.Runner/Executors/Pwsh.cs: -------------------------------------------------------------------------------- 1 | namespace Carbon.Runner.Executors; 2 | 3 | public class Pwsh : Program 4 | { 5 | public override string Name => "Pwsh"; 6 | 7 | public Pwsh() 8 | { 9 | programFile = "pwsh"; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "image": "mcr.microsoft.com/devcontainers/universal:2", 3 | "features": { 4 | "ghcr.io/devcontainers/features/dotnet:2": { 5 | "version": "9.0", 6 | "additionalVersions": ["8.0"] 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tools/Carbon.Runner/Executors/DotNet.cs: -------------------------------------------------------------------------------- 1 | namespace Carbon.Runner.Executors; 2 | 3 | public class DotNet : Program 4 | { 5 | public override string Name => "DotNet"; 6 | 7 | public DotNet() 8 | { 9 | programFile = "dotnet"; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Tools/Build/win/bootstrap.bat: -------------------------------------------------------------------------------- 1 | @echo OFF 2 | 3 | set ROOT=%cd% 4 | cd ../../.. 5 | 6 | dotnet run --project Carbon.Core/Carbon.Tools/Carbon.Runner Tools/Build/runners/bootstrap.cs 7 | dotnet run --project Carbon.Core/Carbon.Tools/Carbon.Runner Tools/Build/runners/update.cs 8 | cd %ROOT% -------------------------------------------------------------------------------- /Tools/Helpers/doorstop_config.ini: -------------------------------------------------------------------------------- 1 | [General] 2 | enabled = true 3 | ignore_disable_switch=false 4 | target_assembly = carbon/managed/Carbon.Preloader.dll 5 | 6 | [UnityMono] 7 | debug_enabled=false 8 | debug_suspend=false 9 | debug_address=127.0.0.1:55555 10 | 11 | [Il2Cpp] 12 | # Not used -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tools/Carbon.Runner/.idea/.idea.Carbon.Runner/.idea/indexLayout.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Tools/Helpers/carbon.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ### 4 | ### Copyright (c) 2022-2023 Carbon Community 5 | ### All rights reserved 6 | ### 7 | 8 | SCRIPT=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) 9 | source "${SCRIPT}/carbon/tools/environment.sh" 10 | "${SCRIPT}/RustDedicated" "$@" -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tools/Carbon.Generator/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using CommandLine; 3 | using HarmonyLib; 4 | 5 | Parser.Default.ParseArguments(args) 6 | .WithNotParsed(x => Environment.Exit(1)) 7 | .WithParsed(x => Generator.Arguments = x); 8 | 9 | Generator.Prewarm(); 10 | Generator.Generate(); 11 | -------------------------------------------------------------------------------- /Tools/Build/linux/build_native.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | BASE="$(cd -- "$(dirname "$0")" >/dev/null 2>&1; pwd -P)" 4 | 5 | "${BASE}/build.sh" Release 6 | "${BASE}/build.sh" ReleaseUnix 7 | 8 | HOME=$(pwd) 9 | ROOT=$(dirname "$(dirname "$(dirname "$HOME")")") 10 | 11 | cd "$ROOT/Carbon.Core/Carbon.Native" || exit 12 | 13 | cargo build 14 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tests/Static/carbon/config.profiler.json: -------------------------------------------------------------------------------- 1 | { 2 | "Enabled": true, 3 | "TrackCalls": true, 4 | "SourceViewer": true, 5 | "Assemblies": [ 6 | "*" 7 | ], 8 | "Plugins": [ 9 | "*" 10 | ], 11 | "Modules": [ 12 | "*" 13 | ], 14 | "Extensions": [ 15 | "*" 16 | ], 17 | "Harmony": [ 18 | "*" 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /Tools/Build/win/build_native.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | set HOME=%cd% 4 | set ROOT=%HOME%\..\..\.. 5 | 6 | cd %ROOT%\Carbon.Core\Carbon.Native 7 | 8 | podman machine start 9 | rustup target add x86_64-unknown-linux-gnu 10 | rustup target add x86_64-pc-windows-gnu 11 | cross build -r --target x86_64-unknown-linux-gnu 12 | cross build -r --target x86_64-pc-windows-gnu 13 | 14 | cd %HOME% -------------------------------------------------------------------------------- /Carbon.Core/omnisharp.json: -------------------------------------------------------------------------------- 1 | { 2 | "script": { 3 | "enabled": true, 4 | "defaultTargetFramework": "net48", 5 | "enableScriptNuGetReferences": true 6 | }, 7 | "RoslynExtensionsOptions": { 8 | "EnableAnalyzersSupport": true, 9 | "EnableDecompilationSupport": true, 10 | "LocationPaths": [] 11 | }, 12 | "FormattingOptions": { 13 | "TabSize": 4, 14 | "UseTabs": true 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/.gitignore: -------------------------------------------------------------------------------- 1 | # Build results 2 | [Bb]in/ 3 | [Oo]bj/ 4 | 5 | # Visual Studio 2015/2017 cache/options directory 6 | .vs/ 7 | 8 | # VS Code files for those working on multiple tools 9 | .vscode/* 10 | !.vscode/settings.json 11 | !.vscode/tasks.json 12 | !.vscode/launch.json 13 | !.vscode/extensions.json 14 | *.code-workspace 15 | *.csproj.user 16 | 17 | # misc 18 | .[Rr]elease/ 19 | .[Rr]edist/ -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tools/Carbon.Runner/.idea/.idea.Carbon.Runner/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Rider ignored files 5 | /contentModel.xml 6 | /.idea.Carbon.Runner.iml 7 | /projectSettingsUpdater.xml 8 | /modules.xml 9 | # Editor-based HTTP Client requests 10 | /httpRequests/ 11 | # Datasource local storage ignored files 12 | /dataSources/ 13 | /dataSources.local.xml 14 | -------------------------------------------------------------------------------- /Tools/Build/win/build_profiler.bat: -------------------------------------------------------------------------------- 1 | @echo OFF 2 | 3 | call "%~dp0\build_native.bat" 4 | 5 | set ROOT=%cd% 6 | cd ../../.. 7 | 8 | set VERSION=2.0.0 9 | dotnet run --project Carbon.Core/Carbon.Tools/Carbon.Runner Tools/Build/runners/profiler.cs Debug HARMONYMOD edge_build 10 | dotnet run --project Carbon.Core/Carbon.Tools/Carbon.Runner Tools/Build/runners/profiler.cs DebugUnix HARMONYMOD edge_build 11 | cd %ROOT% -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tools/Carbon.Runner/Carbon.Runner.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | Exe 4 | net10.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Tools/Build/win/build_profiler_noarchive.bat: -------------------------------------------------------------------------------- 1 | @echo OFF 2 | 3 | call "%~dp0\build_native.bat" 4 | 5 | set ROOT=%cd% 6 | cd ../../.. 7 | 8 | set VERSION=2.0.0 9 | dotnet run --project Carbon.Core/Carbon.Tools/Carbon.Runner Tools/Build/runners/profiler.cs Debug HARMONYMOD edge_build -noarchive 10 | dotnet run --project Carbon.Core/Carbon.Tools/Carbon.Runner Tools/Build/runners/profiler.cs DebugUnix HARMONYMOD edge_build -noarchive 11 | cd %ROOT% -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tests/.env.example: -------------------------------------------------------------------------------- 1 | WorkingDir=.dev 2 | BranchName=public 3 | CarbonDownloadZipUrl=https://github.com/CarbonCommunity/Carbon/releases/download/edge_build/Carbon.Windows.Debug.zip 4 | 5 | # Skip Depot Downloader hit if Rust server is already present 6 | ForDebug__SkipRustServerIfPresent=false 7 | 8 | # Skip Rust server run at all 9 | ForDebug__NoRustServerRun=false 10 | 11 | # Skip Carbon if the directory is already present 12 | ForDebug__SkipCarbonIfPresent=false 13 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tests/Static/carbon/plugins/TestsConflict.cs: -------------------------------------------------------------------------------- 1 | // Requires: Tests 2 | 3 | using Carbon.Test; 4 | 5 | namespace Carbon.Plugins; 6 | 7 | [Info("TestConflict", "Carbon Community LTD", "1.0.0")] 8 | public partial class TestsConflict : CarbonPlugin 9 | { 10 | private object ConflictTest(Integrations.Test.Assert test) 11 | { 12 | test.Log("ConflictTest was fired (False) [TestConflict]"); 13 | Tests.Hooks.hasFired = true; 14 | return false; 15 | } 16 | } -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tests/Static/carbon/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "DeveloperMode": true, 3 | "Analytics": { 4 | "Enabled": false 5 | }, 6 | "SelfUpdating": { 7 | "Enabled": false, 8 | "HookUpdates": true 9 | }, 10 | "Logging": { 11 | "LogSplitSize": 2.5, 12 | "LogSeverity": 3, 13 | "LogFileMode": 2, 14 | "LogVerbosity": 6, 15 | "CommandSuggestions": true, 16 | "ReducedLogging": false 17 | }, 18 | "Misc": { 19 | "ShowConsoleInfo": false 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/Carbon.Polyfills.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | Carbon.Polyfills 4 | Library 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Tools/Build/runners/nuget.cs: -------------------------------------------------------------------------------- 1 | var key = GetArg(1); 2 | var version = GetArg(2); 3 | 4 | Warn($"Key: {key.Length}"); 5 | Warn($"Version: {version}"); 6 | 7 | DotNet.WorkingDirectory(Path(Home, "Carbon.Core")); 8 | DotNet.Run("pack", "-o", PathEnquotes(Home, "Carbon.Core", ".nugets"), 9 | "-c", "Release", $"/p:PackageVersion={version}", "--no-build"); 10 | 11 | DotNet.SetQuiet(true); 12 | DotNet.Run("nuget", "push", PathEnquotes(Home, "Carbon.Core", ".nugets", $"Carbon.Community.{version}.nupkg"), 13 | "--api-key", key, "--source", "https://api.nuget.org/v3/index.json"); 14 | -------------------------------------------------------------------------------- /Tools/Build/runners/bootstrap.cs: -------------------------------------------------------------------------------- 1 | Log(Home); 2 | 3 | Git.Run("config", "--global", "--add", "safe.directory", "'*'"); 4 | Git.Run("config", "--local", "--add", "safe.directory", "'*'"); 5 | 6 | Warn("Git Setup"); 7 | { 8 | Git.Run("-C", Home, "submodule", "init"); 9 | Git.Run("-C", Home, "submodule", "update"); 10 | Git.Run("-C", Home, "submodule", "foreach", "git", "checkout"); 11 | } 12 | 13 | Warn("Building Submodules"); 14 | { 15 | DotNet.Run("restore", PathEnquotes(Home, "Tools", "DepotDownloader")); 16 | DotNet.Run("clean", PathEnquotes(Home, "Tools", "DepotDownloader")); 17 | DotNet.Run("build", PathEnquotes(Home, "Tools", "DepotDownloader"), "--no-restore", "--no-incremental"); 18 | } -------------------------------------------------------------------------------- /Tools/Helpers/environment.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ### 4 | ### Copyright (c) 2022-2023 Carbon Community 5 | ### All rights reserved 6 | ### 7 | 8 | # Get the directory of the executable 9 | CARBONENV_SCRIPT=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) 10 | CARBONENV_BASEDIR=$(realpath "${CARBONENV_SCRIPT}/../../") 11 | 12 | # Docker workaround 13 | export TERM=xterm 14 | 15 | # Prepare unity doorstop 16 | export DOORSTOP_ENABLED=1 17 | export DOORSTOP_TARGET_ASSEMBLY="${CARBONENV_BASEDIR}/carbon/managed/Carbon.Preloader.dll" 18 | 19 | # Prepare the environment 20 | export LD_PRELOAD="${CARBONENV_BASEDIR}/libdoorstop.so" 21 | export LD_LIBRARY_PATH="${CARBONENV_BASEDIR}:${CARBONENV_BASEDIR}/RustDedicated_Data/Plugins/x86_64" 22 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Diagnostics.CodeAnalysis 9 | { 10 | /// 11 | /// Applied to a method that will never return under any circumstance. 12 | /// 13 | [global::System.AttributeUsage(global::System.AttributeTargets.Method, Inherited = false)] 14 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 15 | public sealed class DoesNotReturnAttribute : global::System.Attribute 16 | { 17 | } 18 | } -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/System.Runtime.CompilerServices.IsExternalInit.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Runtime.CompilerServices 9 | { 10 | /// 11 | /// Reserved to be used by the compiler for tracking metadata. 12 | /// This class should not be used by developers in source code. 13 | /// 14 | [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] 15 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 16 | public static class IsExternalInit 17 | { 18 | } 19 | } -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/System.Runtime.CompilerServices.ParamCollectionAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Runtime.CompilerServices 9 | { 10 | /// 11 | /// Indicates that a method will allow a variable number of arguments in its invocation. 12 | /// 13 | [global::System.AttributeUsage(global::System.AttributeTargets.Parameter, Inherited = true, AllowMultiple = false)] 14 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 15 | public sealed class ParamCollectionAttribute : global::System.Attribute 16 | { 17 | } 18 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Build results 2 | [Bb]in/ 3 | [Oo]bj/ 4 | 5 | # Visual Studio 2015/2017 cache/options directory 6 | .vs/ 7 | *.user 8 | 9 | # VS Code files for those working on multiple tools 10 | .vscode/* 11 | !.vscode/settings.json 12 | !.vscode/tasks.json 13 | !.vscode/launch.json 14 | !.vscode/extensions.json 15 | *.code-workspace 16 | *.csproj.user 17 | 18 | # Rider 19 | */.idea/* 20 | 21 | # Code gen 22 | Carbon.Core/Carbon.Components/Carbon.Common/src/Carbon/Build.cs 23 | [Gg]enerated/ 24 | [Tt]ools/Runtime 25 | 26 | # Oxide autogen hooks 27 | **/Carbon.Hooks/Carbon.Hooks.Extra/src/Oxide 28 | 29 | # Project release folder 30 | [Rr]elease/ 31 | 32 | # Rust managed files 33 | [Rr]ust/ 34 | 35 | # msbuild stuff 36 | .tmp 37 | .gittag 38 | .gitauthor 39 | .gitbranch 40 | .gitchl 41 | .gitchs 42 | .gitcomment 43 | .gitdate 44 | .giturl 45 | .rndasm -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tools/Carbon.Generator/Arguments.cs: -------------------------------------------------------------------------------- 1 | using CommandLine; 2 | 3 | #pragma warning disable 4 | 5 | public class CommandLineArguments 6 | { 7 | [Option("plugininput", Required = true, HelpText = "Path to the plugin folder")] 8 | public string PluginInput { get; set; } 9 | 10 | [Option("rust", Required = true, HelpText = "Path to the Rust folder")] 11 | public string Rust { get; set; } 12 | 13 | [Option("pluginnamespace", Required = false, HelpText = "Plugin namespace")] 14 | public string PluginNamespace { get; set; } = @"Carbon.Core"; 15 | 16 | [Option("basecall", Required = false, HelpText = "InternalCallHook base call as default")] 17 | public bool BaseCall { get; set; } = false; 18 | 19 | [Option("basename", Required = false, HelpText = "InternalCallHook base name")] 20 | public string BaseName { get; set; } = "plugin"; 21 | } 22 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tests/README.md: -------------------------------------------------------------------------------- 1 | # Carbon.Tests 2 | 3 | Automated test runner suit for testing carbon. 4 | Mainly used inside [CI/CD](../../.github/workflows/common-test.yml) 5 | 6 | ## Required Env Variables 7 | 8 | ```dotenv 9 | WorkingDir=.dev 10 | BranchName=public 11 | CarbonDownloadZipUrl=https://github.com/CarbonCommunity/Carbon/releases/download/edge_build/Carbon.Windows.Debug.zip 12 | 13 | # Skip Depot Downloader hit if Rust server is already present 14 | ForDebug__SkipRustServerIfPresent=false 15 | 16 | # Skip Rust server run at all 17 | ForDebug__NoRustServerRun=false 18 | 19 | # Skip Carbon if the directory is already present 20 | ForDebug__SkipCarbonIfPresent=false 21 | ``` 22 | 23 | For dev purposes, you can create `.env` file (or rename `.env.example` to `.env`) and add it as Env variable inside run configuration, 24 | or use `Carbon.Tests (DEV+ENV)` run config (still need `.env`) 25 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/System.Diagnostics.CodeAnalysis.SetsRequiredMembersAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Diagnostics.CodeAnalysis 9 | { 10 | /// 11 | /// Specifies that this constructor sets all required members for the current type, 12 | /// and callers do not need to set any required members themselves. 13 | /// 14 | [global::System.AttributeUsage(global::System.AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)] 15 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 16 | public sealed class SetsRequiredMembersAttribute : global::System.Attribute 17 | { 18 | } 19 | } -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/System.Runtime.CompilerServices.InterpolatedStringHandlerAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Runtime.CompilerServices 9 | { 10 | /// 11 | /// Indicates the attributed type is to be used as an interpolated string handler. 12 | /// 13 | [global::System.AttributeUsage( 14 | global::System.AttributeTargets.Class | 15 | global::System.AttributeTargets.Struct, 16 | AllowMultiple = false, Inherited = false)] 17 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 18 | public sealed class InterpolatedStringHandlerAttribute : global::System.Attribute 19 | { 20 | } 21 | } -------------------------------------------------------------------------------- /Carbon.Core/Carbon/src/Hooks/Structs.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Reflection; 3 | using API.Hooks; 4 | using HarmonyLib; 5 | 6 | namespace Carbon.Hooks; 7 | 8 | public struct HookRuntime 9 | { 10 | public string LastError; 11 | public HookState Status; 12 | 13 | public Harmony HarmonyHandler; 14 | public MethodInfo Prefix; 15 | public MethodInfo Postfix; 16 | public MethodInfo Transpiler; 17 | } 18 | 19 | public struct Subscription 20 | { 21 | public string Identifier, Subscriber; 22 | 23 | public Subscription(string id, string sub) 24 | { 25 | Identifier = id; 26 | Subscriber = sub; 27 | } 28 | } 29 | 30 | public struct TaskStatus 31 | { 32 | public int Static; 33 | public int Patch; 34 | public int Dynamic; 35 | public int Metadata; 36 | public List Hooks; 37 | 38 | public readonly int Total => Static + Patch + Dynamic + Metadata; 39 | } 40 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/System.Diagnostics.CodeAnalysis.AllowNullAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Diagnostics.CodeAnalysis 9 | { 10 | /// 11 | /// Specifies that null is allowed as an input even if the corresponding type disallows it. 12 | /// 13 | [global::System.AttributeUsage( 14 | global::System.AttributeTargets.Field | 15 | global::System.AttributeTargets.Parameter | 16 | global::System.AttributeTargets.Property, 17 | Inherited = false)] 18 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 19 | public sealed class AllowNullAttribute : global::System.Attribute 20 | { 21 | } 22 | } -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/System.Diagnostics.CodeAnalysis.DisallowNullAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Diagnostics.CodeAnalysis 9 | { 10 | /// 11 | /// Specifies that null is disallowed as an input even if the corresponding type allows it. 12 | /// 13 | [global::System.AttributeUsage( 14 | global::System.AttributeTargets.Field | 15 | global::System.AttributeTargets.Parameter | 16 | global::System.AttributeTargets.Property, 17 | Inherited = false)] 18 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 19 | public sealed class DisallowNullAttribute : global::System.Attribute 20 | { 21 | } 22 | } -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/System.Runtime.CompilerServices.RequiresLocationAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Runtime.CompilerServices 9 | { 10 | /// 11 | /// Reserved for use by a compiler for tracking metadata. 12 | /// This attribute should not be used by developers in source code. 13 | /// 14 | [global::System.AttributeUsage(global::System.AttributeTargets.Parameter, Inherited = false)] 15 | [global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)] 16 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 17 | public sealed class RequiresLocationAttribute : global::System.Attribute 18 | { 19 | } 20 | } -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/System.Diagnostics.CodeAnalysis.MaybeNullAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Diagnostics.CodeAnalysis 9 | { 10 | /// 11 | /// Specifies that an output may be null even if the corresponding type disallows it. 12 | /// 13 | [global::System.AttributeUsage( 14 | global::System.AttributeTargets.Field | 15 | global::System.AttributeTargets.Parameter | 16 | global::System.AttributeTargets.Property | 17 | global::System.AttributeTargets.ReturnValue, 18 | Inherited = false)] 19 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 20 | public sealed class MaybeNullAttribute : global::System.Attribute 21 | { 22 | } 23 | } -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tools/Carbon.Publicizer/Carbon.Publicizer.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | Exe 4 | net10.0 5 | enable 6 | enable 7 | 8 | 9 | 0 10 | 11 | 12 | 0 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tools/Carbon.Publicizer.Shared/ModifierBank.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.IO; 3 | using Newtonsoft.Json; 4 | 5 | namespace Carbon.Components; 6 | 7 | public class ModifierBank : List 8 | { 9 | public bool HasPlugin(string name) 10 | { 11 | for (int i = 0; i < Count; i++) 12 | { 13 | if (Path.GetFileNameWithoutExtension(this[i].Path).Equals(name, System.StringComparison.CurrentCulture)) 14 | { 15 | return true; 16 | } 17 | } 18 | return false; 19 | } 20 | 21 | public ModifierBank WithModifier(Modifier modifier) 22 | { 23 | Add(modifier); 24 | return this; 25 | } 26 | 27 | public string ToJson(Formatting formatting = Formatting.Indented) 28 | { 29 | return JsonConvert.SerializeObject(this, formatting); 30 | } 31 | 32 | public void ToFile(string path, Formatting formatting = Formatting.Indented) 33 | { 34 | File.WriteAllText(path, ToJson(formatting)); 35 | } 36 | } 37 | 38 | -------------------------------------------------------------------------------- /Carbon.Core/.msbuild/Metadata.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | $(UserVersion) 8 | 9 | 10 | 11 | $(Product) 12 | $(Version) 13 | $(CarbonProtocol) 14 | $(Version) 15 | $(Configuration) 16 | 17 | 18 | 22 | 23 | 24 | 25 | $(VersionPrefix)-$(VersionSuffix) 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/System.Runtime.CompilerServices.RequiredMemberAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Runtime.CompilerServices 9 | { 10 | /// 11 | /// Specifies that a type has required members or that a member is required. 12 | /// 13 | [global::System.AttributeUsage( 14 | global::System.AttributeTargets.Class | 15 | global::System.AttributeTargets.Struct | 16 | global::System.AttributeTargets.Field | 17 | global::System.AttributeTargets.Property, 18 | AllowMultiple = false, 19 | Inherited = false)] 20 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 21 | public sealed class RequiredMemberAttribute : global::System.Attribute 22 | { 23 | } 24 | } -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/RuntimeSupported/System.Runtime.Versioning.TargetPlatformAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Runtime.Versioning 9 | { 10 | /// 11 | /// Records the platform that the project targeted. 12 | /// 13 | [global::System.AttributeUsage(global::System.AttributeTargets.Assembly, AllowMultiple = false, Inherited = false)] 14 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 15 | [global::System.Diagnostics.Conditional("MULTI_TARGETING_SUPPORT_ATTRIBUTES")] 16 | public sealed class TargetPlatformAttribute : global::System.Attribute // OSPlatformAttribute 17 | { 18 | public TargetPlatformAttribute(string platformName) 19 | // : base(platformName) 20 | { 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tests/Carbon.Tests.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net10.0 6 | enable 7 | enable 8 | latest 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | Always 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /.github/workflows/production-build.yml: -------------------------------------------------------------------------------- 1 | name: Production Build 2 | concurrency: build-production 3 | 4 | on: 5 | workflow_dispatch: 6 | 7 | jobs: 8 | call-common: 9 | uses: ./.github/workflows/common-core-build.yml 10 | name: Call Common Build 11 | permissions: 12 | contents: write 13 | with: 14 | # noinspection UndefinedParamsPresent 15 | GIT_BRANCH: production 16 | # noinspection UndefinedParamsPresent 17 | RELEASE_BODY: | 18 | This is a release build of Carbon based on the `production` branch. 19 | This build is targeted at the general public. 20 | 21 | ### How to install 22 | 1. Download the `Carbon.[Windows|Linux].Release` archive from the attachments below. 23 | 2. Unzip the archive to the root of your Rust Dedicated Server. 24 | 3. Restart the server and enjoy. 25 | secrets: 26 | PAT_ALL_REPO: ${{ secrets.PAT_ALL_REPO }} 27 | VERSIONS_TOKEN: ${{ secrets.VERSIONS_TOKEN }} 28 | NUGET_API: ${{ secrets.NUGET_API }} 29 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/System.Diagnostics.CodeAnalysis.NotNullAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Diagnostics.CodeAnalysis 9 | { 10 | /// 11 | /// Specifies that an output will not be null even if the corresponding type allows it. 12 | /// Specifies that an input argument was not null when the call returns. 13 | /// 14 | [global::System.AttributeUsage( 15 | global::System.AttributeTargets.Field | 16 | global::System.AttributeTargets.Parameter | 17 | global::System.AttributeTargets.Property | 18 | global::System.AttributeTargets.ReturnValue, 19 | Inherited = false)] 20 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 21 | public sealed class NotNullAttribute : global::System.Attribute 22 | { 23 | } 24 | } -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tests/Static/server.cfg: -------------------------------------------------------------------------------- 1 | bear.population "0" 2 | bike.motorbikemonumentpopulation "0" 3 | bike.pedalmonumentpopulation "0" 4 | bike.pedalroadsidepopulation "0" 5 | boar.population "0" 6 | chicken.population "0" 7 | halloween.murdererpopulation "0" 8 | halloween.scarecrowpopulation "0" 9 | spawn.population_cap_rate "0" 10 | spawn.respawn_populations "0" 11 | halloweendungeon.population "0" 12 | hotairballoon.population "0" 13 | metaldetectorsource.population "0" 14 | minicopter.population "0" 15 | modularcar.population "0" 16 | motorrowboat.population "0" 17 | polarbear.population "0" 18 | rhib.rhibpopulation "0" 19 | ridablehorse.population "0" 20 | crocodile.population "0" 21 | panther.population "0" 22 | tiger.population "0" 23 | scraptransporthelicopter.population "0" 24 | snakehazard.population "0" 25 | stag.population "0" 26 | traincar.population "0" 27 | wolf.population "0" 28 | xmasdungeon.xmaspopulation "0" 29 | zombie.population "0" 30 | server.autouploadmap "0" 31 | server.autouploadmapimages "0" 32 | server.tickrate "2" 33 | server.corpses "0" 34 | server.events "0" 35 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tools/Carbon.Generator.Shared/Carbon.Generator.Shared.projitems: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | true 6 | 05275584-550b-440b-86c5-8d76e490dcd2 7 | 8 | 9 | Carbon.Generator.Shared 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | C:\Users\rauls\.nuget\packages\microsoft.codeanalysis.csharp\4.13.0\lib\netstandard2.0\Microsoft.CodeAnalysis.CSharp.dll 18 | 19 | 20 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tools/Carbon.Generator.Shared/HookStringPool.cs: -------------------------------------------------------------------------------- 1 | using System.Security.Cryptography; 2 | using System.Text; 3 | using System.Collections.Generic; 4 | 5 | namespace Carbon.Pooling; 6 | 7 | #pragma warning disable 8 | 9 | public class HookStringPool 10 | { 11 | public static Dictionary HookNamePoolString = new(); 12 | public static Dictionary HookNamePoolInt = new(); 13 | 14 | public static uint GetOrAdd(string name) 15 | { 16 | if (HookNamePoolString.TryGetValue(name, out var hash)) 17 | { 18 | return hash; 19 | } 20 | 21 | hash = ManifestHash(name); 22 | HookNamePoolString[name] = hash; 23 | HookNamePoolInt[hash] = name; 24 | return hash; 25 | } 26 | 27 | public static string GetOrAdd(uint name) 28 | { 29 | return HookNamePoolInt.TryGetValue(name, out var hash) ? hash : string.Empty; 30 | } 31 | 32 | private static uint ManifestHash(string str) 33 | { 34 | return string.IsNullOrEmpty(str) ? 0 : BitConverter.ToUInt32(new MD5CryptoServiceProvider().ComputeHash(Encoding.UTF8.GetBytes(str)), 0); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tools/Carbon.Runner/Executors/Directories.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | 3 | namespace Carbon.Runner.Executors; 4 | 5 | public class Directories : Executor 6 | { 7 | public override string? Name => "Directories"; 8 | 9 | [Expose("Gets a list of all files in a directory")] 10 | public string[] Get(string directory, string search = "*") => Directory.GetDirectories(directory, search); 11 | 12 | [Expose("Ensure the directory exists")] 13 | public void Create(string directory) 14 | { 15 | if (Directory.Exists(directory)) 16 | { 17 | Log($"Directory '{directory}' already exists. Skipping.."); 18 | return; 19 | } 20 | 21 | Directory.CreateDirectory(directory); 22 | Warn($"Created folder: {directory}"); 23 | } 24 | 25 | [Expose("Deletes a directory if the directory exists")] 26 | public void Delete(string directory) 27 | { 28 | if (!Directory.Exists(directory)) 29 | { 30 | Log($"Directory '{directory}' not found. Skipping.."); 31 | return; 32 | } 33 | 34 | Directory.Delete(directory, true); 35 | Warn($"Deleted directory: '{directory}'"); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/RuntimeSupported/System.Diagnostics.DebuggerDisableUserUnhandledExceptionsAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Diagnostics 9 | { 10 | /// 11 | /// If a .NET Debugger is attached which supports the Debugger.BreakForUserUnhandledException(Exception) API, 12 | /// this attribute will prevent the debugger from breaking on user-unhandled exceptions when the 13 | /// exception is caught by a method with this attribute, unless BreakForUserUnhandledException is called. 14 | /// 15 | [global::System.AttributeUsage(global::System.AttributeTargets.Method)] 16 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 17 | [global::System.Diagnostics.Conditional("MULTI_TARGETING_SUPPORT_ATTRIBUTES")] 18 | public sealed class DebuggerDisableUserUnhandledExceptionsAttribute : global::System.Attribute 19 | { 20 | } 21 | } -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tools/Carbon.Generator.Shared/Carbon.Generator.Shared.shproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 05275584-550b-440b-86c5-8d76e490dcd2 5 | 14.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Tools/Build/runners/git.cs: -------------------------------------------------------------------------------- 1 | var localTag = GetArg(0); 2 | Warn($"Local Tag: {localTag}"); 3 | 4 | var temp = Path(Home, "Carbon.Core", ".tmp"); 5 | Directories.Create(temp); 6 | 7 | Files.Create(Path(temp, ".gitbranch"), Git.RunOutput("branch", "--show-current")); 8 | Files.Create(Path(temp, ".gitchs"), Git.RunOutput("rev-parse", "--short", "HEAD")); 9 | Files.Create(Path(temp, ".gitchl"), Git.RunOutput("rev-parse", "--long", "HEAD")); 10 | Files.Create(Path(temp, ".gitauthor"), Git.RunOutput("show", "-s", "--format=\"%an\"", "HEAD")); 11 | Files.Create(Path(temp, ".gitcomment"), Git.RunOutput("log -1", "--pretty=\"%B\"", "HEAD")); 12 | Files.Create(Path(temp, ".gitdate"), Git.RunOutput("log -1", "--format=\"%ci\"", "HEAD")); 13 | 14 | if(string.IsNullOrEmpty(localTag)) 15 | { 16 | Files.Create(Path(temp, ".gittag"), Git.RunOutput("describe", "--tags")); 17 | } 18 | else 19 | { 20 | Files.Create(Path(temp, ".gittag"), localTag); 21 | } 22 | 23 | Files.Create(Path(temp, ".giturl"), Git.RunOutput("remote", "get-url", "origin")); 24 | Files.Create(Path(temp, ".gitchanges"), Git.RunOutput("log -1", "--name-status", "--format=\"\"")); 25 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tools/Carbon.Publicizer.Shared/Carbon.Publicizer.Shared.shproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 206fef5d-2782-4954-8272-2ab61b2695b7 5 | 14.0 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tools/Carbon.Publicizer/Program.cs: -------------------------------------------------------------------------------- 1 | using Carbon.Publicizer; 2 | 3 | #pragma warning disable 4 | 5 | var input = args[0]; 6 | var patchableFiles = Directory.EnumerateFiles(input); 7 | 8 | Config.Init(null!); 9 | Patch.Init(null!, null!, input); 10 | foreach (var file in patchableFiles) 11 | { 12 | try 13 | { 14 | var name = Path.GetFileName(file); 15 | var patch = BuiltInPatches.Current.FirstOrDefault(x => x.fileName.Equals(name)); 16 | 17 | if (patch != null && patch.Execute()) 18 | { 19 | patch.Write(file); 20 | Console.WriteLine($" Publicized '{Path.GetFileName(file)}'"); 21 | continue; 22 | } 23 | 24 | if (!Config.Singleton.Publicizer.PublicizedAssemblies.Any(x => name.StartsWith(x, StringComparison.OrdinalIgnoreCase))) 25 | { 26 | continue; 27 | } 28 | 29 | patch = new Patch(Path.GetDirectoryName(file), name); 30 | if (patch.Execute()) 31 | { 32 | patch.Write(file); 33 | Console.WriteLine($" Publicized '{Path.GetFileName(file)}'"); 34 | } 35 | } 36 | catch (Exception ex) 37 | { 38 | Console.WriteLine($"Failed to patch ({ex.Message})\n{ex.StackTrace}"); 39 | } 40 | } 41 | Patch.Uninit(); 42 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/RuntimeSupported/System.Runtime.InteropServices.WasmImportLinkageAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Runtime.InteropServices 9 | { 10 | /// 11 | /// Specifies that the P/Invoke marked with this attribute should be linked in as a WASM import. 12 | /// 13 | /// 14 | /// See https://webassembly.github.io/spec/core/syntax/modules.html#imports. 15 | /// 16 | [global::System.AttributeUsage(global::System.AttributeTargets.Method, Inherited = false)] 17 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 18 | [global::System.Diagnostics.Conditional("MULTI_TARGETING_SUPPORT_ATTRIBUTES")] 19 | public sealed class WasmImportLinkageAttribute : global::System.Attribute 20 | { 21 | /// 22 | /// Instance constructor. 23 | /// 24 | public WasmImportLinkageAttribute() { } 25 | } 26 | } -------------------------------------------------------------------------------- /Carbon.Core/Carbon/Carbon.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | Carbon 4 | Library 5 | Carbon 6 | False 7 | Carbon 8 | true 9 | ..\.nuspec 10 | version=$(PackageVersion) 11 | true 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Carbon.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "name": "Carbon", 5 | "path": "." 6 | } 7 | ], 8 | "settings": { 9 | "editor.insertSpaces": false, 10 | "editor.snippetSuggestions": "inline", 11 | "editor.formatOnSave": true, 12 | "editor.tabSize": 4, 13 | "editor.rulers": [ 14 | { 15 | "column": 80, 16 | "color": "#ff000025" 17 | }, 18 | { 19 | "column": 130, 20 | "color": "#ff000025" 21 | } 22 | ], 23 | "files.watcherExclude": { 24 | "**/.git/objects/**": true, 25 | "**/.git/subtree-cache/**": true, 26 | "**/node_modules/*/**": true 27 | }, 28 | "[csharp]": { 29 | "editor.defaultFormatter": "ms-dotnettools.csharp" 30 | }, 31 | "dotnet.completion.showCompletionItemsFromUnimportedNamespaces": true, 32 | "dotnet.formatting.organizeImportsOnFormat": true 33 | }, 34 | "extensions": { 35 | "recommendations": [ 36 | "ms-dotnettools.csharp", 37 | "ms-vscode.powershell", 38 | "donjayamanne.githistory", 39 | "dotjoshjohnson.xml", 40 | "fabiospampinato.vscode-diff", 41 | "fudge.auto-using", 42 | "esbenp.prettier-vscode" 43 | ] 44 | } 45 | } -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/System.Runtime.CompilerServices.SkipLocalsInitAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Runtime.CompilerServices 9 | { 10 | /// 11 | /// Used to indicate to the compiler that the .locals init flag should not be set in method headers. 12 | /// 13 | [global::System.AttributeUsage( 14 | global::System.AttributeTargets.Module | 15 | global::System.AttributeTargets.Class | 16 | global::System.AttributeTargets.Struct | 17 | global::System.AttributeTargets.Interface | 18 | global::System.AttributeTargets.Constructor | 19 | global::System.AttributeTargets.Method | 20 | global::System.AttributeTargets.Property | 21 | global::System.AttributeTargets.Event, 22 | Inherited = false)] 23 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 24 | public sealed class SkipLocalsInitAttribute : global::System.Attribute 25 | { 26 | } 27 | } -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tools/Carbon.Runner/Carbon.Runner.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.13.35825.156 d17.13 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Carbon.Runner", "Carbon.Runner.csproj", "{455AD15E-A5EE-4E60-8300-3E1FCE9252C3}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {455AD15E-A5EE-4E60-8300-3E1FCE9252C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {455AD15E-A5EE-4E60-8300-3E1FCE9252C3}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {455AD15E-A5EE-4E60-8300-3E1FCE9252C3}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {455AD15E-A5EE-4E60-8300-3E1FCE9252C3}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {36ACBC6B-9D0C-4B1C-B0F6-001EDE9E95DD} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon/src/Utilities/ServerLog.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using Carbon.Core; 4 | using Carbon.Extensions; 5 | using UnityEngine; 6 | 7 | namespace Carbon; 8 | 9 | public class ServerLog : ILogHandler, IDisposable 10 | { 11 | internal FileStream _stream; 12 | internal StreamWriter _writer; 13 | internal ILogHandler _default = Debug.unityLogger.logHandler; 14 | 15 | public ServerLog() 16 | { 17 | _stream = new FileStream(CommandLineEx.GetArgumentResult("-logfile", Path.Combine(Defines.GetLogsFolder(), $"Server.{ConVar.Server.identity}.txt")), FileMode.OpenOrCreate, FileAccess.ReadWrite); 18 | _writer = new StreamWriter(_stream); 19 | 20 | Debug.unityLogger.logHandler = this; 21 | } 22 | 23 | public void LogFormat(LogType logType, UnityEngine.Object context, string format, params object[] args) 24 | { 25 | _writer.WriteLine(string.Format(format, args)); 26 | _writer.Flush(); 27 | _default.LogFormat(logType, context, format, args); 28 | } 29 | 30 | public void LogException(Exception exception, UnityEngine.Object context) 31 | { 32 | _default.LogException(exception, context); 33 | } 34 | 35 | public void Dispose() 36 | { 37 | Debug.unityLogger.logHandler = _default; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tests/AppSettings.cs: -------------------------------------------------------------------------------- 1 | namespace Carbon.Tests; 2 | 3 | internal class AppSettings 4 | { 5 | public required string WorkingDir { get; init; } 6 | public required string BranchName { get; init; } 7 | public required string CarbonDownloadZipUrl { get; init; } 8 | 9 | public AppSettings(string workingDir, string branchName, string carbonDownloadZipUrl) 10 | { 11 | WorkingDir = workingDir ?? throw new ArgumentException(null, nameof(workingDir)); 12 | BranchName = branchName ?? throw new ArgumentException(null, nameof(branchName)); 13 | CarbonDownloadZipUrl = carbonDownloadZipUrl ?? throw new ArgumentException(null, nameof(carbonDownloadZipUrl)); 14 | } 15 | } 16 | 17 | internal class ForDebugSettings 18 | { 19 | public const string SectionName = "ForDebug"; 20 | 21 | public bool SkipRustServerIfPresent { get; init; } 22 | public bool SkipCarbonIfPresent { get; init; } 23 | public bool NoRustServerRun { get; init; } 24 | 25 | public ForDebugSettings(bool skipRustServerIfPresent = false, bool skipCarbonIfPresent = false, bool noRustServerRun = false) 26 | { 27 | SkipRustServerIfPresent = skipRustServerIfPresent; 28 | SkipCarbonIfPresent = skipCarbonIfPresent; 29 | NoRustServerRun = noRustServerRun; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tools/Carbon.Generator/Carbon.Generator.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | Exe 4 | net10.0 5 | enable 6 | enable 7 | 8 | 9 | 0 10 | 11 | 12 | 0 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tools/Carbon.Publicizer.Shared/Carbon.Publicizer.Shared.projitems: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath) 5 | true 6 | 206fef5d-2782-4954-8272-2ab61b2695b7 7 | 8 | 9 | Carbon.Publicizer.Shared 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Tools/Build/linux/publish_git.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # 4 | # Copyright (c) 2022-2023 Carbon Community 5 | # All rights reserved. 6 | # 7 | 8 | HOME=$(pwd) 9 | TEMP="$(dirname "$0")/../../../Carbon.Core/.tmp" 10 | 11 | if [ ! -d "$TEMP" ]; then 12 | mkdir -p "$TEMP" 13 | fi 14 | 15 | git fetch --tags 16 | 17 | echo "** Git Metadata:" 18 | 19 | for tag in $(git tag -l); do 20 | git tag -d "$tag" 21 | done 22 | 23 | git fetch --tags 24 | 25 | cd "$TEMP" 26 | git branch --show-current > .gitbranch 27 | echo "** Branch done." 28 | 29 | git rev-parse --short HEAD > .gitchs 30 | echo "** Hash-short done." 31 | 32 | git rev-parse --long HEAD > .gitchl 33 | echo "** Hash-long done." 34 | 35 | git show -s --format="%an" HEAD > .gitauthor 36 | echo "** Author done." 37 | 38 | git log -1 --pretty="%B" HEAD > .gitcomment 39 | echo "** Comment done." 40 | 41 | git log -1 --format="%ci" HEAD > .gitdate 42 | echo "** Date done." 43 | 44 | if [ -z "$1" ]; then 45 | git describe --tags > .gittag 46 | echo "** Tag done." 47 | else 48 | echo "$1" > .gittag 49 | echo "** Tag done." 50 | fi 51 | 52 | git remote get-url origin > .giturl 53 | echo "** URL done." 54 | 55 | git log -1 --name-status --format="" > .gitchanges 56 | echo "** Changes done." 57 | 58 | cd "$HOME" 59 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/System.Diagnostics.CodeAnalysis.ConstantExpectedAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Diagnostics.CodeAnalysis 9 | { 10 | /// 11 | /// Indicates that the specified method parameter expects a constant. 12 | /// 13 | /// 14 | /// This can be used to inform tooling that a constant should be used as an argument for the annotated parameter. 15 | /// 16 | [global::System.AttributeUsage(AttributeTargets.Parameter, Inherited = false)] 17 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 18 | public sealed class ConstantExpectedAttribute : global::System.Attribute 19 | { 20 | /// 21 | /// Indicates the minimum bound of the expected constant, inclusive. 22 | /// 23 | public object? Min { get; set; } 24 | 25 | /// 26 | /// Indicates the maximum bound of the expected constant, inclusive. 27 | /// 28 | public object? Max { get; set; } 29 | } 30 | } -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tests/.run/Carbon.Tests (DEV+ENV).run.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 23 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/RuntimeSupported/System.Runtime.CompilerServices.UnsafeAccessorKind.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Runtime.CompilerServices 9 | { 10 | /// 11 | /// Specifies the kind of target to which an is providing access. 12 | /// 13 | public enum UnsafeAccessorKind 14 | { 15 | /// 16 | /// Provide access to a constructor. 17 | /// 18 | Constructor, 19 | 20 | /// 21 | /// Provide access to a method. 22 | /// 23 | Method, 24 | 25 | /// 26 | /// Provide access to a static method. 27 | /// 28 | StaticMethod, 29 | 30 | /// 31 | /// Provide access to a field. 32 | /// 33 | Field, 34 | 35 | /// 36 | /// Provide access to a static field. 37 | /// 38 | StaticField 39 | } 40 | } -------------------------------------------------------------------------------- /Tools/Build/linux/bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ### 4 | ### Copyright (c) 2022-2023 Carbon Community 5 | ### All rights reserved 6 | ### 7 | set -e 8 | 9 | cat </dev/null 2>&1; pwd -P)" 19 | ROOT="$(realpath "${BASE}/../../../")" 20 | 21 | # Inits and downloads the submodules 22 | git -C "${ROOT}" submodule init 23 | git -C "${ROOT}" submodule update 24 | 25 | echo Building submodules.. 26 | for TOOL in DepotDownloader; do 27 | echo Build "${TOOL}" 28 | dotnet restore "${ROOT}/Tools/${TOOL}" --verbosity quiet --nologo --force > /dev/null 29 | dotnet clean "${ROOT}/Tools/${TOOL}" --verbosity quiet --configuration Release --nologo > /dev/null 30 | dotnet build "${ROOT}/Tools/${TOOL}" --verbosity quiet --configuration Release --no-restore --no-incremental > /dev/null 31 | echo done. 32 | done 33 | 34 | # Download rust binary libs 35 | "${BASE}/update.sh" 36 | 37 | # Don't track changes to this file 38 | git -C "${ROOT}" update-index --assume-unchanged "${ROOT}/Tools/Helpers/doorstop_config.ini" -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/RuntimeSupported/System.Diagnostics.StackTraceHiddenAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Diagnostics 9 | { 10 | /// 11 | /// Types and Methods attributed with StackTraceHidden will be omitted from the stack trace text shown in StackTrace.ToString() 12 | /// and Exception.StackTrace 13 | /// 14 | [global::System.AttributeUsage( 15 | global::System.AttributeTargets.Class | 16 | global::System.AttributeTargets.Method | 17 | global::System.AttributeTargets.Constructor | 18 | global::System.AttributeTargets.Struct, 19 | Inherited = false)] 20 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 21 | [global::System.Diagnostics.Conditional("MULTI_TARGETING_SUPPORT_ATTRIBUTES")] 22 | public sealed class StackTraceHiddenAttribute : global::System.Attribute 23 | { 24 | /// 25 | /// Initializes a new instance of the class. 26 | /// 27 | public StackTraceHiddenAttribute() { } 28 | } 29 | } -------------------------------------------------------------------------------- /.github/workflows/preview-build.yml: -------------------------------------------------------------------------------- 1 | name: Preview Build 2 | concurrency: build-preview 3 | 4 | on: 5 | workflow_dispatch: 6 | 7 | jobs: 8 | call-common: 9 | uses: ./.github/workflows/common-core-build.yml 10 | name: Call Common Build 11 | permissions: 12 | contents: write 13 | with: 14 | # noinspection UndefinedParamsPresent 15 | GIT_BRANCH: preview 16 | # noinspection UndefinedParamsPresent 17 | RELEASE_BODY: | 18 | This is a manually triggered development build of Carbon based on the `preview` branch which includes pre-production changes and upcoming features (for testing purposes). 19 | 20 | This build is targeted at developers. 21 | The general public is advised to use one of the [stable] builds. 22 | Since it's manually triggered, we're confident you should use this build to test out the latest Carbon changes. 23 | 24 | ### How to install 25 | 1. Download the `Carbon.[Windows|Linux].Debug` archive from the attachments below. 26 | 2. Unzip the archive to the root of your Rust Dedicated Server. 27 | 3. Restart the server and enjoy. 28 | 29 | [stable]: https://github.com/CarbonCommunity/Carbon.Core/releases/latest 30 | secrets: 31 | PAT_ALL_REPO: ${{ secrets.PAT_ALL_REPO }} 32 | VERSIONS_TOKEN: ${{ secrets.VERSIONS_TOKEN }} 33 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Diagnostics.CodeAnalysis 9 | { 10 | /// 11 | /// Specifies that when a method returns , the parameter may be null even if the corresponding type disallows it. 12 | /// 13 | [global::System.AttributeUsage(global::System.AttributeTargets.Parameter, Inherited = false)] 14 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 15 | public sealed class MaybeNullWhenAttribute : global::System.Attribute 16 | { 17 | /// 18 | /// Initializes the attribute with the specified return value condition. 19 | /// 20 | /// The return value condition. If the method returns this value, the associated parameter may be null. 21 | public MaybeNullWhenAttribute(bool returnValue) => ReturnValue = returnValue; 22 | 23 | /// 24 | /// Gets the return value condition. 25 | /// 26 | public bool ReturnValue { get; } 27 | } 28 | } -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/System.Diagnostics.CodeAnalysis.NotNullWhenAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Diagnostics.CodeAnalysis 9 | { 10 | /// 11 | /// Specifies that when a method returns , the parameter will not be null even if the corresponding type allows it. 12 | /// 13 | [global::System.AttributeUsage(global::System.AttributeTargets.Parameter, Inherited = false)] 14 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 15 | public sealed class NotNullWhenAttribute : global::System.Attribute 16 | { 17 | /// 18 | /// Initializes the attribute with the specified return value condition. 19 | /// 20 | /// The return value condition. If the method returns this value, the associated parameter will not be null. 21 | public NotNullWhenAttribute(bool returnValue) 22 | { 23 | ReturnValue = returnValue; 24 | } 25 | 26 | /// Gets the return value condition. 27 | public bool ReturnValue { get; } 28 | } 29 | } -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tools/Carbon.Runner/Executors/Archive.cs: -------------------------------------------------------------------------------- 1 | using System.Formats.Tar; 2 | using System.IO.Compression; 3 | 4 | namespace Carbon.Runner.Executors; 5 | 6 | public class Archive : Executor 7 | { 8 | public override string Name => "Archive"; 9 | 10 | [Expose("Creates a new ZIP file of a directory")] 11 | public void Zip(string directory, string destination) 12 | { 13 | if (File.Exists(destination)) 14 | { 15 | File.Delete(destination); 16 | } 17 | ZipFile.CreateFromDirectory(directory, destination, CompressionLevel.Optimal, false); 18 | Warn($"Created ZIP file: {destination}"); 19 | } 20 | 21 | [Expose("Creates a new TAR file of a directory")] 22 | public void Tar(string directory, string destination) 23 | { 24 | if (File.Exists(destination)) 25 | { 26 | File.Delete(destination); 27 | } 28 | 29 | var temp = InternalRunner.Path(destination + ".tmp"); 30 | 31 | TarFile.CreateFromDirectory(directory, temp, false); 32 | 33 | using (var originalFileStream = new FileStream(temp, FileMode.Open, FileAccess.Read)) 34 | using (var compressedFileStream = new FileStream(destination, FileMode.Create)) 35 | using (var gzipStream = new GZipStream(compressedFileStream, CompressionLevel.Optimal)) 36 | { 37 | originalFileStream.CopyTo(gzipStream); 38 | } 39 | 40 | Warn($"Created TAR file: {destination}"); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /.github/workflows/qa-build.yml: -------------------------------------------------------------------------------- 1 | name: QA Build 2 | concurrency: build-qa 3 | 4 | on: 5 | workflow_dispatch: 6 | 7 | jobs: 8 | call-common: 9 | uses: ./.github/workflows/common-core-build.yml 10 | name: Call Common Build 11 | permissions: 12 | contents: write 13 | with: 14 | # noinspection UndefinedParamsPresent 15 | GIT_BRANCH: qa 16 | # noinspection UndefinedParamsPresent 17 | RELEASE_BODY: | 18 | This is a manually triggered build of Carbon based on the `qa` branch. 19 | This build is high priority and dedicated to reflect what's to come in the upcoming `production` build. Primarily used by Quality Assurance community members. 20 | 21 | This build is targeted at developers or testers. 22 | The general public is advised to use one of the [stable] builds. 23 | Since it's manually triggered, we're confident you should use this build to test out the latest Carbon changes. 24 | 25 | ### How to install 26 | 1. Download the `Carbon.[Windows|Linux].Debug` archive from the attachments below. 27 | 2. Unzip the archive to the root of your Rust Dedicated Server. 28 | 3. Restart the server and enjoy. 29 | 30 | [stable]: https://github.com/CarbonCommunity/Carbon.Core/releases/latest 31 | secrets: 32 | PAT_ALL_REPO: ${{ secrets.PAT_ALL_REPO }} 33 | VERSIONS_TOKEN: ${{ secrets.VERSIONS_TOKEN }} 34 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/System.Runtime.CompilerServices.CallerArgumentExpressionAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Runtime.CompilerServices 9 | { 10 | /// 11 | /// An attribute that allows parameters to receive the expression of other parameters. 12 | /// 13 | [global::System.AttributeUsage(global::System.AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] 14 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 15 | public sealed class CallerArgumentExpressionAttribute : global::System.Attribute 16 | { 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | /// The condition parameter value. 21 | public CallerArgumentExpressionAttribute(string parameterName) 22 | { 23 | ParameterName = parameterName; 24 | } 25 | 26 | /// 27 | /// Gets the parameter name the expression is retrieved from. 28 | /// 29 | public string ParameterName { get; } 30 | } 31 | } -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/System.Diagnostics.CodeAnalysis.DoesNotReturnIfAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Diagnostics.CodeAnalysis 9 | { 10 | /// 11 | /// Specifies that the method will not return if the associated Boolean parameter is passed the specified value. 12 | /// 13 | [global::System.AttributeUsage(global::System.AttributeTargets.Parameter, Inherited = false)] 14 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 15 | public sealed class DoesNotReturnIfAttribute : global::System.Attribute 16 | { 17 | /// 18 | /// Initializes the attribute with the specified parameter value. 19 | /// 20 | /// 21 | /// The condition parameter value. Code after the method will be considered unreachable 22 | /// by diagnostics if the argument to the associated parameter matches this value. 23 | /// 24 | public DoesNotReturnIfAttribute(bool parameterValue) => ParameterValue = parameterValue; 25 | 26 | /// 27 | /// Gets the condition parameter value. 28 | /// 29 | public bool ParameterValue { get; } 30 | } 31 | } -------------------------------------------------------------------------------- /.github/workflows/rust-aux01-build.yml: -------------------------------------------------------------------------------- 1 | name: Rust (Aux01) Build 2 | concurrency: build-aux01 3 | 4 | on: 5 | workflow_dispatch: 6 | 7 | jobs: 8 | call-common: 9 | uses: ./.github/workflows/common-core-build.yml 10 | name: Call Common Build 11 | permissions: 12 | contents: write 13 | with: 14 | # noinspection UndefinedParamsPresent 15 | GIT_BRANCH: rust_beta/aux01 16 | # noinspection UndefinedParamsPresent 17 | RELEASE_BODY: | 18 | This is a manually triggered development build of Carbon based on the `rust_beta/aux01` branch. 19 | This build might and probably will be very unstable and its sole purpose is for testing and/or exploring Rust's future update features in a modded environment. 20 | 21 | This build is targeted at developers or testers. 22 | The general public is advised to use one of the [stable] builds. 23 | Since it's manually triggered, we're confident you should use this build to test out the latest Carbon changes. 24 | 25 | ### How to install 26 | 1. Download the `Carbon.[Windows|Linux].Debug` archive from the attachments below. 27 | 2. Unzip the archive to the root of your Rust Dedicated Server. 28 | 3. Restart the server and enjoy. 29 | 30 | [stable]: https://github.com/CarbonCommunity/Carbon.Core/releases/latest 31 | secrets: 32 | PAT_ALL_REPO: ${{ secrets.PAT_ALL_REPO }} 33 | VERSIONS_TOKEN: ${{ secrets.VERSIONS_TOKEN }} 34 | -------------------------------------------------------------------------------- /.github/workflows/rust-aux02-build.yml: -------------------------------------------------------------------------------- 1 | name: Rust (Aux02) Build 2 | concurrency: build-aux02 3 | 4 | on: 5 | workflow_dispatch: 6 | 7 | jobs: 8 | call-common: 9 | uses: ./.github/workflows/common-core-build.yml 10 | name: Call Common Build 11 | permissions: 12 | contents: write 13 | with: 14 | # noinspection UndefinedParamsPresent 15 | GIT_BRANCH: rust_beta/aux02 16 | # noinspection UndefinedParamsPresent 17 | RELEASE_BODY: | 18 | This is a manually triggered development build of Carbon based on the `rust_beta/aux02` branch. 19 | This build might and probably will be very unstable and its sole purpose is for testing and/or exploring Rust's future update features in a modded environment. 20 | 21 | This build is targeted at developers or testers. 22 | The general public is advised to use one of the [stable] builds. 23 | Since it's manually triggered, we're confident you should use this build to test out the latest Carbon changes. 24 | 25 | ### How to install 26 | 1. Download the `Carbon.[Windows|Linux].Debug` archive from the attachments below. 27 | 2. Unzip the archive to the root of your Rust Dedicated Server. 28 | 3. Restart the server and enjoy. 29 | 30 | [stable]: https://github.com/CarbonCommunity/Carbon.Core/releases/latest 31 | secrets: 32 | PAT_ALL_REPO: ${{ secrets.PAT_ALL_REPO }} 33 | VERSIONS_TOKEN: ${{ secrets.VERSIONS_TOKEN }} 34 | -------------------------------------------------------------------------------- /.github/workflows/rust-aux03-build.yml: -------------------------------------------------------------------------------- 1 | name: Rust (Aux03) Build 2 | concurrency: build-aux03 3 | 4 | on: 5 | workflow_dispatch: 6 | 7 | jobs: 8 | call-common: 9 | uses: ./.github/workflows/common-core-build.yml 10 | name: Call Common Build 11 | permissions: 12 | contents: write 13 | with: 14 | # noinspection UndefinedParamsPresent 15 | GIT_BRANCH: rust_beta/aux03 16 | # noinspection UndefinedParamsPresent 17 | RELEASE_BODY: | 18 | This is a manually triggered development build of Carbon based on the `rust_beta/aux03` branch. 19 | This build might and probably will be very unstable and its sole purpose is for testing and/or exploring Rust's future update features in a modded environment. 20 | 21 | This build is targeted at developers or testers. 22 | The general public is advised to use one of the [stable] builds. 23 | Since it's manually triggered, we're confident you should use this build to test out the latest Carbon changes. 24 | 25 | ### How to install 26 | 1. Download the `Carbon.[Windows|Linux].Debug` archive from the attachments below. 27 | 2. Unzip the archive to the root of your Rust Dedicated Server. 28 | 3. Restart the server and enjoy. 29 | 30 | [stable]: https://github.com/CarbonCommunity/Carbon.Core/releases/latest 31 | secrets: 32 | PAT_ALL_REPO: ${{ secrets.PAT_ALL_REPO }} 33 | VERSIONS_TOKEN: ${{ secrets.VERSIONS_TOKEN }} 34 | -------------------------------------------------------------------------------- /.github/workflows/rust-release-build.yml: -------------------------------------------------------------------------------- 1 | name: Rust (Release) Build 2 | concurrency: build-release 3 | 4 | on: 5 | workflow_dispatch: 6 | 7 | jobs: 8 | call-common: 9 | uses: ./.github/workflows/common-core-build.yml 10 | name: Call Common Build 11 | permissions: 12 | contents: write 13 | with: 14 | # noinspection UndefinedParamsPresent 15 | GIT_BRANCH: rust_beta/release 16 | # noinspection UndefinedParamsPresent 17 | RELEASE_BODY: | 18 | This is a manually triggered development build of Carbon based on the `rust_beta/release` branch. 19 | This build might and probably will be very unstable and its sole purpose is for testing and/or exploring Rust's future update features in a modded environment. 20 | 21 | This build is targeted at developers or testers. 22 | The general public is advised to use one of the [stable] builds. 23 | Since it's manually triggered, we're confident you should use this build to test out the latest Carbon changes. 24 | 25 | ### How to install 26 | 1. Download the `Carbon.[Windows|Linux].Debug` archive from the attachments below. 27 | 2. Unzip the archive to the root of your Rust Dedicated Server. 28 | 3. Restart the server and enjoy. 29 | 30 | [stable]: https://github.com/CarbonCommunity/Carbon.Core/releases/latest 31 | secrets: 32 | PAT_ALL_REPO: ${{ secrets.PAT_ALL_REPO }} 33 | VERSIONS_TOKEN: ${{ secrets.VERSIONS_TOKEN }} 34 | -------------------------------------------------------------------------------- /.github/workflows/rust-staging-build.yml: -------------------------------------------------------------------------------- 1 | name: Rust (Staging) Build 2 | concurrency: build-staging 3 | 4 | on: 5 | workflow_dispatch: 6 | schedule: 7 | - cron: "00 19 * * *" 8 | 9 | jobs: 10 | call-common: 11 | uses: ./.github/workflows/common-core-build.yml 12 | name: Call Common Build 13 | permissions: 14 | contents: write 15 | with: 16 | # noinspection UndefinedParamsPresent 17 | GIT_BRANCH: rust_beta/staging 18 | # noinspection UndefinedParamsPresent 19 | RELEASE_BODY: | 20 | This is a manually triggered development build of Carbon based on the `rust_beta/staging` branch. 21 | This build might and probably will be very unstable and its sole purpose is for testing and/or exploring Rust's future update features in a modded environment. 22 | 23 | This build is targeted at developers or testers. 24 | The general public is advised to use one of the [stable] builds. 25 | Since it's manually triggered, we're confident you should use this build to test out the latest Carbon changes. 26 | 27 | ### How to install 28 | 1. Download the `Carbon.[Windows|Linux].Debug` archive from the attachments below. 29 | 2. Unzip the archive to the root of your Rust Dedicated Server. 30 | 3. Restart the server and enjoy. 31 | 32 | [stable]: https://github.com/CarbonCommunity/Carbon.Core/releases/latest 33 | secrets: 34 | PAT_ALL_REPO: ${{ secrets.PAT_ALL_REPO }} 35 | VERSIONS_TOKEN: ${{ secrets.VERSIONS_TOKEN }} 36 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tools/Carbon.Runner/Executor.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.CodeAnalysis; 2 | 3 | namespace Carbon.Runner; 4 | 5 | public abstract class Executor 6 | { 7 | public bool IsQuiet; 8 | public void SetQuiet(bool wants) => IsQuiet = wants; 9 | 10 | public virtual string? Name => null; 11 | public virtual void Run(params string[] args) 12 | { 13 | InternalRunner.Warn($"Executor {Name}.Run(..) runner is not implemented!"); 14 | } 15 | public virtual string? RunOutput(params string[] args) 16 | { 17 | InternalRunner.Warn($"Executor {Name}.Run(..) runner is not implemented!"); 18 | return null; 19 | } 20 | 21 | public void Log(object message) 22 | { 23 | if (IsQuiet) return; 24 | InternalRunner.Log($"{Name?.ToUpperInvariant()}| {message}"); 25 | } 26 | public void Warn(object message) 27 | { 28 | if (IsQuiet) return; 29 | InternalRunner.Warn($"{Name?.ToUpperInvariant()}| {message}"); 30 | } 31 | public void Error(object message) 32 | { 33 | InternalRunner.Error($"{Name?.ToUpperInvariant()}| {message}"); 34 | } 35 | 36 | public static void RegisterReference(List references, string name) 37 | { 38 | var assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(x => x.GetName().Name!.Equals(name, StringComparison.OrdinalIgnoreCase)); 39 | 40 | if (assembly == null) 41 | { 42 | InternalRunner.Error($"Couldn't register reference: {name}"); 43 | return; 44 | } 45 | 46 | references.Add(MetadataReference.CreateFromFile(assembly.Location)); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/System.Diagnostics.CodeAnalysis.NotNullIfNotNullAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Diagnostics.CodeAnalysis 9 | { 10 | /// 11 | /// Specifies that the output will be non-null if the named parameter is non-null. 12 | /// 13 | [global::System.AttributeUsage( 14 | global::System.AttributeTargets.Parameter | 15 | global::System.AttributeTargets.Property | 16 | global::System.AttributeTargets.ReturnValue, 17 | AllowMultiple = true, Inherited = false)] 18 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 19 | public sealed class NotNullIfNotNullAttribute : global::System.Attribute 20 | { 21 | /// 22 | /// Initializes the attribute with the associated parameter name. 23 | /// 24 | /// The associated parameter name. The output will be non-null if the argument to the parameter specified is non-null. 25 | public NotNullIfNotNullAttribute(string parameterName) 26 | { 27 | ParameterName = parameterName; 28 | } 29 | 30 | /// 31 | /// Gets the associated parameter name. 32 | /// 33 | public string ParameterName { get; } 34 | } 35 | } -------------------------------------------------------------------------------- /Carbon.Core/.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Carbon.Community 5 | 1.0.0 6 | Carbon 7 | Carbon Community 8 | 9 | true 10 | GPL-3.0-only 11 | NuGet-ICON.png 12 | NuGet-README.md 13 | https://github.com/CarbonCommunity/Carbon.Core 14 | Carbon is a self-updating, lightweight, intelligent mod loader for Rust utilizing the latest C# and Harmony for the best performance and stability possible, fully compatible with Oxide. 15 | Copyright © 2022-2025 Carbon Community 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/System.Runtime.CompilerServices.OverloadResolutionPriorityAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Runtime.CompilerServices 9 | { 10 | /// 11 | /// Specifies the priority of a member in overload resolution. When unspecified, the default priority is 0. 12 | /// 13 | [global::System.AttributeUsage( 14 | global::System.AttributeTargets.Method | 15 | global::System.AttributeTargets.Constructor | 16 | global::System.AttributeTargets.Property, 17 | AllowMultiple = false, 18 | Inherited = false)] 19 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 20 | public sealed class OverloadResolutionPriorityAttribute : global::System.Attribute 21 | { 22 | /// 23 | /// Initializes a new instance of the class. 24 | /// 25 | /// The priority of the attributed member. Higher numbers are prioritized, lower numbers are deprioritized. 0 is the default if no attribute is present. 26 | public OverloadResolutionPriorityAttribute(int priority) 27 | { 28 | Priority = priority; 29 | } 30 | 31 | /// 32 | /// The priority of the member. 33 | /// 34 | public int Priority { get; } 35 | } 36 | } -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tools/Carbon.Runner/.idea/.idea.Carbon.Runner/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /Tools/Build/runners/profiler.cs: -------------------------------------------------------------------------------- 1 | var target = GetArg(1, "Debug"); 2 | var defines = GetArg(2); 3 | var tag = GetArg(3, Git.RunOutput("describe", "--tags")); 4 | var version = GetVariable("VERSION"); 5 | var cargoTarget = target.Equals("Debug") || target.Equals("DebugUnix") || target.Equals("Minimal") || target.Equals("MinimalUnix") ? "release" : "prod"; 6 | var isUnix = target.Contains("Unix"); 7 | var noArchive = HasArg("-noarchive"); 8 | 9 | Run(Path(Home, "Tools", "Build", "runners", "git.cs"), tag); 10 | 11 | DotNet.ExitOnError(true); 12 | DotNet.Run("restore", PathEnquotes(Home, "Carbon.Core")); 13 | DotNet.Run("clean", PathEnquotes(Home, "Carbon.Core"), "--configuration", target); 14 | DotNet.Run("build", PathEnquotes(Home, "Carbon.Core"), "--configuration", target, "--no-restore", 15 | $"/p:UserConstants=\"{defines}\"", $"/p:UserVersion=\"{version}\""); 16 | 17 | var tos = isUnix ? "Linux" : "Windows"; 18 | 19 | if(isUnix) 20 | { 21 | Files.Copy(Path(Home, "Carbon.Core", "Carbon.Native", "target", "x86_64-unknown-linux-gnu", cargoTarget, "libCarbonNative.so"), Path(Home, "Release", ".tmp", target, "profiler", "native")); 22 | 23 | if(!noArchive) 24 | { 25 | Archive.Tar(Path(Home, "Release", ".tmp", target, "profiler"), Path(Home, "Release", $"Carbon.{tos}.Profiler.tar.gz")); 26 | } 27 | } 28 | else 29 | { 30 | Files.Copy(Path(Home, "Carbon.Core", "Carbon.Native", "target", "x86_64-pc-windows-gnu", cargoTarget, "CarbonNative.dll"), Path(Home, "Release", ".tmp", target, "profiler", "native")); 31 | 32 | if(!noArchive) 33 | { 34 | Archive.Zip(Path(Home, "Release", ".tmp", target, "profiler"), Path(Home, "Release", $"Carbon.{tos}.Profiler.zip")); 35 | } 36 | } 37 | 38 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/System.Diagnostics.CodeAnalysis.MemberNotNullAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Diagnostics.CodeAnalysis 9 | { 10 | /// 11 | /// Specifies that the method or property will ensure that the listed field and property members have not-null values. 12 | /// 13 | [global::System.AttributeUsage( 14 | global::System.AttributeTargets.Method | 15 | global::System.AttributeTargets.Property, 16 | Inherited = false, AllowMultiple = true)] 17 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 18 | public sealed class MemberNotNullAttribute : global::System.Attribute 19 | { 20 | /// 21 | /// Initializes the attribute with a field or property member. 22 | /// 23 | /// The field or property member that is promised to be not-null. 24 | public MemberNotNullAttribute(string member) => Members = new[] { member }; 25 | 26 | /// 27 | /// Initializes the attribute with the list of field and property members. 28 | /// 29 | /// The list of field and property members that are promised to be not-null. 30 | public MemberNotNullAttribute(params string[] members) => Members = members; 31 | 32 | /// 33 | /// Gets field or property member names. 34 | /// 35 | public string[] Members { get; } 36 | } 37 | } -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/System.Runtime.CompilerServices.AsyncMethodBuilderAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Runtime.CompilerServices 9 | { 10 | /// 11 | /// Indicates the type of the async method builder that should be used by a language compiler to 12 | /// build the attributed async method or to build the attributed type when used as the return type 13 | /// of an async method. 14 | /// 15 | [global::System.AttributeUsage( 16 | global::System.AttributeTargets.Class | 17 | global::System.AttributeTargets.Struct | 18 | global::System.AttributeTargets.Interface | 19 | global::System.AttributeTargets.Delegate | 20 | global::System.AttributeTargets.Enum | 21 | global::System.AttributeTargets.Method, 22 | Inherited = false, AllowMultiple = false)] 23 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 24 | public sealed class AsyncMethodBuilderAttribute : global::System.Attribute 25 | { 26 | /// Initializes the . 27 | /// The of the associated builder. 28 | public AsyncMethodBuilderAttribute(global::System.Type builderType) => BuilderType = builderType; 29 | 30 | /// Gets the of the associated builder. 31 | public global::System.Type BuilderType { get; } 32 | } 33 | } -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tests/Utils.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.InteropServices; 2 | 3 | namespace Carbon.Tests; 4 | 5 | internal static class Utils 6 | { 7 | public static void MakeExecutableExecutable(string executablePath) 8 | { 9 | if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) 10 | { 11 | File.SetUnixFileMode(executablePath, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute); 12 | } 13 | } 14 | 15 | public static Dictionary Copy( 16 | string src, string dst, 17 | bool subdirectories = true, bool overwrite = true, 18 | SearchOption option = SearchOption.AllDirectories 19 | ) 20 | { 21 | if (string.IsNullOrEmpty(src) || string.IsNullOrEmpty(dst)) 22 | { 23 | throw new Exception("Folder or destination is empty"); 24 | } 25 | 26 | if (!Directory.Exists(src)) 27 | { 28 | throw new DirectoryNotFoundException("Src folder not found"); 29 | } 30 | 31 | var folderInfo = new DirectoryInfo(src); 32 | var retDictionary = new Dictionary(); 33 | 34 | var folders = folderInfo.GetDirectories(); 35 | Directory.CreateDirectory(dst); 36 | retDictionary.Add(folderInfo.FullName, dst); 37 | 38 | var files = folderInfo.GetFiles(); 39 | foreach (var file in files) 40 | { 41 | var tempPath = Path.Combine(dst, file.Name); 42 | file.CopyTo(tempPath, overwrite); 43 | retDictionary.Add(file.FullName, tempPath); 44 | } 45 | 46 | foreach (var subDirectory in folders) 47 | { 48 | var tempPath = Path.Combine(dst, subDirectory.Name); 49 | Copy(subDirectory.FullName, tempPath, subdirectories, overwrite, option); 50 | retDictionary.Add(subDirectory.FullName, tempPath); 51 | } 52 | 53 | return retDictionary; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/RuntimeSupported/System.Runtime.Versioning.SupportedOSPlatformGuardAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Runtime.Versioning 9 | { 10 | /// 11 | /// Annotates a custom guard field, property or method with a supported platform name and optional version. 12 | /// Multiple attributes can be applied to indicate guard for multiple supported platforms. 13 | /// 14 | /// 15 | /// Callers can apply a to a field, property or method 16 | /// and use that field, property or method in a conditional or assert statements in order to safely call platform specific APIs. 17 | /// 18 | /// The type of the field or property should be boolean, the method return type should be boolean in order to be used as platform guard. 19 | /// 20 | [global::System.AttributeUsage( 21 | global::System.AttributeTargets.Field | 22 | global::System.AttributeTargets.Method | 23 | global::System.AttributeTargets.Property, 24 | AllowMultiple = true, Inherited = false)] 25 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 26 | [global::System.Diagnostics.Conditional("MULTI_TARGETING_SUPPORT_ATTRIBUTES")] 27 | public sealed class SupportedOSPlatformGuardAttribute : global::System.Attribute // OSPlatformAttribute 28 | { 29 | public SupportedOSPlatformGuardAttribute(string platformName) 30 | // : base(platformName) 31 | { 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/System.Runtime.CompilerServices.ModuleInitializerAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Runtime.CompilerServices 9 | { 10 | /// 11 | /// Used to indicate to the compiler that a method should be called 12 | /// in its containing module's initializer. 13 | /// 14 | /// 15 | /// When one or more valid methods 16 | /// with this attribute are found in a compilation, the compiler will 17 | /// emit a module initializer which calls each of the attributed methods. 18 | /// 19 | /// Certain requirements are imposed on any method targeted with this attribute: 20 | /// - The method must be `static`. 21 | /// - The method must be an ordinary member method, as opposed to a property accessor, constructor, local function, etc. 22 | /// - The method must be parameterless. 23 | /// - The method must return `void`. 24 | /// - The method must not be generic or be contained in a generic type. 25 | /// - The method's effective accessibility must be `public` or `public`. 26 | /// 27 | /// The specification for module initializers in the .NET runtime can be found here: 28 | /// https://github.com/dotnet/runtime/blob/main/docs/design/specs/Ecma-335-Augments.md#module-initializer 29 | /// 30 | [global::System.AttributeUsage(global::System.AttributeTargets.Method, Inherited = false)] 31 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 32 | public sealed class ModuleInitializerAttribute : global::System.Attribute 33 | { 34 | } 35 | } -------------------------------------------------------------------------------- /Carbon.Core/.msbuild/Common.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | false 5 | false 6 | Debug;Release;ReleaseUnix;DebugUnix;Minimal;MinimalUnix 7 | true 8 | true 9 | true 10 | 512 11 | disable 12 | preview 13 | x64 14 | en 15 | net48 16 | true 17 | true 18 | 19 | 20 | 21 | Debug 22 | x64 23 | 24 | 25 | 26 | 27 | 28 | Carbon Community 29 | Copyright © 2022-$([System.DateTime]::Now.Year) $(Authors) 30 | https://discord.gg/carbonmod 31 | https://github.com/CarbonCommunity/Carbon 32 | A very lightweight and modular Harmony-based modding framework 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /.github/workflows/edge-build.yml: -------------------------------------------------------------------------------- 1 | name: Edge Build 2 | concurrency: build-edge 3 | 4 | on: 5 | workflow_dispatch: 6 | push: 7 | branches: 8 | - develop 9 | 10 | paths-ignore: 11 | - ".github/**/*" 12 | - "**/*.md" 13 | - "Carbon.Core/Carbon.Tests/**/*" 14 | - ".gitignore" 15 | 16 | jobs: 17 | call-common: 18 | uses: ./.github/workflows/common-core-build.yml 19 | name: Call Common Build 20 | permissions: 21 | contents: write 22 | with: 23 | # noinspection UndefinedParamsPresent 24 | GIT_BRANCH: develop 25 | # noinspection UndefinedParamsPresent 26 | RELEASE_BODY: | 27 | This is a development build of Carbon based on the latest commit pushed to the repository. 28 | This build is best used to test the very last changes that can be found in the commit history list, since the [preview] and [stable] builds. 29 | 30 | This build is targeted at developers. 31 | The general public is advised to use one of the [stable] or [preview] builds. 32 | 33 | ### How to install 34 | 1. Download the `Carbon.[Windows|Linux].Debug` archive from the attachments below. 35 | 2. Unzip the archive to the root of your Rust Dedicated Server. 36 | 3. Restart the server and enjoy. 37 | 38 | [stable]: https://github.com/CarbonCommunity/Carbon.Core/releases/latest 39 | [preview]: https://github.com/CarbonCommunity/Carbon.Core/releases/preview_build 40 | secrets: 41 | PAT_ALL_REPO: ${{ secrets.PAT_ALL_REPO }} 42 | VERSIONS_TOKEN: ${{ secrets.VERSIONS_TOKEN }} 43 | 44 | call-tests: 45 | uses: ./.github/workflows/common-test.yml 46 | needs: call-common 47 | name: Call Common Tests 48 | with: 49 | build_identifier: 'develop' 50 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/RuntimeSupported/System.Runtime.Versioning.UnsupportedOSPlatformGuardAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Runtime.Versioning 9 | { 10 | /// 11 | /// Annotates the custom guard field, property or method with an unsupported platform name and optional version. 12 | /// Multiple attributes can be applied to indicate guard for multiple unsupported platforms. 13 | /// 14 | /// 15 | /// Callers can apply a to a field, property or method 16 | /// and use that field, property or method in a conditional or assert statements as a guard to safely call APIs unsupported on those platforms. 17 | /// 18 | /// The type of the field or property should be boolean, the method return type should be boolean in order to be used as platform guard. 19 | /// 20 | [global::System.AttributeUsage( 21 | global::System.AttributeTargets.Field | 22 | global::System.AttributeTargets.Method | 23 | global::System.AttributeTargets.Property, 24 | AllowMultiple = true, Inherited = false)] 25 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 26 | [global::System.Diagnostics.Conditional("MULTI_TARGETING_SUPPORT_ATTRIBUTES")] 27 | public sealed class UnsupportedOSPlatformGuardAttribute : global::System.Attribute // OSPlatformAttribute 28 | { 29 | public UnsupportedOSPlatformGuardAttribute(string platformName) 30 | // : base(platformName) 31 | { 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /Carbon.Core/.msbuild/References.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | all 33 | runtime; build; native; contentfiles; analyzers 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/RuntimeSupported/System.Runtime.CompilerServices.DisableRuntimeMarshallingAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Runtime.CompilerServices 9 | { 10 | /// 11 | /// Disables the built-in runtime managed/unmanaged marshalling subsystem for 12 | /// P/Invokes, Delegate types, and unmanaged function pointer invocations. 13 | /// 14 | /// 15 | /// The built-in marshalling subsystem has some behaviors that cannot be changed due to 16 | /// backward-compatibility requirements. This attribute allows disabling the built-in 17 | /// subsystem and instead uses the following rules for P/Invokes, Delegates, 18 | /// and unmanaged function pointer invocations: 19 | /// 20 | /// - All value types that do not contain reference type fields recursively (unmanaged in C#) are blittable 21 | /// - Value types that recursively have any fields that have [StructLayout(LayoutKind.Auto)] are disallowed from interop. 22 | /// - All reference types are disallowed from usage in interop scenarios. 23 | /// - SetLastError support in P/Invokes is disabled. 24 | /// - varargs support is disabled. 25 | /// - LCIDConversionAttribute support is disabled. 26 | /// 27 | [global::System.AttributeUsage(global::System.AttributeTargets.Assembly, Inherited = false, AllowMultiple = false)] 28 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 29 | [global::System.Diagnostics.Conditional("MULTI_TARGETING_SUPPORT_ATTRIBUTES")] 30 | public sealed class DisableRuntimeMarshallingAttribute : global::System.Attribute 31 | { 32 | } 33 | } -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/RuntimeSupported/System.Diagnostics.CodeAnalysis.FeatureGuardAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Diagnostics.CodeAnalysis 9 | { 10 | /// 11 | /// Indicates that the specified public static boolean get-only property 12 | /// guards access to the specified feature. 13 | /// 14 | /// 15 | /// Analyzers can use this to prevent warnings on calls to code that is 16 | /// annotated as requiring that feature, when the callsite is guarded by a 17 | /// call to the property. 18 | /// 19 | [global::System.AttributeUsage(global::System.AttributeTargets.Property, Inherited = false, AllowMultiple = true)] 20 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 21 | [global::System.Diagnostics.Conditional("MULTI_TARGETING_SUPPORT_ATTRIBUTES")] 22 | public sealed class FeatureGuardAttribute : global::System.Attribute 23 | { 24 | /// 25 | /// Initializes a new instance of the class 26 | /// with the specified feature type. 27 | /// 28 | /// 29 | /// The type that represents the feature guarded by the property. 30 | /// 31 | public FeatureGuardAttribute(global::System.Type featureType) 32 | { 33 | FeatureType = featureType; 34 | } 35 | 36 | /// 37 | /// The type that represents the feature guarded by the property. 38 | /// 39 | public global::System.Type FeatureType { get; } 40 | } 41 | } -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tools/Carbon.Runner/Executors/Copy.cs: -------------------------------------------------------------------------------- 1 | namespace Carbon.Runner.Executors; 2 | 3 | public class Copy : Executor 4 | { 5 | public override string? Name => "Copy"; 6 | 7 | [Expose("Copies an entire folder and its subdirectories to a destination")] 8 | public void Folder(string source, string destination, bool overwrite = true, bool optional = false) 9 | { 10 | try 11 | { 12 | if (!Directory.Exists(source)) 13 | { 14 | Error($"Could not find source folder: {source}"); 15 | return; 16 | } 17 | 18 | var folderInfo = new DirectoryInfo(source); 19 | var folders = folderInfo.GetDirectories(); 20 | Directory.CreateDirectory(destination); 21 | 22 | var files = folderInfo.GetFiles(); 23 | foreach (var file in files) 24 | { 25 | var tempPath = InternalRunner.Path(destination, file.Name); 26 | file.CopyTo(tempPath, overwrite); 27 | Log($"Copied file: {file.Name}"); 28 | } 29 | 30 | foreach (var subDirectory in folders) 31 | { 32 | var tempPath = InternalRunner.Path(destination, subDirectory.Name); 33 | Folder(subDirectory.FullName, tempPath, overwrite); 34 | Log($"Copied folder: {subDirectory.Name}"); 35 | } 36 | } 37 | catch (Exception e) 38 | { 39 | if (!optional) 40 | { 41 | Error($"Failed Copy.Folder: {e.Message}"); 42 | } 43 | } 44 | } 45 | 46 | [Expose("Copies a specific file to a destination")] 47 | public void File(string source, string destination, bool overwrite = true, bool optional = false) 48 | { 49 | try 50 | { 51 | if (!System.IO.File.Exists(source)) 52 | { 53 | Error($"Could not find source file: {source}"); 54 | return; 55 | } 56 | System.IO.File.Copy(source, destination, overwrite); 57 | } 58 | catch (Exception e) 59 | { 60 | if (!optional) 61 | { 62 | Error($"Failed Copy.File: {e.Message}"); 63 | } 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/RuntimeSupported/System.Diagnostics.CodeAnalysis.FeatureSwitchDefinitionAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Diagnostics.CodeAnalysis 9 | { 10 | /// 11 | /// Indicates that the specified public static boolean get-only property 12 | /// corresponds to the feature switch specified by name. 13 | /// 14 | /// 15 | /// IL rewriters and compilers can use this to substitute the return value 16 | /// of the specified property with the value of the feature switch. 17 | /// 18 | [global::System.AttributeUsage(global::System.AttributeTargets.Property, Inherited = false)] 19 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 20 | [global::System.Diagnostics.Conditional("MULTI_TARGETING_SUPPORT_ATTRIBUTES")] 21 | public sealed class FeatureSwitchDefinitionAttribute : global::System.Attribute 22 | { 23 | /// 24 | /// Initializes a new instance of the class 25 | /// with the specified feature switch name. 26 | /// 27 | /// 28 | /// The name of the feature switch that provides the value for the specified property. 29 | /// 30 | public FeatureSwitchDefinitionAttribute(string switchName) 31 | { 32 | SwitchName = switchName; 33 | } 34 | 35 | /// 36 | /// The name of the feature switch that provides the value for the specified property. 37 | /// 38 | public string SwitchName { get; } 39 | } 40 | } -------------------------------------------------------------------------------- /NuGet-README.md: -------------------------------------------------------------------------------- 1 | Carbon is a self-updating, lightweight, intelligent mod loader for Rust utilizing the latest C# and Harmony for the best performance and stability possible. Its robust framework and backward compatibility with Oxide plugins make it the ultimate replacement for those wanting better functionality and performance from their plugins! 2 | 3 | Carbon has all the creature comforts you need to run your server, such as a permission system, user system, and so much more. Carbon is developed by experienced developers and server owners working to take the tedium out of hosting servers and make configuration and setup seamless with an integrated GUI in-game to manage everything! 4 | 5 | ## :package: Download 6 | Start using Carbon today, download the latest version from our [releases page][production]. 7 | We also provide a [quick start script][quick-start] to get your server running in minutes, available for Windows and Linux. 8 | 9 | ## :blue_book: Documentation 10 | 11 | For more in-depth Carbon documentation, from builds and deployment, check [here][documentation]. 12 | Find all currently available hooks [here][hooks]. 13 | If you are a developer take a look at our [Wiki page][wiki]. 14 | 15 | ## :question: Support 16 | 17 | Join our official [Discord server][discord] for support, more frequent development info, discussions and future plans. 18 | 19 | ## :heart: Sponsor 20 | 21 | If you would like to [sponsor][patreon] the project the best way is to use [Patreon]. 22 | 23 | We would like to thank everyone who sponsors us. 24 | 25 | 26 | [hooks]: https://carboncommunity.gitbook.io/docs/core/hooks/carbon-hooks 27 | [wiki]: https://github.com/CarbonCommunity/Carbon.Core/wiki 28 | [discord]: https://discord.gg/eXPcNKK4yd 29 | [documentation]: https://carboncommunity.gitbook.io/docs 30 | [patreon]: https://patreon.com/CarbonCommunity 31 | [production]: https://github.com/CarbonCommunity/Carbon.Core/releases/tag/production_build 32 | [quick-start]: https://github.com/CarbonCommunity/Carbon.QuickStart 33 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/RuntimeSupported/System.Runtime.Versioning.SupportedOSPlatformAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Runtime.Versioning 9 | { 10 | /// 11 | /// Records the operating system (and minimum version) that supports an API. Multiple attributes can be 12 | /// applied to indicate support on multiple operating systems. 13 | /// 14 | /// 15 | /// Callers can apply a 16 | /// or use guards to prevent calls to APIs on unsupported operating systems. 17 | /// 18 | /// A given platform should only be specified once. 19 | /// 20 | [global::System.AttributeUsage( 21 | global::System.AttributeTargets.Assembly | 22 | global::System.AttributeTargets.Class | 23 | global::System.AttributeTargets.Constructor | 24 | global::System.AttributeTargets.Enum | 25 | global::System.AttributeTargets.Event | 26 | global::System.AttributeTargets.Field | 27 | global::System.AttributeTargets.Interface | 28 | global::System.AttributeTargets.Method | 29 | global::System.AttributeTargets.Module | 30 | global::System.AttributeTargets.Property | 31 | global::System.AttributeTargets.Struct, 32 | AllowMultiple = true, Inherited = false)] 33 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 34 | [global::System.Diagnostics.Conditional("MULTI_TARGETING_SUPPORT_ATTRIBUTES")] 35 | public sealed class SupportedOSPlatformAttribute : global::System.Attribute // OSPlatformAttribute 36 | { 37 | public SupportedOSPlatformAttribute(string platformName) 38 | // : base(platformName) 39 | { 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/RuntimeSupported/System.Runtime.Versioning.UnsupportedOSPlatformAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Runtime.Versioning 9 | { 10 | /// 11 | /// Marks APIs that were removed in a given operating system version. 12 | /// 13 | /// 14 | /// Primarily used by OS bindings to indicate APIs that are only available in 15 | /// earlier versions. 16 | /// 17 | [global::System.AttributeUsage( 18 | global::System.AttributeTargets.Assembly | 19 | global::System.AttributeTargets.Class | 20 | global::System.AttributeTargets.Constructor | 21 | global::System.AttributeTargets.Enum | 22 | global::System.AttributeTargets.Event | 23 | global::System.AttributeTargets.Field | 24 | global::System.AttributeTargets.Interface | 25 | global::System.AttributeTargets.Method | 26 | global::System.AttributeTargets.Module | 27 | global::System.AttributeTargets.Property | 28 | global::System.AttributeTargets.Struct, 29 | AllowMultiple = true, Inherited = false)] 30 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 31 | [global::System.Diagnostics.Conditional("MULTI_TARGETING_SUPPORT_ATTRIBUTES")] 32 | public sealed class UnsupportedOSPlatformAttribute : global::System.Attribute // OSPlatformAttribute 33 | { 34 | public UnsupportedOSPlatformAttribute(string platformName) 35 | // : base(platformName) 36 | { 37 | } 38 | public UnsupportedOSPlatformAttribute(string platformName, string? message) 39 | // : base(platformName) 40 | { 41 | Message = message; 42 | } 43 | 44 | public string? Message { get; } 45 | } 46 | } -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/RuntimeSupported/System.Runtime.Versioning.ObsoletedOSPlatformAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Runtime.Versioning 9 | { 10 | /// 11 | /// Marks APIs that were obsoleted in a given operating system version. 12 | /// 13 | /// 14 | /// Primarily used by OS bindings to indicate APIs that should not be used anymore. 15 | /// 16 | [global::System.AttributeUsage( 17 | global::System.AttributeTargets.Assembly | 18 | global::System.AttributeTargets.Class | 19 | global::System.AttributeTargets.Constructor | 20 | global::System.AttributeTargets.Enum | 21 | global::System.AttributeTargets.Event | 22 | global::System.AttributeTargets.Field | 23 | global::System.AttributeTargets.Interface | 24 | global::System.AttributeTargets.Method | 25 | global::System.AttributeTargets.Module | 26 | global::System.AttributeTargets.Property | 27 | global::System.AttributeTargets.Struct, 28 | AllowMultiple = true, Inherited = false)] 29 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 30 | [global::System.Diagnostics.Conditional("MULTI_TARGETING_SUPPORT_ATTRIBUTES")] 31 | public sealed class ObsoletedOSPlatformAttribute : global::System.Attribute // OSPlatformAttribute 32 | { 33 | public ObsoletedOSPlatformAttribute(string platformName) 34 | // : base(platformName) 35 | { 36 | } 37 | 38 | public ObsoletedOSPlatformAttribute(string platformName, string? message) 39 | // : base(platformName) 40 | { 41 | Message = message; 42 | } 43 | 44 | public string? Message { get; } 45 | 46 | public string? Url { get; set; } 47 | } 48 | } -------------------------------------------------------------------------------- /Carbon.Core/Carbon/src/Processors/CarbonProcessor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using API.Commands; 4 | using Carbon.Base; 5 | using Carbon.Contracts; 6 | 7 | namespace Carbon.Managers; 8 | 9 | public class CarbonProcessor : BaseProcessor, ICarbonProcessor 10 | { 11 | public override string Name => "Carbon Processor"; 12 | 13 | public override void OnDestroy() { } 14 | public override void Dispose() { } 15 | 16 | public List CurrentFrameQueue { get; set; } = new(); 17 | public List PreviousFrameQueue { get; set; } = new(); 18 | public object CurrentFrameLock { get; set; } = new(); 19 | 20 | public override void Start() 21 | { 22 | Community.Runtime.CommandManager.RegisterCommand(new Command.RCon 23 | { 24 | Name = "avgfps", 25 | Help = "Displays the server's average FPS.", 26 | Callback = arg => 27 | { 28 | arg.ReplyWith($"{Performance.report.frameRateAverage:0}"); 29 | } 30 | }, out _); 31 | Community.Runtime.CommandManager.RegisterCommand(new Command.ClientConsole 32 | { 33 | Name = "avgfps", 34 | Help = "Displays the server's average FPS.", 35 | Callback = arg => 36 | { 37 | arg.ReplyWith($"{Performance.report.frameRateAverage:0}"); 38 | }, 39 | Auth = new Command.Authentication 40 | { 41 | AuthLevel = 2 42 | } 43 | }, out _); 44 | } 45 | public void Update() 46 | { 47 | if (CurrentFrameQueue.Count <= 0) return; 48 | 49 | var lockObject = CurrentFrameLock; 50 | var queueList = (List)null; 51 | 52 | lock (lockObject) 53 | { 54 | queueList = CurrentFrameQueue; 55 | CurrentFrameQueue = PreviousFrameQueue; 56 | PreviousFrameQueue = queueList; 57 | } 58 | 59 | for (int i = 0; i < queueList.Count; i++) 60 | { 61 | try 62 | { 63 | queueList[i](); 64 | } 65 | catch (Exception exception) 66 | { 67 | Logger.Error($"Failed to execute OnFrame callback", exception.InnerException ?? exception); 68 | } 69 | } 70 | 71 | queueList.Clear(); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/RuntimeSupported/System.Runtime.CompilerServices.InlineArrayAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Runtime.CompilerServices2 9 | { 10 | /// 11 | /// Indicates that the instance's storage is sequentially replicated "length" times. 12 | /// 13 | /// 14 | /// 15 | /// This attribute can be used to annotate a type with a single field. 16 | /// The runtime will replicate that field in the actual type layout as many times as is specified. 17 | /// 18 | /// 19 | /// Here's an example of how an inline array type with 8 values can be declared: 20 | /// 21 | /// [InlineArray(8)] 22 | /// struct Float8InlineArray 23 | /// { 24 | /// private float _value; 25 | /// } 26 | /// 27 | /// 28 | /// 29 | [global::System.AttributeUsage(global::System.AttributeTargets.Struct, AllowMultiple = false)] 30 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 31 | [global::System.Diagnostics.Conditional("MULTI_TARGETING_SUPPORT_ATTRIBUTES")] 32 | public sealed class InlineArrayAttribute : global::System.Attribute 33 | { 34 | /// Creates a new instance with the specified length. 35 | /// The number of sequential fields to replicate in the inline array type. 36 | public InlineArrayAttribute(int length) 37 | { 38 | Length = length; 39 | } 40 | 41 | /// Gets the number of sequential fields to replicate in the inline array type. 42 | public int Length { get; } 43 | } 44 | } -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tests/Program.cs: -------------------------------------------------------------------------------- 1 | using Carbon.Tests.Services; 2 | using Microsoft.Extensions.Configuration; 3 | using Microsoft.Extensions.Logging; 4 | using Microsoft.Extensions.Options; 5 | 6 | namespace Carbon.Tests; 7 | 8 | internal abstract class Program 9 | { 10 | private static async Task Main(string[] _) 11 | { 12 | var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole()); 13 | 14 | var config = new ConfigurationBuilder().AddEnvironmentVariables().Build(); 15 | 16 | var appSettings = config.Get() 17 | ?? throw new Exception("App settings configuration missing"); 18 | var debugSettings = config.GetSection(ForDebugSettings.SectionName).Get() 19 | ?? new ForDebugSettings() 20 | ?? throw new Exception("Debug options are missing"); 21 | 22 | var httpClient = new HttpClient(); 23 | var processLifetimeManager = new ProcessLifetimeManager(loggerFactory.CreateLogger()); 24 | var processRunner = new ProcessRunner(processLifetimeManager); 25 | 26 | var depotDownloader = new DepotDownloaderService( 27 | processRunner, 28 | httpClient, 29 | loggerFactory.CreateLogger()); 30 | 31 | var envSetup = new EnvironmentSetupService( 32 | new OptionsWrapper(appSettings), 33 | new OptionsWrapper(debugSettings), 34 | depotDownloader, 35 | loggerFactory.CreateLogger(), 36 | httpClient); 37 | 38 | var testServerRunner = new TestServerRunner( 39 | processRunner, 40 | new OptionsWrapper(debugSettings), 41 | loggerFactory.CreateLogger()); 42 | 43 | var serverPaths = await envSetup.PrepareEnvironmentAsync(new ServerSettings(258550, appSettings.BranchName)); 44 | var allTestsSucceeded = await testServerRunner.RunTesterServerAsync(serverPaths); 45 | 46 | if (!allTestsSucceeded) 47 | { 48 | return -666; 49 | } 50 | 51 | return 0; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/System.Diagnostics.CodeAnalysis.UnscopedRefAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Diagnostics.CodeAnalysis 9 | { 10 | /// 11 | /// Used to indicate a byref escapes and is not scoped. 12 | /// 13 | /// 14 | /// 15 | /// There are several cases where the C# compiler treats a as implicitly 16 | /// - where the compiler does not allow the to escape the method. 17 | /// 18 | /// 19 | /// For example: 20 | /// 21 | /// for instance methods. 22 | /// parameters that refer to types. 23 | /// parameters. 24 | /// 25 | /// 26 | /// 27 | /// This attribute is used in those instances where the should be allowed to escape. 28 | /// 29 | /// 30 | /// Applying this attribute, in any form, has impact on consumers of the applicable API. It is necessary for 31 | /// API authors to understand the lifetime implications of applying this attribute and how it may impact their users. 32 | /// 33 | /// 34 | [global::System.AttributeUsage( 35 | global::System.AttributeTargets.Method | 36 | global::System.AttributeTargets.Property | 37 | global::System.AttributeTargets.Parameter, 38 | AllowMultiple = false, 39 | Inherited = false)] 40 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 41 | public sealed class UnscopedRefAttribute : global::System.Attribute 42 | { 43 | } 44 | } -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/System.Runtime.CompilerServices.CompilerFeatureRequiredAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Runtime.CompilerServices 9 | { 10 | /// 11 | /// Indicates that compiler support for a particular feature is required for the location where this attribute is applied. 12 | /// 13 | [global::System.AttributeUsage(global::System.AttributeTargets.All, AllowMultiple = true, Inherited = false)] 14 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 15 | public sealed class CompilerFeatureRequiredAttribute : global::System.Attribute 16 | { 17 | /// 18 | /// Creates a new instance of the type. 19 | /// 20 | /// The name of the feature to indicate. 21 | public CompilerFeatureRequiredAttribute(string featureName) 22 | { 23 | FeatureName = featureName; 24 | } 25 | 26 | /// 27 | /// The name of the compiler feature. 28 | /// 29 | public string FeatureName { get; } 30 | 31 | /// 32 | /// If true, the compiler can choose to allow access to the location where this attribute is applied if it does not understand . 33 | /// 34 | public bool IsOptional { get; set; } 35 | 36 | /// 37 | /// The used for the ref structs C# feature. 38 | /// 39 | public const string RefStructs = nameof(RefStructs); 40 | 41 | /// 42 | /// The used for the required members C# feature. 43 | /// 44 | public const string RequiredMembers = nameof(RequiredMembers); 45 | } 46 | } -------------------------------------------------------------------------------- /Tools/Build/linux/build_profiler.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | echo "** Get the base path of the script" 6 | BASE="$(cd -- "$(dirname "$0")" >/dev/null 2>&1; pwd -P)" 7 | ROOT="$(realpath "${BASE}/../../../")" 8 | 9 | "${BASE}/publish_git.sh" ${3} 10 | 11 | TARGET=${1:-Debug} 12 | echo "** Set the build target config to ${TARGET}" 13 | 14 | echo "** Cleanup the release folder" 15 | rm -rf "${ROOT}/Release/.tmp/${TARGET}/profiler" "${ROOT}/Release/Carbon.${TARGET}.Profiler.tar.gz" || exit 0 16 | 17 | if [[ "${DEFINES}" == "" ]]; then 18 | DEFINES=${2} 19 | fi 20 | 21 | if [[ "${DEFINES}" == "" ]]; then 22 | echo "** No defines." 23 | else 24 | echo "** Defines: ${DEFINES}" 25 | fi 26 | 27 | if [[ "${TARGET}" == "Debug" || "${TARGET}" == "DebugUnix" || "${TARGET}" == "Minimal" || "${TARGET}" == "MinimalUnix" ]]; then 28 | CARGO_TARGET="release" 29 | else 30 | CARGO_TARGET="prod" 31 | fi 32 | 33 | echo "** Build the solution" 34 | dotnet restore "${ROOT}/Carbon.Core" -v:m --nologo 35 | dotnet clean "${ROOT}/Carbon.Core" -v:m --configuration ${TARGET} --nologo 36 | dotnet build "${ROOT}/Carbon.Core" -v:m --configuration ${TARGET} --no-restore --no-incremental \ 37 | /p:UserConstants="${DEFINES}" /p:UserVersion="${VERSION}" 38 | 39 | echo "** Copy operating system specific files" 40 | if [[ "${TARGET}" == *"Unix"* ]]; then 41 | cp "${ROOT}/Carbon.Core/Carbon.Native/target/x86_64-unknown-linux-gnu/${CARGO_TARGET}/libCarbonNative.so" "${ROOT}/Release/.tmp/${TARGET}/profiler/native/libCarbonNative.so" 42 | else 43 | cp "${ROOT}/Carbon.Core/Carbon.Native/target/x86_64-pc-windows-msvc/${CARGO_TARGET}/CarbonNative.dll" "${ROOT}/Release/.tmp/${TARGET}/profiler/native/CarbonNative.dll" 44 | fi 45 | 46 | if [[ "${TARGET}" == *"Unix" ]]; then 47 | if [[ "${TARGET}" == "Debug"* ]]; then 48 | TOS=Linux 49 | else 50 | TOS=Linux 51 | fi 52 | else 53 | if [[ "${TARGET}" == "Debug"* ]]; then 54 | TOS=Windows 55 | else 56 | TOS=Windows 57 | fi 58 | fi 59 | 60 | if [ "${2}" != "--no-archive" ]; then 61 | echo "** Create the compressed archive" 62 | tar -zcvf "${ROOT}/Release/Carbon.${TOS}.Profiler.tar.gz" -C "${ROOT}/Release/.tmp/${TARGET}/profiler" $(ls -A ${ROOT}/Release/.tmp/${TARGET}/profiler) 63 | fi 64 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/RuntimeSupported/System.Runtime.InteropServices.UnmanagedCallersOnlyAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Runtime.InteropServices 9 | { 10 | /// 11 | /// Any method marked with can be directly called from 12 | /// native code. The function token can be loaded to a local variable using the address-of operator 13 | /// in C# and passed as a callback to a native method. 14 | /// 15 | /// 16 | /// Methods marked with this attribute have the following restrictions: 17 | /// * Method must be marked "static". 18 | /// * Must not be called from managed code. 19 | /// * Must only have blittable arguments. 20 | /// 21 | [global::System.AttributeUsage(global::System.AttributeTargets.Method, Inherited = false)] 22 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 23 | [global::System.Diagnostics.Conditional("MULTI_TARGETING_SUPPORT_ATTRIBUTES")] 24 | public sealed class UnmanagedCallersOnlyAttribute : global::System.Attribute 25 | { 26 | /// 27 | /// Optional. If omitted, the runtime will use the default platform calling convention. 28 | /// 29 | /// 30 | /// Supplied types must be from the official "System.Runtime.CompilerServices" namespace and 31 | /// be of the form "CallConvXXX". 32 | /// 33 | public global::System.Type[]? CallConvs; 34 | 35 | /// 36 | /// Optional. If omitted, no named export is emitted during compilation. 37 | /// 38 | public string? EntryPoint; 39 | } 40 | } -------------------------------------------------------------------------------- /Tools/Helpers/Carbon.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | true 4 | true 5 | true 6 | true 7 | $(MSBuildThisFileDirectory) 8 | $(RustServerRootPath)carbon/developer/patched_assemblies 9 | $(RustServerRootPath)RustDedicated_Data/Managed 10 | $(RustServerRootPath)carbon/managed 11 | $(CarbonManagedPath)/lib 12 | 13 | 14 | 15 | false 16 | 17 | 18 | false 19 | 20 | 21 | false 22 | 23 | 24 | false 25 | 26 | 27 | false 28 | 29 | 30 | false 31 | 32 | 33 | false 34 | 35 | 36 | false 37 | 38 | 39 | false 40 | 41 | 42 | false 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/RuntimeSupported/System.Diagnostics.CodeAnalysis.RequiresDynamicCodeAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Diagnostics.CodeAnalysis 9 | { 10 | /// 11 | /// Indicates that the specified method requires the ability to generate new code at runtime, 12 | /// for example through . 13 | /// 14 | /// 15 | /// This allows tools to understand which methods are unsafe to call when compiling ahead of time. 16 | /// 17 | [global::System.AttributeUsage( 18 | global::System.AttributeTargets.Method | 19 | global::System.AttributeTargets.Constructor | 20 | global::System.AttributeTargets.Class, 21 | Inherited = false)] 22 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 23 | [global::System.Diagnostics.Conditional("MULTI_TARGETING_SUPPORT_ATTRIBUTES")] 24 | public sealed class RequiresDynamicCodeAttribute : global::System.Attribute 25 | { 26 | /// 27 | /// Initializes a new instance of the class 28 | /// with the specified message. 29 | /// 30 | /// 31 | /// A message that contains information about the usage of dynamic code. 32 | /// 33 | public RequiresDynamicCodeAttribute(string message) 34 | { 35 | Message = message; 36 | } 37 | 38 | /// 39 | /// Gets a message that contains information about the usage of dynamic code. 40 | /// 41 | public string Message { get; } 42 | 43 | /// 44 | /// Gets or sets an optional URL that contains more information about the method, 45 | /// why it requires dynamic code, and what options a consumer has to deal with it. 46 | /// 47 | public string? Url { get; set; } 48 | } 49 | } -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tests/Services/ProcessRunner.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using System.Text; 3 | 4 | namespace Carbon.Tests.Services; 5 | 6 | internal class ProcessRunner 7 | { 8 | private readonly ProcessLifetimeManager _processLifetimeManager; 9 | 10 | public ProcessRunner(ProcessLifetimeManager processLifetimeManager) 11 | { 12 | _processLifetimeManager = processLifetimeManager; 13 | } 14 | 15 | public async Task RunAsync(string processName, ProcessStartInfo startInfo, int timeoutAfterMs = -1) 16 | { 17 | using var process = new Process(); 18 | process.StartInfo = startInfo; 19 | var outputBuilder = new StringBuilder(); 20 | var errorBuilder = new StringBuilder(); 21 | 22 | using var cts = new CancellationTokenSource(); 23 | if (timeoutAfterMs != -1) 24 | { 25 | cts.CancelAfter(timeoutAfterMs); 26 | } 27 | 28 | process.OutputDataReceived += (_, args) => 29 | { 30 | if (args.Data is null) 31 | { 32 | return; 33 | } 34 | 35 | outputBuilder.AppendLine(args.Data); 36 | Console.WriteLine($"[{processName}] {args.Data}"); 37 | }; 38 | 39 | process.ErrorDataReceived += (_, args) => 40 | { 41 | if (args.Data is null) 42 | { 43 | return; 44 | } 45 | 46 | errorBuilder.AppendLine(args.Data); 47 | Console.WriteLine($"[{processName} ERR] {args.Data}"); 48 | }; 49 | 50 | process.Start(); 51 | _processLifetimeManager.RegisterProcess(process); 52 | 53 | try 54 | { 55 | process.BeginOutputReadLine(); 56 | process.BeginErrorReadLine(); 57 | 58 | await process.WaitForExitAsync(cts.Token); 59 | 60 | return new ProcessResult(process.ExitCode, outputBuilder.ToString()); 61 | } 62 | catch (OperationCanceledException) 63 | { 64 | try 65 | { 66 | process.Kill(true); 67 | } 68 | catch (Exception ex) 69 | { 70 | Console.WriteLine($"[{processName}] Failed to force kill on timeout: {ex.Message}"); 71 | } 72 | 73 | throw new TimeoutException($"The process '{processName}' exceeded the timeout of {timeoutAfterMs}ms."); 74 | } 75 | finally 76 | { 77 | _processLifetimeManager.UnregisterProcess(process); 78 | } 79 | } 80 | } 81 | 82 | public record ProcessResult(int ExitCode, string StandardOutput); 83 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tools/Carbon.Publicizer.Shared/Patches/Rust.Harmony.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Linq; 4 | using Mono.Cecil.Cil; 5 | 6 | namespace Carbon.Publicizer; 7 | 8 | #pragma warning disable 9 | 10 | public class RustHarmony() : Patch(RustManagedDirectory, "Rust.Harmony.dll") 11 | { 12 | public override bool Execute() 13 | { 14 | if (!base.Execute()) return false; 15 | 16 | try 17 | { 18 | PatchLoadHarmonyMods(); 19 | } 20 | catch (Exception ex) 21 | { 22 | Console.WriteLine(ex); 23 | return false; 24 | } 25 | 26 | return true; 27 | } 28 | 29 | private void PatchLoadHarmonyMods() 30 | { 31 | var harmonyLoader = assembly.MainModule.GetType("HarmonyLoader"); 32 | var method = harmonyLoader.Methods.FirstOrDefault(x => x.Name == "LoadHarmonyMods"); 33 | var getSwitchType = facepunchSystem.MainModule.GetType("Facepunch.CommandLine")?.Methods.FirstOrDefault(x => x.Name == "GetSwitch"); 34 | 35 | if (getSwitchType == null || method is null || !method.HasBody) 36 | { 37 | return; 38 | } 39 | 40 | var tryingToLoadAssemblyLogMethod = harmonyLoader.NestedTypes.FirstOrDefault(x => x.FullName == "HarmonyLoader/<>c").Methods.FirstOrDefault(x => x.Name == "b__12_0").Body.Instructions; 41 | for (int i = 0; i < 5; i++) 42 | { 43 | tryingToLoadAssemblyLogMethod.RemoveAt(0); 44 | } 45 | 46 | var switchReference = assembly.MainModule.ImportReference(getSwitchType); 47 | var combineReference = assembly.MainModule.ImportReference(typeof(Path).GetMethod("Combine", [typeof(string), typeof(string)])); 48 | 49 | const int offset = 21; 50 | method.Body.Instructions.RemoveAt(offset); 51 | method.Body.Instructions.RemoveAt(offset); 52 | method.Body.Instructions.RemoveAt(offset); 53 | 54 | method.Body.Instructions.Insert(offset, Instruction.Create(OpCodes.Ldstr, "-harmonydir")); 55 | method.Body.Instructions.Insert(offset + 1, Instruction.Create(OpCodes.Ldloc_0)); 56 | method.Body.Instructions.Insert(offset + 2, Instruction.Create(OpCodes.Ldstr, "HarmonyMods")); 57 | method.Body.Instructions.Insert(offset + 3, Instruction.Create(OpCodes.Call, combineReference)); 58 | method.Body.Instructions.Insert(offset + 4, Instruction.Create(OpCodes.Call, switchReference)); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/RuntimeSupported/System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Diagnostics.CodeAnalysis 9 | { 10 | /// 11 | /// Indicates that the specified method requires dynamic access to code that is not referenced 12 | /// statically, for example through . 13 | /// 14 | /// 15 | /// This allows tools to understand which methods are unsafe to call when removing unreferenced 16 | /// code from an application. 17 | /// 18 | [global::System.AttributeUsage( 19 | global::System.AttributeTargets.Method | 20 | global::System.AttributeTargets.Constructor | 21 | global::System.AttributeTargets.Class, Inherited = false)] 22 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 23 | [global::System.Diagnostics.Conditional("MULTI_TARGETING_SUPPORT_ATTRIBUTES")] 24 | public sealed class RequiresUnreferencedCodeAttribute : global::System.Attribute 25 | { 26 | /// 27 | /// Initializes a new instance of the class 28 | /// with the specified message. 29 | /// 30 | /// 31 | /// A message that contains information about the usage of unreferenced code. 32 | /// 33 | public RequiresUnreferencedCodeAttribute(string message) 34 | { 35 | Message = message; 36 | } 37 | 38 | /// 39 | /// Gets a message that contains information about the usage of unreferenced code. 40 | /// 41 | public string Message { get; } 42 | 43 | /// 44 | /// Gets or sets an optional URL that contains more information about the method, 45 | /// why it requires unreferenced code, and what options a consumer has to deal with it. 46 | /// 47 | public string? Url { get; set; } 48 | } 49 | } -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/System.Runtime.Versioning.RequiresPreviewFeaturesAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Runtime.Versioning 9 | { 10 | [global::System.AttributeUsage( 11 | global::System.AttributeTargets.Assembly | 12 | global::System.AttributeTargets.Module | 13 | global::System.AttributeTargets.Class | 14 | global::System.AttributeTargets.Interface | 15 | global::System.AttributeTargets.Delegate | 16 | global::System.AttributeTargets.Struct | 17 | global::System.AttributeTargets.Enum | 18 | global::System.AttributeTargets.Constructor | 19 | global::System.AttributeTargets.Method | 20 | global::System.AttributeTargets.Property | 21 | global::System.AttributeTargets.Field | 22 | AttributeTargets.Event, Inherited = false)] 23 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 24 | public sealed class RequiresPreviewFeaturesAttribute : global::System.Attribute 25 | { 26 | /// 27 | /// Initializes a new instance of the class. 28 | /// 29 | public RequiresPreviewFeaturesAttribute() 30 | { 31 | } 32 | 33 | /// 34 | /// Initializes a new instance of the class with the specified message. 35 | /// 36 | /// An optional message associated with this attribute instance. 37 | public RequiresPreviewFeaturesAttribute(string? message) 38 | { 39 | Message = message; 40 | } 41 | 42 | /// 43 | /// Returns the optional message associated with this attribute instance. 44 | /// 45 | public string? Message { get; } 46 | 47 | /// 48 | /// Returns the optional URL associated with this attribute instance. 49 | /// 50 | public string? Url { get; set; } 51 | } 52 | } -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/System.Runtime.CompilerServices.CollectionBuilderAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Runtime.CompilerServices 9 | { 10 | [global::System.AttributeUsage( 11 | global::System.AttributeTargets.Class | 12 | global::System.AttributeTargets.Struct | 13 | global::System.AttributeTargets.Interface, 14 | Inherited = false)] 15 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 16 | public sealed class CollectionBuilderAttribute : Attribute 17 | { 18 | /// 19 | /// Initialize the attribute to refer to the method on the type. 20 | /// 21 | /// The type of the builder to use to construct the collection. 22 | /// The name of the method on the builder to use to construct the collection. 23 | /// 24 | /// must refer to a static method that accepts a single parameter of 25 | /// type and returns an instance of the collection being built containing 26 | /// a copy of the data from that span. In future releases of .NET, additional patterns may be supported. 27 | /// 28 | public CollectionBuilderAttribute(Type builderType, string methodName) 29 | { 30 | BuilderType = builderType; 31 | MethodName = methodName; 32 | } 33 | 34 | /// 35 | /// Gets the type of the builder to use to construct the collection. 36 | /// 37 | public Type BuilderType { get; } 38 | 39 | /// 40 | /// Gets the name of the method on the builder to use to construct the collection. 41 | /// 42 | /// 43 | /// This should match the metadata name of the target method. 44 | /// For example, this might be ".ctor" if targeting the type's constructor. 45 | /// 46 | public string MethodName { get; } 47 | } 48 | } -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/System.Runtime.CompilerServices.InterpolatedStringHandlerArgumentAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Runtime.CompilerServices 9 | { 10 | /// 11 | /// Indicates which arguments to a method involving an interpolated string handler should be passed to that handler. 12 | /// 13 | [global::System.AttributeUsage(global::System.AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] 14 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 15 | public sealed class InterpolatedStringHandlerArgumentAttribute : global::System.Attribute 16 | { 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | /// The name of the argument that should be passed to the handler. 21 | /// may be used as the name of the receiver in an instance method. 22 | public InterpolatedStringHandlerArgumentAttribute(string argument) 23 | { 24 | Arguments = new string[] { argument }; 25 | } 26 | 27 | /// 28 | /// Initializes a new instance of the class. 29 | /// 30 | /// The names of the arguments that should be passed to the handler. 31 | /// may be used as the name of the receiver in an instance method. 32 | public InterpolatedStringHandlerArgumentAttribute(params string[] arguments) 33 | { 34 | Arguments = arguments; 35 | } 36 | 37 | /// 38 | /// Gets the names of the arguments that should be passed to the handler. 39 | /// 40 | /// may be used as the name of the receiver in an instance method. 41 | public string[] Arguments { get; } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tests/Static/carbon/plugins/cszip_dev/Tests/Tests.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using System.Reflection; 4 | using System.Runtime.InteropServices; 5 | using Carbon.Core; 6 | using Carbon.Test; 7 | 8 | namespace Carbon.Plugins; 9 | 10 | [Info("Tests", "Carbon Community LTD", "1.0.0")] 11 | public partial class Tests : CarbonPlugin 12 | { 13 | public static Tests singleton; 14 | 15 | private void Init() 16 | { 17 | singleton = this; 18 | 19 | ToggleAllHookDebugging(false); 20 | } 21 | 22 | private void OnServerInitialized() 23 | { 24 | foreach(var type in HookableType.GetNestedTypes(BindingFlags.Public)) 25 | { 26 | Integrations.EnqueueBed(Integrations.Get(type.Name, type, Activator.CreateInstance(type))); 27 | } 28 | 29 | Integrations.EnqueueBed(Integrations.Get(nameof(Cleanup), typeof(Cleanup), new Cleanup(), channel: 5)); 30 | 31 | Logger.Log(string.Empty); 32 | 33 | Integrations.Run(delay: 0.1f, -1); 34 | Integrations.OnFatalTestFailure += OnFatalFailure; 35 | } 36 | 37 | private void OnFatalFailure() 38 | { 39 | Integrations.EnqueueBed(Integrations.Get(nameof(Cleanup), typeof(Cleanup), new Cleanup(), channel: 5)); 40 | Integrations.Run(delay: 0.1f, 5); 41 | } 42 | 43 | private static void ToggleAllHookDebugging(bool wants) 44 | { 45 | foreach (var plugin in ModLoader.Packages.SelectMany(package => package.Plugins)) 46 | { 47 | plugin.HookPool.EnableDebugging(wants); 48 | } 49 | foreach (var module in Community.Runtime.ModuleProcessor.Modules) 50 | { 51 | module.HookPool.EnableDebugging(wants); 52 | } 53 | } 54 | 55 | #if !UNIX 56 | [DllImport("kernel32.dll")] 57 | private static extern void ExitProcess(uint uExitCode); 58 | #else 59 | [DllImport("libc")] 60 | private static extern void exit(int status); 61 | #endif 62 | 63 | private class Cleanup 64 | { 65 | [Integrations.Test(Channel = 5)] 66 | public void quit(Integrations.Test test) 67 | { 68 | test.Log($"Quitting - {Integrations.ExitCode}"); 69 | ToggleAllHookDebugging(false); 70 | 71 | Rust.Application.isQuitting = true; 72 | Network.Net.sv?.Stop(nameof (quit)); 73 | UnityEngine.Application.Quit((int)Integrations.ExitCode); 74 | #if WIN 75 | ExitProcess((uint)Integrations.ExitCode); 76 | #else 77 | exit((int)Integrations.ExitCode); 78 | #endif 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/RuntimeSupported/System.Diagnostics.CodeAnalysis.RequiresAssemblyFilesAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Diagnostics.CodeAnalysis 9 | { 10 | /// 11 | /// Indicates that the specified member requires assembly files to be on disk. 12 | /// 13 | [global::System.AttributeUsage( 14 | global::System.AttributeTargets.Constructor | 15 | global::System.AttributeTargets.Event | 16 | global::System.AttributeTargets.Method | 17 | global::System.AttributeTargets.Property, 18 | Inherited = false, AllowMultiple = false)] 19 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 20 | [global::System.Diagnostics.Conditional("MULTI_TARGETING_SUPPORT_ATTRIBUTES")] 21 | public sealed class RequiresAssemblyFilesAttribute : global::System.Attribute 22 | { 23 | /// 24 | /// Initializes a new instance of the class. 25 | /// 26 | public RequiresAssemblyFilesAttribute() 27 | { 28 | } 29 | 30 | /// 31 | /// Initializes a new instance of the class. 32 | /// 33 | /// 34 | /// A message that contains information about the need for assembly files to be on disk. 35 | /// 36 | public RequiresAssemblyFilesAttribute(string message) 37 | { 38 | Message = message; 39 | } 40 | 41 | /// 42 | /// Gets an optional message that contains information about the need for 43 | /// assembly files to be on disk. 44 | /// 45 | public string? Message { get; } 46 | 47 | /// 48 | /// Gets or sets an optional URL that contains more information about the member, 49 | /// why it requires assembly files to be on disk, and what options a consumer has 50 | /// to deal with it. 51 | /// 52 | public string? Url { get; set; } 53 | } 54 | } -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tests/Services/ProcessLifetimeManager.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Concurrent; 2 | using System.Diagnostics; 3 | using Microsoft.Extensions.Logging; 4 | 5 | namespace Carbon.Tests.Services; 6 | 7 | internal class ProcessLifetimeManager : IDisposable 8 | { 9 | private readonly ConcurrentDictionary _runningProcesses = new(); 10 | private readonly ILogger _logger; 11 | 12 | public ProcessLifetimeManager(ILogger logger) 13 | { 14 | _logger = logger; 15 | AppDomain.CurrentDomain.ProcessExit += OnProcessExit; 16 | Console.CancelKeyPress += OnCancelKeyPress; 17 | } 18 | 19 | public void RegisterProcess(Process process) 20 | { 21 | if (process.HasExited) 22 | { 23 | return; 24 | } 25 | 26 | _runningProcesses.TryAdd(process.Id, process); 27 | } 28 | 29 | public void UnregisterProcess(Process process) 30 | { 31 | if (_runningProcesses.TryRemove(process.Id, out _)) 32 | { 33 | } 34 | } 35 | 36 | private void OnProcessExit(object? sender, EventArgs e) 37 | { 38 | _logger.LogInformation("ProcessExit event triggered. Cleaning up child processes..."); 39 | CleanupAllProcesses(); 40 | } 41 | 42 | private void OnCancelKeyPress(object? sender, ConsoleCancelEventArgs e) 43 | { 44 | _logger.LogInformation("CancelKeyPress event triggered. Cleaning up child processes..."); 45 | e.Cancel = true; 46 | CleanupAllProcesses(); 47 | } 48 | 49 | private void CleanupAllProcesses() 50 | { 51 | foreach (var (_, process) in _runningProcesses) 52 | { 53 | CleanupProcess(process); 54 | } 55 | } 56 | 57 | private void CleanupProcess(Process process) 58 | { 59 | try 60 | { 61 | if (process.HasExited) 62 | { 63 | return; 64 | } 65 | 66 | _logger.LogInformation("Attempting to kill process tree with ID: {ProcessId} ({ProcessName})", process.Id, process.ProcessName); 67 | process.Kill(true); 68 | process.WaitForExit(); 69 | _logger.LogInformation("Process {ProcessId} ({ProcessName}) successfully terminated.", process.Id, process.ProcessName); 70 | } 71 | catch (Exception ex) 72 | { 73 | _logger.LogError(ex, "An error occurred while terminating process {ProcessId}.", process.Id); 74 | } 75 | } 76 | 77 | public void Dispose() 78 | { 79 | AppDomain.CurrentDomain.ProcessExit -= OnProcessExit; 80 | Console.CancelKeyPress -= OnCancelKeyPress; 81 | CleanupAllProcesses(); 82 | GC.SuppressFinalize(this); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /Tools/Build/runners/update.cs: -------------------------------------------------------------------------------- 1 | var branch = GetArg(1, "release"); 2 | 3 | Warn($"Branch: {branch}"); 4 | 5 | DotNet.Run("build", PathEnquotes(Home, "Tools", "DepotDownloader", "DepotDownloader")); 6 | DotNet.Run("build", PathEnquotes(Home, "Carbon.Core", "Carbon.Tools", "Carbon.Publicizer")); 7 | DotNet.Run("build", PathEnquotes(Home, "Carbon.Core", "Carbon.Tools", "Carbon.Generator")); 8 | 9 | System.Threading.Tasks.Task.WaitAll( 10 | System.Threading.Tasks.Task.Run(() => DownloadRustFiles("windows")), 11 | System.Threading.Tasks.Task.Run(() => DownloadRustFiles("linux")) 12 | ); 13 | 14 | void DownloadRustFiles(string platform) 15 | { 16 | Log($"Downloading {platform} Rust files.."); 17 | DotNet.Run("run", "--no-build", "--project", PathEnquotes(Home, "Tools", "DepotDownloader", "DepotDownloader"), 18 | "-os", platform, 19 | "-validate", 20 | "-app 258550", 21 | "-branch", branch, 22 | "-filelist", PathEnquotes(Home, "Tools", "Helpers", "258550_refs.txt"), 23 | "-dir", PathEnquotes(Home, "Rust", platform)); 24 | 25 | var hash = Files.Hash(Path(Home, "Rust", platform, "RustDedicated_Data", "Managed", "Assembly-CSharp.dll")).ToString(); 26 | Files.Create(Path(Home, "Rust", platform, "RustDedicated_Data", "Managed", ".hash"), hash); 27 | Log($"Assembly-CSharp = {hash} [hash]"); 28 | 29 | DotNet.Run("run", "--no-build", "--project", PathEnquotes(Home, "Carbon.Core", "Carbon.Tools", "Carbon.Publicizer"), 30 | PathEnquotes(Home, "Rust", platform, "RustDedicated_Data", "Managed")); 31 | } 32 | 33 | DotNet.Run("run", "--no-build", "--project", PathEnquotes(Home, "Carbon.Core", "Carbon.Tools", "Carbon.Generator"), 34 | "--plugininput", PathEnquotes(Home, "Carbon.Core", "Carbon.Components", "Carbon.Common", "src", "Carbon", "CorePlugin"), 35 | "--rust", PathEnquotes(Home, "Rust", "windows", "RustDedicated_Data", "Managed")); 36 | 37 | var modules = new System.Collections.Generic.List(); 38 | modules.AddRange(Directories.Get(Path(Home, "Carbon.Core", "Carbon.Components", "Carbon.Common", "src", "Carbon", "Modules"))); 39 | modules.AddRange(Directories.Get(Path(Home, "Carbon.Core", "Carbon.Components", "Carbon.Modules", "src"))); 40 | 41 | var modulePaths = string.Join(";", modules); 42 | DotNet.Run("run", "--no-build", "--project", PathEnquotes(Home, "Carbon.Core", "Carbon.Tools", "Carbon.Generator"), 43 | "--plugininput", $"\"{modulePaths}\"", 44 | "--pluginnamespace", "Carbon.Modules", 45 | "--basename", "module", 46 | "--rust", PathEnquotes(Home, "Rust", "windows", "RustDedicated_Data", "Managed")); 47 | -------------------------------------------------------------------------------- /Tools/Build/linux/update.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ### 4 | ### Copyright (c) 2022-2023 Carbon Community 5 | ### All rights reserved 6 | ### 7 | 8 | BASE="$(cd -- "$(dirname "$0")" >/dev/null 2>&1; pwd -P)" 9 | ROOT="$(realpath "${BASE}/../../../")" 10 | 11 | # Get the target depot argument 12 | TARGET=${1:-release} 13 | 14 | for OS in windows linux; do 15 | # Download rust binary libs 16 | dotnet "${ROOT}/Tools/DepotDownloader/DepotDownloader/bin/Release/net8.0/DepotDownloader.dll" \ 17 | -os ${OS} -validate -app 258550 -branch ${TARGET} -filelist \ 18 | "${ROOT}/Tools/Helpers/258550_refs.txt" -dir "${ROOT}/Rust/${OS}" 19 | done 20 | 21 | dotnet restore "${ROOT}/Carbon.Core" 22 | dotnet clean "${ROOT}/Carbon.Core" --configuration Debug 23 | dotnet build "${ROOT}/Carbon.Core" --configuration Debug 24 | 25 | for OS in windows linux; do 26 | dotnet "${ROOT}/Carbon.Core/Carbon.Tools/Carbon.Publicizer/bin/x64/Debug/net8.0/Carbon.Publicizer.dll" \ 27 | -input "${ROOT}/Rust/${OS}/RustDedicated_Data/Managed" -carbon.rustrootdir "${ROOT}/Rust/${OS}" -carbon.logdir "${ROOT}/Rust/${OS}" 28 | done 29 | 30 | dotnet restore "${ROOT}/Carbon.Core" 31 | dotnet clean "${ROOT}/Carbon.Core" --configuration Debug 32 | dotnet build "${ROOT}/Carbon.Core" --configuration Debug 33 | 34 | dotnet "${ROOT}/Carbon.Core/Carbon.Tools/Carbon.Generator/bin/x64/Debug/net8.0/Carbon.Generator.dll" \ 35 | --plugininput "${ROOT}/Carbon.Core/Carbon.Components/Carbon.Common/src/Carbon/Core" \ 36 | --pluginoutput "${ROOT}/Carbon.Core/Carbon.Components/Carbon.Common/src/Carbon/Core/Core.Plugin-Generated.cs" 37 | 38 | for MODULE in "${ROOT}/Carbon.Core/Carbon.Components/Carbon.Common/src/Carbon/Modules/"*; do 39 | if [ -d "${MODULE}" ] 40 | then 41 | dotnet "${ROOT}/Carbon.Core/Carbon.Tools/Carbon.Generator/bin/x64/Debug/net8.0/Carbon.Generator.dll" \ 42 | --plugininput "${MODULE}" \ 43 | --pluginoutput "${MODULE}/$(basename "${MODULE}")-Generated.cs" \ 44 | --pluginname "$(basename "${MODULE}")" \ 45 | --pluginnamespace "Carbon.Modules" \ 46 | --basename "module" 47 | fi 48 | done 49 | 50 | for MODULE in "${ROOT}/Carbon.Core/Carbon.Components/Carbon.Modules/src/"*; do 51 | if [ -d "${MODULE}" ] 52 | then 53 | dotnet "${ROOT}/Carbon.Core/Carbon.Tools/Carbon.Generator/bin/x64/Debug/net8.0/Carbon.Generator.dll" \ 54 | --plugininput "${MODULE}" \ 55 | --pluginoutput "${MODULE}/$(basename "${MODULE}")-Generated.cs" \ 56 | --pluginname "$(basename "${MODULE}")" \ 57 | --pluginnamespace "Carbon.Modules" \ 58 | --basename "module" 59 | fi 60 | done 61 | 62 | dotnet restore "${ROOT}/Carbon.Core" --nologo 63 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tools/Carbon.Publicizer.Shared/Config.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Collections.Generic; 4 | using System.Text.RegularExpressions; 5 | using Newtonsoft.Json; 6 | 7 | namespace Carbon.Publicizer; 8 | 9 | #pragma warning disable 10 | 11 | [Serializable] 12 | public class Config 13 | { 14 | public static Config Singleton; 15 | 16 | public bool DeveloperMode { get; set; } = false; 17 | public PublicizerConfig Publicizer { get; set; } = new(); 18 | 19 | public void ForceEnsurePublicizedAssembly(string value) 20 | { 21 | if (Publicizer.PublicizedAssemblies.Contains(value)) 22 | { 23 | return; 24 | } 25 | Publicizer.PublicizedAssemblies.Add(value); 26 | } 27 | 28 | public class PublicizerConfig 29 | { 30 | public List PublicizedAssemblies { get; set; } = new(); 31 | public List PublicizerMemberIgnores { get; set; } = 32 | [ 33 | @"^HiddenValueBase$", 34 | @"^HiddenValue`1$", 35 | @"^Pool$" 36 | ]; 37 | 38 | public bool IsMemberIgnored(string name) 39 | { 40 | foreach (var item in PublicizerMemberIgnores) 41 | { 42 | if (Regex.IsMatch(name, item)) 43 | { 44 | return true; 45 | } 46 | } 47 | return false; 48 | } 49 | } 50 | 51 | public static void Init(string configFile) 52 | { 53 | if (Singleton != null) 54 | { 55 | return; 56 | } 57 | 58 | if (!File.Exists(configFile)) 59 | { 60 | Singleton = new(); 61 | } 62 | else 63 | { 64 | Singleton = JsonConvert.DeserializeObject(File.ReadAllText(configFile)); 65 | } 66 | 67 | Singleton.ForceEnsurePublicizedAssembly("Assembly-CSharp.dll"); 68 | Singleton.ForceEnsurePublicizedAssembly("Facepunch.Console.dll"); 69 | Singleton.ForceEnsurePublicizedAssembly("Facepunch.Network.dll"); 70 | Singleton.ForceEnsurePublicizedAssembly("Facepunch.Nexus.dll"); 71 | Singleton.ForceEnsurePublicizedAssembly("Facepunch.Ping.dll"); 72 | Singleton.ForceEnsurePublicizedAssembly("Facepunch.Unity.dll"); 73 | Singleton.ForceEnsurePublicizedAssembly("Facepunch.Rcon.dll"); 74 | Singleton.ForceEnsurePublicizedAssembly("Rust.Localization.dll"); 75 | Singleton.ForceEnsurePublicizedAssembly("Rust.Clans.Local.dll"); 76 | Singleton.ForceEnsurePublicizedAssembly("Rust.FileSystem.dll"); 77 | Singleton.ForceEnsurePublicizedAssembly("Rust.Harmony.dll"); 78 | Singleton.ForceEnsurePublicizedAssembly("Rust.Global.dll"); 79 | Singleton.ForceEnsurePublicizedAssembly("Rust.Data.dll"); 80 | Singleton.ForceEnsurePublicizedAssembly("Fleck.dll"); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Polyfills/src/System.Diagnostics.CodeAnalysis.MemberNotNullWhenAttribute.cs: -------------------------------------------------------------------------------- 1 | // 2 | #pragma warning disable 3 | #nullable enable annotations 4 | 5 | // Licensed to the .NET Foundation under one or more agreements. 6 | // The .NET Foundation licenses this file to you under the MIT license. 7 | 8 | namespace System.Diagnostics.CodeAnalysis 9 | { 10 | /// 11 | /// Specifies that the method or property will ensure that the listed field and property 12 | /// members have not-null values when returning with the specified return value condition. 13 | /// 14 | [global::System.AttributeUsage( 15 | global::System.AttributeTargets.Method | 16 | global::System.AttributeTargets.Property, 17 | Inherited = false, AllowMultiple = true)] 18 | [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] 19 | public sealed class MemberNotNullWhenAttribute : global::System.Attribute 20 | { 21 | /// 22 | /// Initializes the attribute with the specified return value condition and a field or property member. 23 | /// 24 | /// The return value condition. If the method returns this value, the associated parameter will not be null. 25 | /// The field or property member that is promised to be not-null. 26 | public MemberNotNullWhenAttribute(bool returnValue, string member) 27 | { 28 | ReturnValue = returnValue; 29 | Members = new[] { member }; 30 | } 31 | 32 | /// 33 | /// Initializes the attribute with the specified return value condition and list of field and property members. 34 | /// 35 | /// The return value condition. If the method returns this value, the associated parameter will not be null. 36 | /// The list of field and property members that are promised to be not-null. 37 | public MemberNotNullWhenAttribute(bool returnValue, params string[] members) 38 | { 39 | ReturnValue = returnValue; 40 | Members = members; 41 | } 42 | 43 | /// 44 | /// Gets the return value condition. 45 | /// 46 | public bool ReturnValue { get; } 47 | 48 | /// 49 | /// Gets field or property member names. 50 | /// 51 | public string[] Members { get; } 52 | } 53 | } -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tools/Carbon.Runner/Executors/Program.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | 3 | namespace Carbon.Runner.Executors; 4 | 5 | public class Program : Executor 6 | { 7 | public override string Name => "Program"; 8 | 9 | private string workingDirectory = Environment.CurrentDirectory; 10 | internal string? programFile; 11 | internal bool exitOnError; 12 | 13 | [Expose("Starts and runs a program")] 14 | public override void Run(params string[] args) 15 | { 16 | try 17 | { 18 | Log(string.Join(" ", args)); 19 | var process = Process.Start(new ProcessStartInfo 20 | { 21 | FileName = programFile, 22 | Arguments = string.Join(" ", args), 23 | WorkingDirectory = workingDirectory, 24 | UseShellExecute = false 25 | }); 26 | process!.WaitForExit(); 27 | 28 | if (exitOnError && process.ExitCode != 0) 29 | { 30 | InternalRunner.Exit(process.ExitCode); 31 | } 32 | } 33 | catch (Exception ex) 34 | { 35 | Error($"Failed Run(..) ({ex.Message})\n{ex.StackTrace}"); 36 | } 37 | } 38 | 39 | [Expose("Starts and runs a program and returns the output string")] 40 | public override string RunOutput(params string[] args) 41 | { 42 | var output = string.Empty; 43 | try 44 | { 45 | Log(string.Join(" ", args)); 46 | var process = Process.Start(new ProcessStartInfo 47 | { 48 | FileName = programFile, 49 | Arguments = string.Join(" ", args), 50 | WorkingDirectory = workingDirectory, 51 | UseShellExecute = false, 52 | RedirectStandardError = true, 53 | RedirectStandardOutput = true 54 | }); 55 | 56 | using (var reader = process!.StandardOutput) 57 | { 58 | output += reader.ReadToEnd(); 59 | } 60 | using (var reader = process.StandardError) 61 | { 62 | output += reader.ReadToEnd(); 63 | } 64 | process.WaitForExit(); 65 | } 66 | catch (Exception ex) 67 | { 68 | Error($"Failed Run(..) ({ex.Message})\n{ex.StackTrace}"); 69 | 70 | } 71 | return output; 72 | } 73 | 74 | [Expose("Overrides the working directory specifically for this process")] 75 | public Program WorkingDirectory(string workingDirectory) 76 | { 77 | this.workingDirectory = workingDirectory; 78 | return this; 79 | } 80 | 81 | [Expose("It ensures to shut down the process with a non-successful error code")] 82 | public Program ExitOnError(bool wants) 83 | { 84 | this.exitOnError = wants; 85 | return this; 86 | } 87 | 88 | [Expose("Updates the program to be executed")] 89 | public Program Setup(string programFile) 90 | { 91 | this.programFile = programFile; 92 | return this; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tools/Carbon.Runner/Executors/Files.cs: -------------------------------------------------------------------------------- 1 | using System.Security.Cryptography; 2 | 3 | #pragma warning disable SYSLIB0021 4 | 5 | namespace Carbon.Runner.Executors; 6 | 7 | public class Files : Executor 8 | { 9 | public override string Name => "Files"; 10 | 11 | [Expose("Gets a list of all files in a directory")] 12 | public string[] Get(string folder, string search = "*") => Directory.GetFiles(folder, search); 13 | 14 | [Expose("Create a file with text inside of it")] 15 | public void Create(string target, string content) => File.WriteAllText(target, content); 16 | 17 | [Expose("Copies a file if the file exists")] 18 | public void Copy(string target, string destination, bool optional = false) 19 | { 20 | if (!File.Exists(target)) 21 | { 22 | if (!optional) 23 | { 24 | Error($"File '{target}' not found!"); 25 | } 26 | return; 27 | } 28 | 29 | if (Directory.Exists(destination)) 30 | { 31 | destination = Path.Combine(destination, Path.GetFileName(target)); 32 | } 33 | 34 | var alreadyExisted = File.Exists(destination); 35 | File.Copy(target, destination, true); 36 | Warn($"{(alreadyExisted ? "Overwrote" : "Copied")} file to '{destination}'"); 37 | } 38 | 39 | [Expose("Checks if a file exists")] 40 | public bool Exists(string target) => File.Exists(target); 41 | 42 | [Expose("Deletes a file if the file exists")] 43 | public void Delete(string target, bool optional = false) 44 | { 45 | if (!File.Exists(target)) 46 | { 47 | if (!optional) 48 | { 49 | Log($"File '{target}' not found. Skipping.."); 50 | } 51 | return; 52 | } 53 | 54 | File.Delete(target); 55 | Warn($"Deleted file: '{target}'"); 56 | } 57 | 58 | [Expose("Deletes all files in a folder that contain a string in their name")] 59 | public void DeleteContains(string folder, string contains, bool optional = false) 60 | { 61 | if (!Directory.Exists(folder)) 62 | { 63 | if (!optional) 64 | { 65 | Log($"Folder '{folder}' not found. Skipping.."); 66 | } 67 | return; 68 | } 69 | 70 | var files = Get(folder); 71 | foreach (var file in files) 72 | { 73 | if (Path.GetFileNameWithoutExtension(file).Contains(contains, StringComparison.CurrentCultureIgnoreCase)) 74 | { 75 | Delete(file); 76 | } 77 | } 78 | } 79 | 80 | [Expose("Gets the hash of a file")] 81 | public uint Hash(string fileName) 82 | { 83 | if (!File.Exists(fileName)) 84 | { 85 | Error($"File not found: {fileName}"); 86 | return 0; 87 | } 88 | 89 | return BitConverter.ToUInt32(new MD5CryptoServiceProvider().ComputeHash(File.ReadAllBytes(fileName)), 0); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tools/Carbon.Publicizer.Shared/Patches/Assembly-CSharp.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Linq; 4 | using Mono.Cecil; 5 | using Mono.Cecil.Cil; 6 | using Mono.Cecil.Rocks; 7 | 8 | namespace Carbon.Publicizer; 9 | 10 | #pragma warning disable 11 | 12 | public class AssemblyCSharp() : Patch(RustManagedDirectory, "Assembly-CSharp.dll") 13 | { 14 | public override bool Execute() 15 | { 16 | if (!base.Execute()) return false; 17 | 18 | try 19 | { 20 | InjectBootstrap(); 21 | InjectIPlayer(); 22 | } 23 | catch (Exception ex) 24 | { 25 | Console.WriteLine(ex); 26 | return false; 27 | } 28 | 29 | return true; 30 | } 31 | 32 | private void InjectBootstrap() 33 | { 34 | if (bootstrap == null) 35 | { 36 | return; 37 | } 38 | 39 | var type1 = bootstrap.MainModule.GetType("Carbon", "Bootstrap") ?? throw new Exception("Unable to get a type for 'Carbon.Bootstrap'"); 40 | var method1 = type1.Methods.Single(x => x.Name == "Initialize") ?? throw new Exception("Unable to get a method definition for 'Tier0'"); 41 | var type2 = assembly.MainModule.GetType("Bootstrap") ?? throw new Exception("Unable to get a type for 'Bootstrap'"); 42 | var method2 = type2.Methods.Single(x => x.Name == "Init_Tier0") ?? throw new Exception("Unable to get a method definition for 'Init_Tier0'"); 43 | 44 | if (method2.Body.Instructions.Any(x => x.OpCode == OpCodes.Call && x.Operand.ToString().Contains("Carbon.Bootstrap::Initialize"))) 45 | { 46 | return; 47 | } 48 | 49 | var processor = method2.Body.GetILProcessor(); 50 | var instruction = processor.Create( OpCodes.Call, assembly.MainModule.ImportReference(method1)); 51 | 52 | method2.Body.Instructions[method2.Body.Instructions.Count - 1] = instruction; 53 | method2.Body.Instructions.Insert(method2.Body.Instructions.Count, processor.Create(OpCodes.Ret)); 54 | method2.Body.OptimizeMacros(); 55 | } 56 | 57 | private void InjectIPlayer() 58 | { 59 | var iplayer = assembly.MainModule.GetType("BasePlayer").Fields.FirstOrDefault(x => x.Name == "IPlayer"); 60 | 61 | if (iplayer is not null) 62 | { 63 | return; 64 | } 65 | 66 | try 67 | { 68 | var iPlayerType = common.MainModule.GetType("Oxide.Core.Libraries.Covalence", "IPlayer") ?? throw new Exception("Unable to get a type for 'API.Contracts.IPlayer'"); 69 | var basePlayerType = assembly.MainModule.GetType("BasePlayer") ?? throw new Exception("Unable to get a type for 'BasePlayer'"); 70 | basePlayerType.Fields.Add(item: new FieldDefinition("IPlayer", Mono.Cecil.FieldAttributes.Public | Mono.Cecil.FieldAttributes.NotSerialized, assembly.MainModule.ImportReference(iPlayerType))); 71 | } 72 | catch { } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "Carbon.Core/Carbon.Components/Carbon.Compat"] 2 | path = Carbon.Core/Carbon.Components/Carbon.Compat 3 | url = https://github.com/CarbonCommunity/Carbon.Compat.git 4 | branch = . 5 | [submodule "Carbon.Core/Carbon.Components/Carbon.Modules"] 6 | path = Carbon.Core/Carbon.Components/Carbon.Modules 7 | url = https://github.com/CarbonCommunity/Carbon.Modules.git 8 | branch = . 9 | [submodule "Carbon.Core/Carbon.Components/Carbon.Preloader"] 10 | path = Carbon.Core/Carbon.Components/Carbon.Preloader 11 | url = https://github.com/CarbonCommunity/Carbon.Preloader.git 12 | branch = . 13 | [submodule "Carbon.Core/Carbon.Components/Carbon.Bootstrap"] 14 | path = Carbon.Core/Carbon.Components/Carbon.Bootstrap 15 | url = https://github.com/CarbonCommunity/Carbon.Bootstrap.git 16 | branch = . 17 | [submodule "Carbon.Core/Carbon.Components/Carbon.Common"] 18 | path = Carbon.Core/Carbon.Components/Carbon.Common 19 | url = https://github.com/CarbonCommunity/Carbon.Common.git 20 | branch = . 21 | [submodule "Carbon.Core/Carbon.Components/Carbon.SDK"] 22 | path = Carbon.Core/Carbon.Components/Carbon.SDK 23 | url = https://github.com/CarbonCommunity/Carbon.SDK.git 24 | branch = . 25 | [submodule "Carbon.Core/Carbon.Hooks/Carbon.Hooks.Base"] 26 | path = Carbon.Core/Carbon.Hooks/Carbon.Hooks.Base 27 | url = https://github.com/CarbonCommunity/Carbon.Hooks.Base.git 28 | branch = . 29 | [submodule "Carbon.Core/Carbon.Hooks/Carbon.Hooks.Oxide"] 30 | path = Carbon.Core/Carbon.Hooks/Carbon.Hooks.Oxide 31 | url = https://github.com/CarbonCommunity/Carbon.Hooks.Oxide.git 32 | branch = . 33 | [submodule "Carbon.Core/Carbon.Hooks/Carbon.Hooks.Community"] 34 | path = Carbon.Core/Carbon.Hooks/Carbon.Hooks.Community 35 | url = https://github.com/CarbonCommunity/Carbon.Hooks.Community.git 36 | branch = . 37 | [submodule "Carbon.Core/Carbon.Hooks/Carbon.Hooks.Internal"] 38 | path = Carbon.Core/Carbon.Hooks/Carbon.Hooks.Internal 39 | url = https://github.com/CarbonCommunity/Carbon.Hooks.git 40 | branch = main 41 | [submodule "Carbon.Core/Carbon.Native"] 42 | path = Carbon.Core/Carbon.Native 43 | url = https://github.com/CarbonCommunity/Carbon.Native.git 44 | branch = . 45 | [submodule "Carbon.Core/Carbon.Components/Carbon.Test"] 46 | path = Carbon.Core/Carbon.Components/Carbon.Test 47 | url = https://github.com/CarbonCommunity/Carbon.Test.git 48 | branch = . 49 | [submodule "Tools/DepotDownloader"] 50 | path = Tools/DepotDownloader 51 | url = https://github.com/CarbonCommunity/Carbon.Depot.git 52 | [submodule "Carbon.Core/Carbon.Components/Carbon.Startup"] 53 | path = Carbon.Core/Carbon.Components/Carbon.Startup 54 | url = https://github.com/CarbonCommunity/Carbon.Startup.git 55 | [submodule "Carbon.Core/Carbon.Profiler"] 56 | path = Carbon.Core/Carbon.Profiler 57 | url = https://github.com/CarbonCommunity/Carbon.Profiler.git 58 | [submodule "Carbon.Core/Carbon.UniTask"] 59 | path = Carbon.Core/Carbon.UniTask 60 | url = https://github.com/CarbonCommunity/Carbon.UniTask.git 61 | -------------------------------------------------------------------------------- /Carbon.Core/.msbuild/Configurations.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | bin\$(Configuration)\ 5 | 2.0.0 6 | 7 | 8 | 9 | 10 | 11 | embedded 12 | true 13 | $(DefineConstants) 14 | true 15 | true 16 | 17 | 18 | CS1685 19 | CS1685;CS7035;CS1522;CS0618;CS0162;NU1702;NU1701;MSB3245;MSB3277;MSB3026 20 | 21 | 22 | Release 23 | 24 | 25 | 26 | 27 | embedded 28 | true 29 | MINIMAL;$(DefineConstants) 30 | true 31 | true 32 | 33 | 34 | CS1685 35 | CS1685;CS7035;CS1522;CS0618;CS0162;NU1702;NU1701;MSB3245;MSB3277;MSB3026 36 | 37 | 38 | Minimal 39 | 40 | 41 | 42 | 43 | 44 | embedded 45 | true 46 | DEBUG;UNITY_ASSERTIONS;$(DefineConstants) 47 | false 48 | false 49 | 50 | 51 | CS1685;CS7035;CS1522;CS0618;CS0162;NU1702;NU1701;MSB3245;MSB3277;MSB3026 52 | 53 | 54 | Debug 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | UNIX;$(DefineConstants);$(UserConstants) 63 | Linux 64 | linux 65 | 66 | 67 | 68 | 69 | WIN;$(DefineConstants);$(UserConstants) 70 | Windows 71 | windows 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /Tools/Build/runners/build.cs: -------------------------------------------------------------------------------- 1 | var target = GetArg(1, "Debug"); 2 | var defines = GetArg(2); 3 | var tag = GetArg(3, "edge_build"); 4 | var version = GetVariable("VERSION"); 5 | var cargoTarget = target.Equals("Debug") || target.Equals("DebugUnix") || target.Equals("Minimal") || target.Equals("MinimalUnix") ? "release" : "prod"; 6 | var isUnix = target.Contains("Unix"); 7 | var noArchive = HasArg("-noarchive"); 8 | 9 | var noClean = HasArg("-noclean"); 10 | 11 | Run(Path(Home, "Tools", "Build", "runners", "git.cs"), tag); 12 | 13 | Warn($"Tag: {tag}"); 14 | Warn($"Target: {target}"); 15 | Warn($"Defines: {defines ?? "N/A"}"); 16 | Warn($"Version: {version ?? "N/A"}"); 17 | Warn($"Cargo Target: {cargoTarget}"); 18 | 19 | if (!noClean) 20 | { 21 | Directories.Delete(Path(Home, "Release", ".tmp", target)); 22 | Files.Delete(Path(Home, "Release", $"Carbon.{target}.tar.gz")); 23 | } 24 | 25 | DotNet.ExitOnError(true); 26 | if (!noClean) 27 | { 28 | DotNet.Run("clean", PathEnquotes(Home, "Carbon.Core"), "--configuration", target); 29 | } 30 | DotNet.Run("build", PathEnquotes(Home, "Carbon.Core"), "--configuration", target, 31 | $"/p:UserConstants=\"{defines}\"", $"/p:UserVersion=\"{version}\""); 32 | 33 | Files.Copy(Path(Home, "Tools", "Helpers", "Carbon.targets"), Path(Home, "Release", ".tmp", target, "Carbon.targets")); 34 | 35 | var tos = isUnix ? "Linux" : "Windows"; 36 | var finalTarget = target.Replace("Unix", string.Empty); 37 | 38 | Files.DeleteContains(Path(Home, "Release", ".tmp", target, "carbon", "managed", "lib"), "carbon"); 39 | Directories.Delete(Path(Home, "Release", ".tmp", target, "profiler")); 40 | 41 | if (isUnix) 42 | { 43 | Files.Copy(Path(Home, "Tools", "Helpers", "carbon.sh"), Path(Home, "Release", ".tmp", target)); 44 | Files.Copy(Path(Home, "Tools", "Helpers", "environment.sh"), Path(Home, "Release", ".tmp", target, "carbon", "tools")); 45 | Files.Copy(Path(Home, "Tools", "UnityDoorstop", "linux", "x64", "libdoorstop.so"), Path(Home, "Release", ".tmp", target)); 46 | Files.Copy(Path(Home, "Carbon.Core", "Carbon.Native", "target", "x86_64-unknown-linux-gnu", cargoTarget, "libCarbonNative.so"), Path(Home, "Release", ".tmp", target, "carbon", "native"), optional: true); 47 | 48 | if (!noArchive) 49 | { 50 | Archive.Tar(Path(Home, "Release", ".tmp", target), Path(Home, "Release", $"Carbon.{tos}.{finalTarget}.tar.gz")); 51 | } 52 | } 53 | else 54 | { 55 | Files.Copy(Path(Home, "Tools", "Helpers", "doorstop_config.ini"), Path(Home, "Release", ".tmp", target)); 56 | Files.Copy(Path(Home, "Tools", "UnityDoorstop", "windows", "x64", "doorstop.dll"), Path(Home, "Release", ".tmp", target, "winhttp.dll")); 57 | Files.Copy(Path(Home, "Carbon.Core", "Carbon.Native", "target", "x86_64-pc-windows-gnu", cargoTarget, "CarbonNative.dll"), Path(Home, "Release", ".tmp", target, "carbon", "native"), optional: true); 58 | 59 | if (!noArchive) 60 | { 61 | Archive.Zip(Path(Home, "Release", ".tmp", target), Path(Home, "Release", $"Carbon.{tos}.{finalTarget}.zip")); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tests/Services/TestServerRunner.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | using System.Runtime.InteropServices; 3 | using Microsoft.Extensions.Logging; 4 | using Microsoft.Extensions.Options; 5 | 6 | namespace Carbon.Tests.Services; 7 | 8 | internal class TestServerRunner 9 | { 10 | private readonly ProcessRunner _processRunner; 11 | private readonly ForDebugSettings _forDebugSettings; 12 | private readonly ILogger _logger; 13 | 14 | public TestServerRunner(ProcessRunner processRunner, IOptions forDebugOptions, ILogger logger) 15 | { 16 | _processRunner = processRunner; 17 | _forDebugSettings = forDebugOptions.Value; 18 | _logger = logger; 19 | } 20 | 21 | public async Task RunTesterServerAsync(ServerPaths paths) 22 | { 23 | var startInfo = new ProcessStartInfo 24 | { 25 | FileName = paths.RustExecutable, 26 | Arguments = $"-nographics -batchmode -logs -silent-crashes " + 27 | $"-server.hostname THETESTER -server.identity thetester " + 28 | $"-app.port 1- " + 29 | $"-aimanager.nav_disable 1 " + 30 | $"-disable-server-occlusion -disable-server-occlusion-rocks -disableconsolelog -skipload -noconsole " + 31 | $"+server.level \"CraggyIsland\" -insecure " + 32 | $"-logfile -", 33 | RedirectStandardOutput = true, 34 | RedirectStandardError = true, 35 | UseShellExecute = false, 36 | CreateNoWindow = true, 37 | WorkingDirectory = paths.RustDirectory, 38 | }; 39 | 40 | if (_forDebugSettings.NoRustServerRun) 41 | { 42 | _logger.LogInformation("Skipped rust server run based on configuration"); 43 | return true; 44 | } 45 | 46 | if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) 47 | { 48 | var rustDirAbsolute = Path.GetFullPath(paths.RustDirectory); 49 | 50 | var envKeys = new Dictionary 51 | { 52 | { "TERM", "xterm" }, 53 | { "DOORSTOP_ENABLED", "1" }, 54 | { "DOORSTOP_TARGET_ASSEMBLY", Path.Combine(rustDirAbsolute, "carbon/managed/Carbon.Preloader.dll") }, 55 | { "LD_PRELOAD", Path.Combine(rustDirAbsolute, "libdoorstop.so") }, 56 | { "LD_LIBRARY_PATH", $"{rustDirAbsolute}:{Path.Combine(rustDirAbsolute, "RustDedicated_Data/Plugins/x86_64")}" }, 57 | // { "DOORSTOP_MONO_DEBUG_ENABLED", "1" }, 58 | // { "DOORSTOP_MONO_DEBUG_ADDRESS", "127.0.0.1:5337" }, 59 | // { "DOORSTOP_MONO_DEBUG_SUSPEND", "1" }, 60 | }; 61 | 62 | foreach (var (key, val) in envKeys) 63 | { 64 | startInfo.EnvironmentVariables[key] = val; 65 | } 66 | } 67 | 68 | _logger.LogInformation("Starting Rust server process"); 69 | 70 | var result = await _processRunner.RunAsync("RustDedicated", startInfo, 600_000); 71 | 72 | if (result.ExitCode != 0) 73 | { 74 | _logger.LogError("Tester process did not exit with positive code - exit code {ResultExitCode}", result.ExitCode); 75 | return false; 76 | } 77 | 78 | _logger.LogInformation("No failed tests detected - exit code {ResultExitCode}", result.ExitCode); 79 | 80 | return true; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tools/Carbon.Publicizer.Shared/Modifier.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Collections.Generic; 3 | using Newtonsoft.Json; 4 | 5 | namespace Carbon.Components; 6 | 7 | public partial class Modifier 8 | { 9 | public static readonly string DataType = "CarbonData"; 10 | 11 | public static ModifierBank Read(string path) 12 | { 13 | var result = !File.Exists(path) ? null : JsonConvert.DeserializeObject(File.ReadAllText(path)); 14 | if (result != null) 15 | { 16 | for (int i = 0; i < result.Count; i++) 17 | { 18 | result[i].Path = path; 19 | } 20 | } 21 | return result; 22 | } 23 | 24 | [JsonIgnore] public string Path; 25 | public string Assembly; 26 | public string Name; 27 | public List Fields = []; 28 | 29 | public Modifier WithAssembly(string value) 30 | { 31 | Assembly = value; 32 | return this; 33 | } 34 | 35 | public Modifier WithName(string value) 36 | { 37 | Name = value; 38 | return this; 39 | } 40 | 41 | public Modifier WithField(Field value) 42 | { 43 | Fields.Add(value); 44 | return this; 45 | } 46 | 47 | public Modifier WithPath(string value) 48 | { 49 | Path = value; 50 | return this; 51 | } 52 | 53 | #region Helpers 54 | 55 | public bool Validate() 56 | { 57 | return !string.IsNullOrEmpty(Assembly) && !string.IsNullOrEmpty(Name); 58 | } 59 | 60 | public bool HasSavedFields() 61 | { 62 | for (int i = 0; i < Fields.Count; i++) 63 | { 64 | if (Fields[i].ShouldSave) 65 | { 66 | return true; 67 | } 68 | } 69 | return false; 70 | } 71 | 72 | public int GetInvalidMembers() 73 | { 74 | var invalidMembers = 0; 75 | for (int i = 0; i < Fields.Count; i++) 76 | { 77 | if (Fields[i].Validate()) 78 | { 79 | continue; 80 | } 81 | invalidMembers++; 82 | } 83 | return invalidMembers; 84 | } 85 | 86 | public void ClearInvalidMembers() 87 | { 88 | for (int i = 0; i < Fields.Count; i++) 89 | { 90 | if (Fields[i].Validate()) 91 | { 92 | continue; 93 | } 94 | Fields.RemoveAt(i); 95 | i--; 96 | } 97 | } 98 | 99 | #endregion 100 | 101 | public class Field 102 | { 103 | public string Name; 104 | public string Type; 105 | public object DefaultValue; 106 | public bool IsStatic; 107 | public bool ShouldSave; 108 | 109 | public Field WithName(string value) 110 | { 111 | Name = value; 112 | return this; 113 | } 114 | 115 | public Field WithType(string value) 116 | { 117 | Type = value; 118 | return this; 119 | } 120 | 121 | public Field WithDefaultValue(object value) 122 | { 123 | DefaultValue = value; 124 | return this; 125 | } 126 | 127 | public Field WithStatic(bool wants) 128 | { 129 | IsStatic = wants; 130 | return this; 131 | } 132 | 133 | public Field WithSave(bool wants) 134 | { 135 | ShouldSave = wants; 136 | return this; 137 | } 138 | 139 | public bool Validate() 140 | { 141 | return !string.IsNullOrEmpty(Name) && !string.IsNullOrEmpty(Type); 142 | } 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /Tools/Build/linux/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ### 4 | ### Copyright (c) 2022-2023 Carbon Community 5 | ### All rights reserved 6 | ### 7 | set -e 8 | 9 | echo "** Get the base path of the script" 10 | BASE="$(cd -- "$(dirname "$0")" >/dev/null 2>&1; pwd -P)" 11 | ROOT="$(realpath "${BASE}/../../../")" 12 | 13 | "${BASE}/publish_git.sh" ${3} 14 | 15 | TARGET=${1:-Debug} 16 | echo "** Set the build target config to ${TARGET}" 17 | 18 | echo "** Cleanup the release folder" 19 | rm -rf "${ROOT}/Release/.tmp/${TARGET}" "${ROOT}/Release/Carbon.${TARGET}.tar.gz" || exit 0 20 | 21 | if [[ "${DEFINES}" == "" ]]; then 22 | DEFINES=${2} 23 | fi 24 | 25 | if [[ "${DEFINES}" == "" ]]; then 26 | echo "** No defines." 27 | else 28 | echo "** Defines: ${DEFINES}" 29 | fi 30 | 31 | if [[ "${TARGET}" == "Debug" || "${TARGET}" == "DebugUnix" || "${TARGET}" == "Minimal" || "${TARGET}" == "MinimalUnix" ]]; then 32 | CARGO_TARGET="release" 33 | else 34 | CARGO_TARGET="prod" 35 | fi 36 | 37 | echo "** Build the solution" 38 | dotnet restore "${ROOT}/Carbon.Core" -v:m --nologo 39 | dotnet clean "${ROOT}/Carbon.Core" -v:m --configuration ${TARGET} --nologo 40 | dotnet build "${ROOT}/Carbon.Core" -v:m --configuration ${TARGET} --no-restore --no-incremental \ 41 | /p:UserConstants="${DEFINES}" /p:UserVersion="${VERSION}" 42 | 43 | echo "** Copy operating system specific files" 44 | if [[ "${TARGET}" == *"Unix"* ]]; then 45 | cp "${ROOT}/Tools/Helpers/Carbon.targets" "${ROOT}/Release/.tmp/${TARGET}/Carbon.targets" 46 | cp "${ROOT}/Tools/Helpers/carbon.sh" "${ROOT}/Release/.tmp/${TARGET}/carbon.sh" 47 | cp "${ROOT}/Tools/Helpers/environment.sh" "${ROOT}/Release/.tmp/${TARGET}/carbon/tools" 48 | cp "${ROOT}/Tools/UnityDoorstop/linux/x64/libdoorstop.so" "${ROOT}/Release/.tmp/${TARGET}/libdoorstop.so" 49 | cp "${ROOT}/Carbon.Core/Carbon.Native/target/x86_64-unknown-linux-gnu/${CARGO_TARGET}/libCarbonNative.so" "${ROOT}/Release/.tmp/${TARGET}/carbon/native/libCarbonNative.so" 50 | else 51 | cp "${ROOT}/Tools/Helpers/Carbon.targets" "${ROOT}/Release/.tmp/${TARGET}" 52 | cp "${ROOT}/Tools/Helpers/doorstop_config.ini" "${ROOT}/Release/.tmp/${TARGET}" 53 | cp "${ROOT}/Tools/UnityDoorstop/windows/x64/doorstop.dll" "${ROOT}/Release/.tmp/${TARGET}/winhttp.dll" 54 | cp "${ROOT}/Carbon.Core/Carbon.Native/target/x86_64-pc-windows-msvc/${CARGO_TARGET}/CarbonNative.dll" "${ROOT}/Release/.tmp/${TARGET}/carbon/native/CarbonNative.dll" 55 | fi 56 | 57 | 58 | TAG="$1" 59 | 60 | if [[ "${TAG}" == "" ]]; then 61 | TAG="Debug" 62 | fi 63 | 64 | TAG="${TAG//Unix/}" 65 | 66 | if [[ "${TARGET}" == *"Unix" ]]; then 67 | if [[ "${TARGET}" == "Debug"* ]]; then 68 | TOS=Linux 69 | else 70 | TOS=Linux 71 | fi 72 | else 73 | if [[ "${TARGET}" == "Debug"* ]]; then 74 | TOS=Windows 75 | else 76 | TOS=Windows 77 | fi 78 | fi 79 | 80 | if [ "${2}" != "--no-archive" ]; then 81 | rm -rf "${ROOT}/Release/.tmp/${TARGET}/profiler" 82 | 83 | echo "** Create the compressed archive" 84 | tar -zcvf "${ROOT}/Release/Carbon.${TOS}.${TAG}.tar.gz" -C "${ROOT}/Release/.tmp/${TARGET}" $(ls -A ${ROOT}/Release/.tmp/${TARGET}) 85 | fi 86 | -------------------------------------------------------------------------------- /Carbon.Core/Carbon.Tests/Static/carbon/plugins/cszip_dev/Tests/Tests.Permission.cs: -------------------------------------------------------------------------------- 1 | using Carbon.Test; 2 | using Oxide.Core.Libraries; 3 | 4 | namespace Carbon.Plugins; 5 | 6 | public partial class Tests 7 | { 8 | public class Permission 9 | { 10 | public const string userId = "76561198158946080"; 11 | public const string groupId = "integrationtestgroup"; 12 | 13 | public UserData user; 14 | public GroupData group; 15 | 16 | [Integrations.Test.Assert] 17 | public void valid_id(Integrations.Test.Assert test) 18 | { 19 | test.IsTrue(singleton.permission.UserIdValid(userId), $"singleton.permission.UserIdValid(\"{userId}\")"); 20 | } 21 | 22 | [Integrations.Test.Assert(CancelOnFail = false)] 23 | public void create_user(Integrations.Test.Assert test) 24 | { 25 | test.IsFalse(singleton.permission.UserExists(userId), $"singleton.permission.UserExists(\"{userId}\")"); 26 | test.IsNull(user, "user"); 27 | 28 | user = singleton.permission.GetUserData(userId, addIfNotExisting: true); 29 | test.IsNotNull(user, "user"); 30 | } 31 | 32 | [Integrations.Test.Assert] 33 | public void create_group(Integrations.Test.Assert test) 34 | { 35 | test.IsFalse(singleton.permission.GroupExists(groupId), $"singleton.permission.GroupExists(\"{groupId}\")"); 36 | test.IsNull(group, "group"); 37 | 38 | test.IsTrue(singleton.permission.CreateGroup(groupId, groupId, 0), $"singleton.permission.CreateGroup(\"{groupId}\", \"{groupId}\", 0)"); 39 | 40 | group = singleton.permission.GetGroupData(groupId); 41 | test.IsNotNull(group, "group"); 42 | } 43 | 44 | [Integrations.Test.Assert] 45 | public void add_user_to_group(Integrations.Test.Assert test) 46 | { 47 | test.IsFalse(singleton.permission.UserHasGroup(userId, groupId), $"singleton.permission.UserHasGroup(\"{userId}\", \"{groupId}\")"); 48 | singleton.permission.AddUserGroup(userId, groupId); 49 | test.Log($"singleton.permission.AddUserGroup(\"{userId}\", \"{groupId}\")"); 50 | } 51 | 52 | [Integrations.Test.Assert] 53 | public void remove_user_from_group(Integrations.Test.Assert test) 54 | { 55 | test.IsTrue(singleton.permission.UserHasGroup(userId, groupId), $"singleton.permission.UserHasGroup(\"{userId}\", \"{groupId}\")"); 56 | singleton.permission.RemoveUserGroup(userId, groupId); 57 | test.Log($"singleton.permission.RemoveUserGroup(\"{userId}\", \"{groupId}\")"); 58 | test.IsFalse(singleton.permission.UserHasGroup(userId, groupId), $"singleton.permission.UserHasGroup(\"{userId}\", \"{groupId}\")"); 59 | } 60 | 61 | [Integrations.Test.Assert] 62 | public void delete_user(Integrations.Test.Assert test) 63 | { 64 | test.IsTrue(singleton.permission.UserExists(userId), $"singleton.permission.UserExists(\"{userId}\")"); 65 | test.IsTrue(singleton.permission.userdata.Remove(userId), $"singleton.permission.userdata.Remove(\"{userId}\")"); 66 | } 67 | 68 | [Integrations.Test.Assert] 69 | public void delete_group(Integrations.Test.Assert test) 70 | { 71 | test.IsTrue(singleton.permission.GroupExists(groupId), $"singleton.permission.GroupExists(\"{groupId}\")"); 72 | test.IsTrue(singleton.permission.groupdata.Remove(groupId), $"singleton.permission.groupdata.Remove(\"{groupId}\")"); 73 | } 74 | } 75 | } --------------------------------------------------------------------------------