Remove no longer necessary harmony fix

This commit is contained in:
ManlyMarco committed 2020-06-03 03:20:50 +02:00
1 parent ccbfeddbf0
commit c096209581
3 files changed
-39

No files matched your search

@@ -54,7 +54,6 @@
<Compile Include="Patching\AssemblyPatcher.cs" />
<Compile Include="Entrypoint.cs" />
<Compile Include="Patching\PatcherPlugin.cs" />
<Compile Include="RuntimeFixes\HarmonyFixes.cs" />
<Compile Include="RuntimeFixes\TraceFix.cs" />
<Compile Include="Preloader.cs" />
<Compile Include="Logger\PreloaderLogWriter.cs" />
-2
View File
@@ -43,8 +43,6 @@ namespace BepInEx.Preloader
Logger.Sources.Add(TraceLogSource.CreateSource());
HarmonyFixes.Apply();
PreloaderLog = new PreloaderConsoleListener(ConfigPreloaderCOutLogging.Value);
Logger.Listeners.Add(PreloaderLog);
@@ -1,36 +0,0 @@
using System;
using System.Diagnostics;
using HarmonyLib;
namespace BepInEx.Preloader.RuntimeFixes
{
internal static class HarmonyFixes
{
public static void Apply()
{
try
{
var harmony = new HarmonyLib.Harmony("BepInEx.Preloader.RuntimeFixes.HarmonyFixes");
harmony.Patch(AccessTools.Method(typeof(Traverse), nameof(Traverse.GetValue), new Type[0]), null, new HarmonyMethod(typeof(HarmonyFixes), nameof(GetValue)));
harmony.Patch(AccessTools.Method(typeof(Traverse), nameof(Traverse.SetValue), new []{ typeof(object) }), null, new HarmonyMethod(typeof(HarmonyFixes), nameof(SetValue)));
}
catch (Exception e)
{
Logging.Logger.LogError(e);
}
}
private static void GetValue(Traverse __instance)
{
if (!__instance.FieldExists() && !__instance.MethodExists() && !__instance.TypeExists())
Logging.Logger.LogWarning("Traverse.GetValue was called while not pointing at an existing Field, Property, Method or Type. The return value can be unexpected.\n" + new StackTrace());
}
private static void SetValue(Traverse __instance)
{
// If method exists it will crash inside traverse so only need to mention the field missing
if (!__instance.FieldExists() && !__instance.MethodExists())
Logging.Logger.LogWarning("Traverse.SetValue was called while not pointing at an existing Field or Property. The call will have no effect.\n" + new StackTrace());
}
}
}