giosuel / imperium

Imperium is a powerful and highly performant all-in-one debugging tool to test and explore game mechanics and functionality in Lethal Company.
https://thunderstore.io/c/lethal-company/p/giosuel/Imperium/
GNU General Public License v3.0
25 stars 4 forks source link

Fix HarmonyX errors related to WeatherRegistry's soft-dependency #81

Closed AndreyMrovol closed 2 weeks ago

AndreyMrovol commented 2 weeks ago

This PR aims to fix HarmonyX errors that show up when WeatherRegistryis not present in the modpack.

[Warning:  HarmonyX] AccessTools.GetTypesFromAssembly: assembly giosuel.Imperium, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null => System.Reflection.ReflectionTypeLoadException: Exception of type 'System.Reflection.ReflectionTypeLoadException' was thrown.
Could not load type of field 'Imperium.Integration.WeatherRegistryIntegration+<>c:<>9__2_0' (1) due to: Could not load file or assembly 'WeatherRegistry, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
  at (wrapper managed-to-native) System.Reflection.Assembly.GetTypes(System.Reflection.Assembly,bool)
  at System.Reflection.Assembly.GetTypes () [0x00000] in <787acc3c9a4c471ba7d971300105af24>:IL_0000 
  at HarmonyLib.AccessTools.GetTypesFromAssembly (System.Reflection.Assembly assembly) [0x0000d] in <474744d65d8e460fa08cd5fd82b5d65f>:IL_000D 
System.TypeLoadException: Could not load type of field 'Imperium.Integration.WeatherRegistryIntegration+<>c:<>9__2_0' (1) due to: Could not load file or assembly 'WeatherRegistry, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
[Warning:  HarmonyX] AccessTools.GetTypesFromAssembly: assembly giosuel.Imperium, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null => System.Reflection.ReflectionTypeLoadException: Exception of type 'System.Reflection.ReflectionTypeLoadException' was thrown.
Could not load type of field 'Imperium.Integration.WeatherRegistryIntegration+<>c:<>9__2_0' (1) due to: Could not load file or assembly 'WeatherRegistry, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
  at (wrapper managed-to-native) System.Reflection.Assembly.GetTypes(System.Reflection.Assembly,bool)
  at System.Reflection.Assembly.GetTypes () [0x00000] in <787acc3c9a4c471ba7d971300105af24>:IL_0000 
  at HarmonyLib.AccessTools.GetTypesFromAssembly (System.Reflection.Assembly assembly) [0x0000d] in <474744d65d8e460fa08cd5fd82b5d65f>:IL_000D 
System.TypeLoadException: Could not load type of field 'Imperium.Integration.WeatherRegistryIntegration+<>c:<>9__2_0' (1) due to: Could not load file or assembly 'WeatherRegistry, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
[Warning:  HarmonyX] AccessTools.GetTypesFromAssembly: assembly giosuel.Imperium, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null => System.Reflection.ReflectionTypeLoadException: Exception of type 'System.Reflection.ReflectionTypeLoadException' was thrown.
Could not load type of field 'Imperium.Integration.WeatherRegistryIntegration+<>c:<>9__2_0' (1) due to: Could not load file or assembly 'WeatherRegistry, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
  at (wrapper managed-to-native) System.Reflection.Assembly.GetTypes(System.Reflection.Assembly,bool)
  at System.Reflection.Assembly.GetTypes () [0x00000] in <787acc3c9a4c471ba7d971300105af24>:IL_0000 
  at HarmonyLib.AccessTools.GetTypesFromAssembly (System.Reflection.Assembly assembly) [0x0000d] in <474744d65d8e460fa08cd5fd82b5d65f>:IL_000D 
System.TypeLoadException: Could not load type of field 'Imperium.Integration.WeatherRegistryIntegration+<>c:<>9__2_0' (1) due to: Could not load file or assembly 'WeatherRegistry, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.

The error comes from .Select trying to access fields from missing namespace, it's fixed by doing a normal foreach loop.

AndreyMrovol commented 2 weeks ago

targeted the wrong branch