Browse Source

Slightly changed some stuff to try to fix loading issues

pull/1/head
Anairkoen Schno 5 years ago
parent
commit
a29f741373
5 changed files with 40 additions and 8 deletions
  1. +32
    -4
      IPA.Injector/Injector.cs
  2. +3
    -2
      IPA.Loader/IPA.Loader.csproj
  3. +1
    -1
      IPA.Loader/Logging/Logger.cs
  4. +4
    -1
      IPA.Loader/Logging/UnityLogProvider.cs
  5. BIN
      Refs/UnityEngine.CoreModule.dll

+ 32
- 4
IPA.Injector/Injector.cs View File

@ -8,6 +8,7 @@ using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.ExceptionServices;
using System.Threading.Tasks;
using UnityEngine;
using static IPA.Logging.Logger;
@ -54,7 +55,34 @@ namespace IPA.Injector
loader.Debug("Prepping bootstrapper");
InstallBootstrapPatch();
// The whole mess that follows is an attempt to work around Mono failing to
// call the library load routine for Mono.Cecil when the debugger is attached.
bool runProperly = false;
while (!runProperly) // retry until it finishes, or errors
try
{
InstallBootstrapPatch();
runProperly = true;
}
catch (FileNotFoundException e)
{
var asmName = e.FileName;
AssemblyName name;
try
{ // try to parse as an AssemblyName, if it isn't, rethrow the outer exception
name = new AssemblyName(asmName);
}
catch (Exception)
{
ExceptionDispatchInfo.Capture(e).Throw();
throw;
}
// name is failed lookup, try to manually load it
LibLoader.AssemblyLibLoader(null,
new ResolveEventArgs(name.FullName, Assembly.GetExecutingAssembly()));
}
Updates.InstallPendingUpdates();
@ -205,9 +233,9 @@ namespace IPA.Injector
Application.logMessageReceived += delegate (string condition, string stackTrace, LogType type)
{
var level = UnityLogInterceptor.LogTypeToLevel(type);
UnityLogInterceptor.UnityLogger.Log(level, $"{condition.Trim()}");
UnityLogInterceptor.UnityLogger.Log(level, $"{stackTrace.Trim()}");
var level = UnityLogRedirector.LogTypeToLevel(type);
UnityLogProvider.UnityLogger.Log(level, $"{condition.Trim()}");
UnityLogProvider.UnityLogger.Log(level, $"{stackTrace.Trim()}");
};
// need to reinit streams singe Unity seems to redirect stdout


+ 3
- 2
IPA.Loader/IPA.Loader.csproj View File

@ -62,7 +62,8 @@
<Compile Include="Config\SelfConfig.cs" />
<Compile Include="Loader\Composite\CompositeBSPlugin.cs" />
<Compile Include="Loader\LibLoader.cs" />
<Compile Include="Loader\Features\Feature.cs" /> <Compile Include="Loader\PluginLoader.cs" />
<Compile Include="Loader\Features\Feature.cs" />
<Compile Include="Loader\PluginLoader.cs" />
<Compile Include="Loader\PluginManifest.cs" />
<Compile Include="Logging\Printers\PluginSubLogPrinter.cs" />
<Compile Include="PluginInterfaces\BeatSaber\IBeatSaberPlugin.cs" />
@ -87,7 +88,7 @@
<Compile Include="Logging\Printers\GZFilePrinter.cs" />
<Compile Include="Logging\Printers\PluginLogFilePrinter.cs" />
<Compile Include="Logging\StandardLogger.cs" />
<Compile Include="Logging\UnityLogInterceptor.cs" />
<Compile Include="Logging\UnityLogProvider.cs" />
<Compile Include="Loader\PluginComponent.cs" />
<Compile Include="Loader\PluginManager.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />


+ 1
- 1
IPA.Loader/Logging/Logger.cs View File

@ -25,7 +25,7 @@ namespace IPA.Logging
internal static Logger libLoader => log.GetChildLogger("LibraryLoader");
internal static Logger loader => log.GetChildLogger("Loader");
internal static Logger config => log.GetChildLogger("Config");
internal static bool LogCreated => _log != null || UnityLogInterceptor.Logger != null;
internal static bool LogCreated => _log != null || UnityLogProvider.Logger != null;
/// <summary>
/// The standard format for log messages.


IPA.Loader/Logging/UnityLogInterceptor.cs → IPA.Loader/Logging/UnityLogProvider.cs View File

@ -2,11 +2,14 @@
namespace IPA.Logging
{
internal static class UnityLogInterceptor
internal static class UnityLogProvider
{
internal static Logger Logger;
public static Logger UnityLogger => Logger ?? (Logger = new StandardLogger("UnityEngine"));
}
internal static class UnityLogRedirector
{
public static Logger.Level LogTypeToLevel(LogType type)
{
switch (type)

BIN
Refs/UnityEngine.CoreModule.dll View File


Loading…
Cancel
Save