// Copyright (c) 2022 bradson // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at https://mozilla.org/MPL/2.0/. global using System; global using System.Collections.Generic; global using System.Reflection; global using HarmonyLib; global using FisheryLib.Utility.Diagnostics; global using CodeInstructions = System.Collections.Generic.IEnumerable; using System.Security; using System.Diagnostics; [assembly: AllowPartiallyTrustedCallers] [assembly: SecurityTransparent] [assembly: SecurityRules(SecurityRuleSet.Level2, SkipVerificationInFullTrust = true)] [assembly: Debuggable(false, false)] /*namespace FisheryLib; public class Fishery : Harmony { /// Creates a new Fishery instance /// A unique identifier (you choose your own) /// A Fishery instance public Fishery(string id) : base(id) { } /// Creates a patch class processor from an annotated class /// The class/type /// A new instance public new FisheryPatchClassProcessor CreateClassProcessor(Type type) => new(this, type); /// Creates patches by manually specifying the methods /// The original method/constructor /// An optional prefix method wrapped in a object /// An optional postfix method wrapped in a object /// An optional infix method wrapped in a object /// An optional transpiler method wrapped in a object /// An optional finalizer method wrapped in a object /// The replacement method that was created to patch the original method public MethodInfo Patch(MethodBase original, HarmonyMethod? prefix = null, HarmonyMethod? postfix = null, InfixMethod? infix = null, HarmonyMethod? transpiler = null, HarmonyMethod? finalizer = null) { Guard.IsNotNull(original, nameof(original)); return HarmonyPatchExtensions.Patch(this, original, prefix, postfix, infix, transpiler, finalizer); } /// Searches the current assembly for Harmony and Fishery annotations, using them to create patches /// This method can fail to use the correct assembly when being inlined. It calls StackTrace.GetFrame(1) which can point to the wrong method/assembly. If you are unsure or run into problems, use PatchAll(Assembly.GetExecutingAssembly()) instead. public new void PatchAll() => PatchAll(UtilityF.GetCallingAssembly()); /// Searches an assembly for Harmony annotations and uses them to create patches /// The assembly public new void PatchAll(Assembly assembly) { Guard.IsNotNull(assembly, nameof(assembly)); foreach (var type in AccessTools.GetTypesFromAssembly(assembly)) CreateClassProcessor(type).Patch(); } }*/