using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using Microsoft.CodeAnalysis; using Mono.Cecil; using Mono.Collections.Generic; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("BaconFixer.Preloader")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("BaconFixer.Preloader")] [assembly: AssemblyTitle("BaconFixer.Preloader")] [assembly: AssemblyMetadata("AI_Assisted_Creation", "Code generated with Claude Code, Anthropic's AI coding agent")] [assembly: AssemblyMetadata("AI_Model_Vendor", "Anthropic")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace BaconFixer.Preloader { public static class DunGenForwarder { private const string KeepUnforwarded = "DunGen.TileConnectionRule"; private static readonly ManualLogSource Log = Logger.CreateLogSource("BaconFixer.Preloader"); public static IEnumerable TargetDLLs { get; } = new string[1] { "Assembly-CSharp.dll" }; public static void Patch(AssemblyDefinition assembly) { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Expected O, but got Unknown ModuleDefinition mainModule = assembly.MainModule; AssemblyNameReference val = ((IEnumerable)mainModule.AssemblyReferences).FirstOrDefault((Func)((AssemblyNameReference r) => r.Name == "DunGen")); string text = Path.Combine(Paths.ManagedPath, "DunGen.dll"); if (val == null || !File.Exists(text)) { Log.LogWarning((object)"DunGen.dll not found or not referenced. Nothing to forward."); return; } int num = 0; AssemblyDefinition val2 = AssemblyDefinition.ReadAssembly(text); try { Enumerator enumerator = val2.MainModule.Types.GetEnumerator(); try { while (enumerator.MoveNext()) { TypeDefinition current = enumerator.Current; if (current.IsPublic && !(((MemberReference)current).FullName == "DunGen.TileConnectionRule") && mainModule.GetType(((MemberReference)current).FullName) == null) { mainModule.ExportedTypes.Add(new ExportedType(((TypeReference)current).Namespace, ((MemberReference)current).Name, mainModule, (IMetadataScope)(object)val) { IsForwarder = true }); num++; } } } finally { ((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } } finally { ((IDisposable)val2)?.Dispose(); } Log.LogInfo((object)$"Forwarding {num} DunGen types from Assembly-CSharp to DunGen.dll"); } } }