From 9d24f5bca330952c55fd1b124df9f6506051cee4 Mon Sep 17 00:00:00 2001 From: Cory Charlton Date: Wed, 15 May 2024 09:47:56 -0700 Subject: [PATCH] Add CallerArgumentExpression to IsTrue/IsFalse --- source/TestFramework/Assert.cs | 9 +++------ source/TestFramework/nanoFramework.TestFramework.nfproj | 1 + 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/source/TestFramework/Assert.cs b/source/TestFramework/Assert.cs index b7961be..e226e5d 100644 --- a/source/TestFramework/Assert.cs +++ b/source/TestFramework/Assert.cs @@ -7,6 +7,7 @@ using System; using System.Collections; using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; using TestFrameworkShared; namespace nanoFramework.TestFramework @@ -54,9 +55,7 @@ public static void SkipTest(string message = "") /// The condition the test expects to be true. /// The message to include in the exception when condition is false. The message is shown in test results. /// Thrown if condition is . - public static void IsTrue( - bool condition, - string message = "") + public static void IsTrue(bool condition, [CallerArgumentExpression(nameof(condition))] string message = "") { if (!condition) { @@ -83,9 +82,7 @@ public static void True( /// The condition the test expects to be false. /// The message to include in the exception when condition is true. The message is shown in test results. /// Thrown if condition is . - public static void IsFalse( - bool condition, - string message = "") + public static void IsFalse(bool condition, [CallerArgumentExpression(nameof(condition))] string message = "") { if (condition) { diff --git a/source/TestFramework/nanoFramework.TestFramework.nfproj b/source/TestFramework/nanoFramework.TestFramework.nfproj index ed0807a..9e54f45 100644 --- a/source/TestFramework/nanoFramework.TestFramework.nfproj +++ b/source/TestFramework/nanoFramework.TestFramework.nfproj @@ -18,6 +18,7 @@ v1.0 true true + default true