All checks were successful
Build / Compute Version (push) Successful in 6s
Build / Build Nuget package (CringeBootstrap.Abstractions) (push) Successful in 4m4s
Build / Build Nuget package (NuGet) (push) Successful in 4m7s
Build / Build Nuget package (SharedCringe) (push) Successful in 4m5s
Build / Build Nuget package (CringePlugins) (push) Successful in 4m25s
Build / Build Launcher (push) Successful in 5m12s
Also ran cleanup
24 lines
1003 B
C#
24 lines
1003 B
C#
using System.Reflection.Emit;
|
|
using HarmonyLib;
|
|
using Microsoft.CodeAnalysis;
|
|
using Microsoft.CodeAnalysis.CSharp;
|
|
using VRage.Scripting;
|
|
|
|
namespace CringeLauncher.Patches;
|
|
|
|
[HarmonyPatch(typeof(MyScriptCompiler), nameof(MyScriptCompiler.CreateCompilation))]
|
|
public static class ScriptCompilationSettingsPatch
|
|
{
|
|
private static readonly CSharpParseOptions Options = new(LanguageVersion.Latest, DocumentationMode.None);
|
|
|
|
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
|
|
{
|
|
var field = AccessTools.Field(typeof(MyScriptCompiler), nameof(MyScriptCompiler.m_conditionalParseOptions));
|
|
return new CodeMatcher(instructions)
|
|
.Start()
|
|
.MatchStartForward(CodeMatch.IsLdarg(0), CodeMatch.LoadsField(field))
|
|
.SetAndAdvance(OpCodes.Nop, null)
|
|
.SetInstructionAndAdvance(CodeInstruction.LoadField(typeof(ScriptCompilationSettingsPatch), nameof(Options)))
|
|
.Instructions();
|
|
}
|
|
} |