wtf is that
This commit is contained in:
@@ -96,9 +96,6 @@ public abstract class PluginData : IEquatable<PluginData>
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Precompile the entire assembly in order to force any missing method exceptions
|
|
||||||
LogFile.WriteLine("Precompiling " + a);
|
|
||||||
LoaderTools.Precompile(a);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
@@ -141,56 +141,6 @@ public static class LoaderTools
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This method attempts to disable JIT compiling for the assembly.
|
|
||||||
/// This method will force any member access exceptions by methods to be thrown now instead of later.
|
|
||||||
/// </summary>
|
|
||||||
public static void Precompile(Assembly a)
|
|
||||||
{
|
|
||||||
Type[] types;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
types = a.GetTypes();
|
|
||||||
}
|
|
||||||
catch (ReflectionTypeLoadException e)
|
|
||||||
{
|
|
||||||
var sb = new StringBuilder();
|
|
||||||
sb.AppendLine("LoaderExceptions: ");
|
|
||||||
foreach (var e2 in e.LoaderExceptions)
|
|
||||||
sb.Append(e2).AppendLine();
|
|
||||||
LogFile.WriteLine(sb.ToString());
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var t in types)
|
|
||||||
{
|
|
||||||
// Static constructors allow for early code execution which can cause issues later in the game
|
|
||||||
if (HasStaticConstructor(t))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
foreach (var m in t.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.NonPublic | BindingFlags.Public |
|
|
||||||
BindingFlags.Instance | BindingFlags.Static))
|
|
||||||
{
|
|
||||||
if (m.HasAttribute<HarmonyReversePatch>())
|
|
||||||
throw new("Harmony attribute 'HarmonyReversePatch' found on the method '" + m.Name +
|
|
||||||
"' is not compatible with Plugin Loader!");
|
|
||||||
Precompile(m);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void Precompile(MethodInfo m)
|
|
||||||
{
|
|
||||||
if (!m.IsAbstract && !m.ContainsGenericParameters)
|
|
||||||
RuntimeHelpers.PrepareMethod(m.MethodHandle);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static bool HasStaticConstructor(Type t)
|
|
||||||
{
|
|
||||||
return t.GetConstructors(BindingFlags.Public | BindingFlags.Static | BindingFlags.NonPublic |
|
|
||||||
BindingFlags.Instance).Any(c => c.IsStatic);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static void OpenFileDialog(string title, string directory, string filter, Action<string> onOk)
|
public static void OpenFileDialog(string title, string directory, string filter, Action<string> onOk)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user