In this case a broken mod is examined during the bootstrap phase of handover, which causes an uncaught ReflectionTypeLoadException. Exception handlers are not diverted yet at bootstrap time, so these exceptions end up preventing handover and polluting the log file.
Problem 1
The handover algo should not look at Plugins.PluginInfo:get_userModInstance which causes the mod to be instantiated, ie, the types to be resolved.
Problem 2
There should be no way for the handover to throw, so it needs a try...catch with any exception logged as a SelfProblem
To reproduce
This exception can be triggered with sway2020/YetAnotherToolbar@3317a066, which suffers from the "public class patcher" problem, aka #9 (@sway2020, if you read this, fixing this bug won't fix yours):
[Harmony 0.9] 2448994345 threw: TypeLoadException: Could not load type `YetAnotherToolbar.Patcher` from assembly `YetAnotherToolbar, Version=1.1.2.0, Culture=neutral, PublicKeyToken=null`.
Symptom (stack trace)
Loading C:\Users\yanni\AppData\Local\Colossal Order\Cities_Skylines\UndoMod.cgs [Settings - Internal]
ReflectionTypeLoadException: The classes in the module cannot be loaded.
at (wrapper m
[d0c52a38.txt](https://github.com/drok/Harmony-CitiesSkylines/files/7954860/d0c52a38.txt)
anaged-to-native) System.Reflection.Assembly:GetTypes (bool)
at System.Reflection.Assembly.GetExportedTypes () [0x00000] in <filename unknown>:0
at ColossalFramework.Plugins.PluginManager+PluginInfo.get_userModInstance () [0x00000] in <filename unknown>:0
UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
UnityEngine.DebugLogHandler:LogException(Exception, Object)
UnityEngine.Logger:LogException(Exception, Object)
UnityEngine.Debug:LogException(Exception)
ColossalFramework.Plugins.PluginInfo:get_userModInstance()
HarmonyMod.<>c__DisplayClass2_0:<.ctor>b__0(PluginInfo)
System.Linq.Enumerable:First(IEnumerable`1, Func`2, Fallback)
System.Linq.Enumerable:First(IEnumerable`1, Func`2)
HarmonyMod.Handover:.ctor(IAmAware)
HarmonyMod.Mod:OnEnabled()
System.Reflection.MonoMethod:InternalInvoke(Object, Object[], Exception&)
System.Reflection.MonoMethod:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)
System.Reflection.MethodBase:Invoke(Object, Object[])
ColossalFramework.Plugins.PluginManager:AddPlugins(Dictionary`2)
ColossalFramework.Plugins.PluginManager:LoadPlugins()
Starter:Awake()
In this case a broken mod is examined during the bootstrap phase of handover, which causes an uncaught ReflectionTypeLoadException. Exception handlers are not diverted yet at bootstrap time, so these exceptions end up preventing handover and polluting the log file.
Problem 1
The handover algo should not look at
Plugins.PluginInfo:get_userModInstance
which causes the mod to be instantiated, ie, the types to be resolved.Problem 2
There should be no way for the handover to throw, so it needs a try...catch with any exception logged as a SelfProblem
To reproduce
This exception can be triggered with sway2020/YetAnotherToolbar@3317a066, which suffers from the "public class patcher" problem, aka #9 (@sway2020, if you read this, fixing this bug won't fix yours):
Symptom (stack trace)
End user log file
d0c52a38.txt