diff --git a/Harmony/Harmony.csproj b/Harmony/Harmony.csproj index d84d5e87..8ba80c29 100644 --- a/Harmony/Harmony.csproj +++ b/Harmony/Harmony.csproj @@ -73,7 +73,9 @@ - + + runtime; build; native; contentfiles; analyzers; buildtransitive + @@ -93,7 +95,8 @@ - + + @@ -110,13 +113,7 @@ - + \ No newline at end of file diff --git a/HarmonyTests/HarmonyTests.csproj b/HarmonyTests/HarmonyTests.csproj index ec907561..5fe7e64b 100644 --- a/HarmonyTests/HarmonyTests.csproj +++ b/HarmonyTests/HarmonyTests.csproj @@ -61,7 +61,7 @@ - + diff --git a/HarmonyTests/Patching/Assets/FinalizerPatchClasses.cs b/HarmonyTests/Patching/Assets/FinalizerPatchClasses.cs index df21f639..8c3cd39c 100644 --- a/HarmonyTests/Patching/Assets/FinalizerPatchClasses.cs +++ b/HarmonyTests/Patching/Assets/FinalizerPatchClasses.cs @@ -55,14 +55,16 @@ public string Method() } } + public class ThrowingStringReturningMethod { [MethodImpl(MethodImplOptions.NoInlining)] public string Method() { - if (this != null) // satisfy compiler - throw new OriginalException(); + throw new OriginalException(); +#pragma warning disable CS0162 return "OriginalResult"; +#pragma warning restore CS0162 } } diff --git a/HarmonyTests/Patching/FinalizerPatches.cs b/HarmonyTests/Patching/FinalizerPatches.cs index f8b08fdf..783a4058 100644 --- a/HarmonyTests/Patching/FinalizerPatches.cs +++ b/HarmonyTests/Patching/FinalizerPatches.cs @@ -209,7 +209,7 @@ public void SetUp() if (m_method.ReturnType == typeof(void)) _ = m_method.Invoke(obj, null); else - info["result"] = m_method.Invoke(obj, null); + info["result"] = m_method.Invoke(obj, new object[0]); info["outerexception"] = null; } catch (TargetInvocationException e) @@ -234,10 +234,8 @@ private void AssertGotResult(string str) private void AssertGotNullResult() { Assert.NotNull(info, "info should not be null"); - if (info.TryGetValue("result", out var value)) - Assert.IsNull(value, "Result should be null"); - else - Assert.Fail("Should return result"); + Assert.True(info.ContainsKey("result"), "Should return result"); + Assert.IsNull(info["result"], "Result should be null"); } private void AssertGotNoResult()