private static void ChecksStackTrace()
        {
            var st     = new StackTrace(1, false);
            var method = Harmony.GetMethodFromStackframe(st.GetFrame(0));

            // Replacement will be HarmonyLibTests.Extras.RetrieveOriginalMethod.PatchTarget_Patch1
            // We should be able to go from this method, back to HarmonyLibTests.Extras.PatchTarget
            if (method is MethodInfo replacement)
            {
                var original = Harmony.GetOriginalMethod(replacement);
                Assert.NotNull(original);
                Assert.AreEqual(original, AccessTools.Method(typeof(RetrieveOriginalMethod), nameof(RetrieveOriginalMethod.PatchTarget)));
            }
        }
        public static string GetStackTraceString(StackTrace st, out List <MethodMeta> methods)
        {
            var stringBuilder = new StringBuilder(255);

            methods = new List <MethodMeta>();

            for (int i = 0; i < st.FrameCount; i++)
            {
                var method = Harmony.GetMethodFromStackframe(st.GetFrame(i));

                if (method is MethodInfo replacement)
                {
                    var original = Harmony.GetOriginalMethod(replacement);
                    if (original != null)
                    {
                        method = original;
                    }
                }

                GetStringForMethod(ref stringBuilder, method);

                if (method != null)
                {
                    var p = Harmony.GetPatchInfo(method);

                    if (p != null && p.Owners.Count != 0)
                    {
                        var pString = GetPatchStrings(method, p);

                        if (pString != null)
                        {
                            stringBuilder.Append(pString);
                        }
                    }

                    methods.Add(new MethodMeta(method, p));
                }
                else
                {
                    methods.Add(null);
                }

                stringBuilder.Append("\n");
            }

            return(stringBuilder.ToString());
        }