Skip to content

Commit 5465639

Browse files
authored
Add CallerArgumentExpression to IsTrue/IsFalse (#252)
1 parent f264efa commit 5465639

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

source/TestFramework/Assert.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System;
88
using System.Collections;
99
using System.Diagnostics.CodeAnalysis;
10+
using System.Runtime.CompilerServices;
1011
using TestFrameworkShared;
1112

1213
namespace nanoFramework.TestFramework
@@ -54,9 +55,7 @@ public static void SkipTest(string message = "")
5455
/// <param name="condition">The condition the test expects to be true.</param>
5556
/// <param name="message">The message to include in the exception when condition is false. The message is shown in test results.</param>
5657
/// <exception cref="AssertFailedException">Thrown if condition is <see langword="false"/>.</exception>
57-
public static void IsTrue(
58-
bool condition,
59-
string message = "")
58+
public static void IsTrue(bool condition, [CallerArgumentExpression(nameof(condition))] string message = "")
6059
{
6160
if (!condition)
6261
{
@@ -83,9 +82,7 @@ public static void True(
8382
/// <param name="condition">The condition the test expects to be false.</param>
8483
/// <param name="message">The message to include in the exception when condition is true. The message is shown in test results.</param>
8584
/// <exception cref="AssertFailedException">Thrown if condition is <see langword="true"/>.</exception>
86-
public static void IsFalse(
87-
bool condition,
88-
string message = "")
85+
public static void IsFalse(bool condition, [CallerArgumentExpression(nameof(condition))] string message = "")
8986
{
9087
if (condition)
9188
{

source/TestFramework/nanoFramework.TestFramework.nfproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<TargetFrameworkVersion>v1.0</TargetFrameworkVersion>
1919
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
2020
<RestoreLockedMode Condition="'$(TF_BUILD)' == 'True' or '$(ContinuousIntegrationBuild)' == 'True'">true</RestoreLockedMode>
21+
<LangVersion>default</LangVersion>
2122
</PropertyGroup>
2223
<PropertyGroup>
2324
<SignAssembly>true</SignAssembly>

0 commit comments

Comments
 (0)