diff --git a/HarmonyTests/Patching/Arguments.cs b/HarmonyTests/Patching/Arguments.cs index 587bb5d3..bb6130f2 100644 --- a/HarmonyTests/Patching/Arguments.cs +++ b/HarmonyTests/Patching/Arguments.cs @@ -396,5 +396,23 @@ public void Test_RenamedArguments() var log = RenamedArgumentsPatch.log.Join(); Assert.AreEqual("val1, patched, val2, hello", log); } + + [Test] + public void Test_NullableResults() + { + var res1 = new NullableResults().Method(); + Assert.True(res1.HasValue); + Assert.False(res1.Value); + + var harmony = new Harmony("test"); + var processor = new PatchClassProcessor(harmony, typeof(NullableResultsPatch)); + var patches = processor.Patch(); + Assert.NotNull(patches, "patches"); + Assert.AreEqual(1, patches.Count); + + var res2 = new NullableResults().Method(); + Assert.True(res2.HasValue); + Assert.True(res2.Value); + } } } diff --git a/HarmonyTests/Patching/Assets/ArgumentCases.cs b/HarmonyTests/Patching/Assets/ArgumentCases.cs index 06c32479..e7996e88 100644 --- a/HarmonyTests/Patching/Assets/ArgumentCases.cs +++ b/HarmonyTests/Patching/Assets/ArgumentCases.cs @@ -144,6 +144,24 @@ public static void Postfix([HarmonyArgument("__instance")] RenamedArguments foo2 } } + public class NullableResults + { + private string s = "foo"; + + [MethodImpl(MethodImplOptions.NoInlining)] + public bool? Method() => false; + } + + [HarmonyPatch(typeof(NullableResults), nameof(NullableResults.Method))] + public static class NullableResultsPatch + { + public static bool Prefix(ref bool? __result) + { + __result = true; + return false; + } + } + public class ArgumentArrayMethods { public struct SomeStruct