port over script compiler patch changes
This commit is contained in:
25
Torch/Patches/DarkTardMissingNamespacePatch.cs
Normal file
25
Torch/Patches/DarkTardMissingNamespacePatch.cs
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using Sandbox.Game.World;
|
||||||
|
using Torch.Managers.PatchManager;
|
||||||
|
using Torch.Utils;
|
||||||
|
|
||||||
|
namespace Torch.Patches;
|
||||||
|
|
||||||
|
[PatchShim]
|
||||||
|
internal static class DarkTardMissingNamespacePatch
|
||||||
|
{
|
||||||
|
public static void Patch(PatchContext ctx)
|
||||||
|
{
|
||||||
|
ctx.GetPattern(Info.OfMethod<MyScriptManager>(nameof(MyScriptManager.Init))).AddPrefix();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Prefix(Dictionary<string, string> ___m_compatibilityChanges)
|
||||||
|
{
|
||||||
|
___m_compatibilityChanges["using System.Runtime.Remoting.Metadata.W3cXsd2001;"] = "";
|
||||||
|
___m_compatibilityChanges["using System.IO.Ports;"] = "";
|
||||||
|
___m_compatibilityChanges["using System.Runtime.Remoting;"] = "";
|
||||||
|
___m_compatibilityChanges["using System.Runtime.Remoting.Messaging;"] = "";
|
||||||
|
___m_compatibilityChanges["using System.Numerics;"] = "";
|
||||||
|
___m_compatibilityChanges["using System.Runtime.Remoting.Lifetime;"] = "";
|
||||||
|
}
|
||||||
|
}
|
@@ -22,20 +22,22 @@ namespace Torch.Patches
|
|||||||
[PatchShim]
|
[PatchShim]
|
||||||
public static class ScriptCompilerPatch
|
public static class ScriptCompilerPatch
|
||||||
{
|
{
|
||||||
[ReflectedMethodInfo(typeof(MyScriptWhitelist), "Register", Parameters = new[] {typeof(MyWhitelistTarget), typeof(INamespaceSymbol), typeof(Type)})]
|
[ReflectedMethodInfo(typeof(MyScriptWhitelist), "Register", Parameters = [typeof(MyWhitelistTarget), typeof(INamespaceSymbol), typeof(Type)])]
|
||||||
private static MethodInfo _register1Method;
|
private static MethodInfo _register1Method;
|
||||||
|
|
||||||
[ReflectedMethodInfo(typeof(MyScriptWhitelist), "Register", Parameters = new[] {typeof(MyWhitelistTarget), typeof(ITypeSymbol), typeof(Type)})]
|
[ReflectedMethodInfo(typeof(MyScriptWhitelist), "Register", Parameters = [typeof(MyWhitelistTarget), typeof(ITypeSymbol), typeof(Type)])]
|
||||||
private static MethodInfo _register2Method;
|
private static MethodInfo _register2Method;
|
||||||
|
|
||||||
|
[ReflectedMethodInfo(null, "AllowMembers", TypeName = "VRage.Scripting.MyScriptWhitelist+MyWhitelistBatch, VRage.Scripting")]
|
||||||
|
private static MethodInfo _allowMembersMethod;
|
||||||
|
|
||||||
public static void Patch(PatchContext context)
|
public static void Patch(PatchContext context)
|
||||||
{
|
{
|
||||||
context.GetPattern(typeof(MyScriptWhitelist).GetConstructor(new[] {typeof(MyScriptCompiler)}))
|
context.GetPattern(typeof(MyScriptWhitelist).GetConstructor(new[] {typeof(MyScriptCompiler)}))
|
||||||
.AddPrefix(nameof(WhitelistCtorPrefix));
|
.AddPrefix(nameof(WhitelistCtorPrefix));
|
||||||
context.GetPattern(Type.GetType("VRage.Scripting.MyVRageScriptingInternal, VRage.Scripting", true).GetMethod("Initialize"))
|
context.GetPattern(Info.OfMethod("VRage.Scripting", "VRage.Scripting.MyVRageScriptingInternal", "Initialize"))
|
||||||
.AddPrefix(nameof(InitializePrefix));
|
.AddPrefix(nameof(InitializePrefix));
|
||||||
context.GetPattern(typeof(MyScriptWhitelist).GetNestedType("MyWhitelistBatch", BindingFlags.NonPublic)!
|
context.GetPattern(_allowMembersMethod).AddPrefix(nameof(AllowMembersPrefix));
|
||||||
.GetMethod("AllowMembers")).AddPrefix(nameof(AllowMembersPrefix));
|
|
||||||
context.GetPattern(_register1Method).AddTranspiler(nameof(RegisterTranspiler));
|
context.GetPattern(_register1Method).AddTranspiler(nameof(RegisterTranspiler));
|
||||||
context.GetPattern(_register2Method).AddTranspiler(nameof(RegisterTranspiler));
|
context.GetPattern(_register2Method).AddTranspiler(nameof(RegisterTranspiler));
|
||||||
}
|
}
|
||||||
@@ -56,9 +58,10 @@ namespace Torch.Patches
|
|||||||
typeof(System.Diagnostics.TraceSource).Assembly.Location,
|
typeof(System.Diagnostics.TraceSource).Assembly.Location,
|
||||||
typeof(System.Security.Policy.Evidence).Assembly.Location,
|
typeof(System.Security.Policy.Evidence).Assembly.Location,
|
||||||
Path.Combine(baseDir, "System.Xml.ReaderWriter.dll"),
|
Path.Combine(baseDir, "System.Xml.ReaderWriter.dll"),
|
||||||
|
Path.Combine(MyFileSystem.ExePath, "ProtoBuf.Net.dll"),
|
||||||
|
Path.Combine(MyFileSystem.ExePath, "ProtoBuf.Net.Core.dll"),
|
||||||
Path.Combine(baseDir, "netstandard.dll"),
|
Path.Combine(baseDir, "netstandard.dll"),
|
||||||
Path.Combine(baseDir, "System.Runtime.dll"),
|
Path.Combine(baseDir, "System.Runtime.dll"),
|
||||||
Path.Combine(MyFileSystem.ExePath, "ProtoBuf.Net.Core.dll"),
|
|
||||||
Path.Combine(MyFileSystem.ExePath, "Sandbox.Game.dll"),
|
Path.Combine(MyFileSystem.ExePath, "Sandbox.Game.dll"),
|
||||||
Path.Combine(MyFileSystem.ExePath, "Sandbox.Common.dll"),
|
Path.Combine(MyFileSystem.ExePath, "Sandbox.Common.dll"),
|
||||||
Path.Combine(MyFileSystem.ExePath, "Sandbox.Graphics.dll"),
|
Path.Combine(MyFileSystem.ExePath, "Sandbox.Graphics.dll"),
|
||||||
@@ -80,6 +83,7 @@ namespace Torch.Patches
|
|||||||
|
|
||||||
using var batch = MyScriptCompiler.Static.Whitelist.OpenBatch();
|
using var batch = MyScriptCompiler.Static.Whitelist.OpenBatch();
|
||||||
batch.AllowTypes(MyWhitelistTarget.ModApi, typeof(ConcurrentQueue<>));
|
batch.AllowTypes(MyWhitelistTarget.ModApi, typeof(ConcurrentQueue<>));
|
||||||
|
batch.AllowNamespaceOfTypes(MyWhitelistTarget.Both, typeof(ImmutableArray));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
21
Torch/Patches/TypeTableRegisterPatch.cs
Normal file
21
Torch/Patches/TypeTableRegisterPatch.cs
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using Torch.Managers.PatchManager;
|
||||||
|
using Torch.Utils;
|
||||||
|
using VRage.Network;
|
||||||
|
|
||||||
|
namespace Torch.Patches;
|
||||||
|
|
||||||
|
[PatchShim]
|
||||||
|
internal static class TypeTableRegisterPatch
|
||||||
|
{
|
||||||
|
public static void Patch(PatchContext context)
|
||||||
|
{
|
||||||
|
context.GetPattern(Info.OfMethod<MyTypeTable>("IsSerializableClass")).AddSuffix();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Suffix(Type type, ref bool __result)
|
||||||
|
{
|
||||||
|
if (type == typeof(Delegate) || type == typeof(MulticastDelegate))
|
||||||
|
__result = true;
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user