
All checks were successful
Build / Compute Version (push) Successful in 6s
Build / Build Nuget package (CringeBootstrap.Abstractions) (push) Successful in 54s
Build / Build Nuget package (NuGet) (push) Successful in 53s
Build / Build Nuget package (SharedCringe) (push) Successful in 55s
Build / Build Nuget package (CringePlugins) (push) Successful in 1m18s
Build / Build Launcher (push) Successful in 6m24s
24 lines
1007 B
C#
24 lines
1007 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();
|
|
}
|
|
} |