diff --git a/src/Docs/DocsHook.cs b/src/Docs/DocsHook.cs index 83fe7a5..a111121 100644 --- a/src/Docs/DocsHook.cs +++ b/src/Docs/DocsHook.cs @@ -22,6 +22,7 @@ public class DocsHook public string HookName { get; set; } public string HookDescription { get; set; } public Dictionary HookParameters { get; set; } + public string ReturnType { get; set; } public ReturnBehavior ReturnBehavior { get; set; } = ReturnBehavior.Continue; public string TargetType { get; set; } public string Category { get; set; } @@ -45,6 +46,7 @@ public DocsHook(Hook hook, MethodDefinition methodDef, string targetDirectory) Type = HookType.Simple; ReturnBehavior = simpleHook.ReturnBehavior; HookParameters = GetHookArguments(simpleHook, methodDef); + ReturnType = GetReturnType(simpleHook, methodDef); break; case Modify modifyHook: @@ -165,6 +167,42 @@ private Dictionary GetHookArguments(Simple hook, MethodDefinitio return hookArguments; } + private string GetReturnType(Simple hook, MethodDefinition method) + { + string returnType = ""; + try + { + switch (hook?.ReturnBehavior) + { + case ReturnBehavior.Continue: + returnType = "void"; + break; + + case ReturnBehavior.ExitWhenNonNull: + if (hook?.Signature.ReturnType == "System.Void") returnType = "object"; + else returnType = Utility.TransformType(hook?.Signature.ReturnType); + break; + + case ReturnBehavior.ExitWhenValidType: + if (hook?.Signature.ReturnType == "System.Void") returnType = "object"; + else returnType = Utility.TransformType(hook?.Signature.ReturnType); + break; + + case ReturnBehavior.ModifyRefArg: + if (hook?.Signature.ReturnType == "System.Void") returnType = "object"; + else returnType = Utility.TransformType(hook?.Signature.ReturnType); + break; + + case ReturnBehavior.UseArgumentString: + string[] args = Utility.ParseArgumentString(hook.ArgumentString, out string returnValue); + returnType = Utility.TransformType(GetArgStringType(returnValue, method, out string argName)); + break; + } + } catch { returnType = "ERROR"; } + + return returnType; + } + //Doesn't work if I use the Decompiler class so just do this for now private static string GetSourceCode(MethodDefinition methodDefinition) {