Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of VargheimSoftRefCompat v0.1.0
patchers/VargheimSoftRefCompat/VargheimSoftRefCompat.dll
Decompiled 17 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx.Logging; using Microsoft.CodeAnalysis; using Mono.Cecil; using Mono.Cecil.Cil; using Mono.Collections.Generic; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.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; } } } public static class VargheimSoftRefCompat { public const string Version = "0.1.0"; public static IEnumerable<string> TargetDLLs => new string[1] { "SoftReferenceableAssets.dll" }; public static void Patch(AssemblyDefinition assembly) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Expected O, but got Unknown //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Expected O, but got Unknown //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Expected O, but got Unknown //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Expected O, but got Unknown ManualLogSource val = Logger.CreateLogSource("VargheimSoftRefCompat"); try { TypeDefinition type = assembly.MainModule.GetType("SoftReferenceableAssets.SoftReference`1"); if (type == null) { val.LogWarning((object)"SoftReference`1 not found; nothing patched."); return; } MethodDefinition val2 = null; MethodDefinition val3 = null; Enumerator<MethodDefinition> enumerator = type.Methods.GetEnumerator(); try { while (enumerator.MoveNext()) { MethodDefinition current = enumerator.Current; if (((MethodReference)current).Parameters.Count == 0) { if (((MemberReference)current).Name == "get_Name") { val2 = current; } else if (((MemberReference)current).Name == "get_name") { val3 = current; } } } } finally { ((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } if (val2 != null) { val.LogInfo((object)"SoftReference`1.get_Name already exists; nothing to do (0.1.0)."); return; } if (val3 == null || ((MemberReference)((MethodReference)val3).ReturnType).FullName != "System.String") { val.LogWarning((object)"SoftReference`1.get_name (string) not found; nothing patched."); return; } GenericInstanceType val4 = new GenericInstanceType((TypeReference)(object)type); Enumerator<GenericParameter> enumerator2 = ((TypeReference)type).GenericParameters.GetEnumerator(); try { while (enumerator2.MoveNext()) { GenericParameter current2 = enumerator2.Current; val4.GenericArguments.Add((TypeReference)(object)current2); } } finally { ((IDisposable)enumerator2/*cast due to .constrained prefix*/).Dispose(); } MethodReference val5 = new MethodReference(((MemberReference)val3).Name, ((MethodReference)val3).ReturnType, (TypeReference)(object)val4); val5.HasThis = true; MethodDefinition val6 = new MethodDefinition("get_Name", val3.Attributes, ((MethodReference)val3).ReturnType); type.Methods.Add(val6); ILProcessor iLProcessor = val6.Body.GetILProcessor(); iLProcessor.Emit(OpCodes.Ldarg_0); iLProcessor.Emit(OpCodes.Call, val5); iLProcessor.Emit(OpCodes.Ret); PropertyDefinition val7 = new PropertyDefinition("Name", (PropertyAttributes)0, ((MethodReference)val3).ReturnType); val7.GetMethod = val6; type.Properties.Add(val7); val.LogInfo((object)"Added SoftReference`1.get_Name as an alias of get_name (0.1.0)."); } catch (Exception ex) { val.LogError((object)("Patch failed, game continues unpatched: " + ex)); } finally { Logger.Sources.Remove((ILogSource)(object)val); } } }