Files
se-launcher/CringeLauncher/Patches/XmlRootWriterPatch.cs
pas2704 662aef1247
All checks were successful
Build / Compute Version (push) Successful in 6s
Build / Build Nuget package (NuGet) (push) Successful in 53s
Build / Build Nuget package (CringeBootstrap.Abstractions) (push) Successful in 58s
Build / Build Nuget package (SharedCringe) (push) Successful in 1m2s
Build / Build Nuget package (CringePlugins) (push) Successful in 1m19s
Build / Build Launcher (push) Successful in 1m49s
Input keybinds: hold ` for free mouse, use alt + delete to toggle free mouse
2025-05-17 18:08:44 -04:00

36 lines
1.1 KiB
C#

using System.Reflection.Emit;
using System.Xml;
using HarmonyLib;
using VRage;
namespace CringeLauncher.Patches;
[HarmonyPatch(typeof(CustomRootWriter), "Init")]
public static class XmlRootWriterPatch
{
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
var ins = instructions.ToList();
var index = ins.FindIndex(b =>
b.opcode == OpCodes.Ldstr && b.operand is "xsi:type");
ins[index].operand = "xsi";
ins.InsertRange(index + 1, new[]
{
new CodeInstruction(OpCodes.Ldstr, "type"),
new CodeInstruction(OpCodes.Ldstr, "http://www.w3.org/2001/XMLSchema-instance")
});
var instruction = ins[ins.FindIndex(b => b.opcode == OpCodes.Callvirt)];
instruction.operand = AccessTools.Method(typeof(XmlWriter), "WriteAttributeString", new[]
{
typeof(string),
typeof(string),
typeof(string),
typeof(string)
});
return ins;
}
}