Skip to content

Commit b70691d

Browse files
authored
Improve null asserts (#249)
***NO_CI***
1 parent 119c97b commit b70691d

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

source/TestFramework/Assert.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
using System;
88
using System.Collections;
9+
using System.Diagnostics.CodeAnalysis;
910
using TestFrameworkShared;
1011

1112
namespace nanoFramework.TestFramework
@@ -1604,7 +1605,7 @@ public static void NotSame(
16041605
/// <exception cref="AssertFailedException">Thrown if value is not null.</exception>
16051606
public static void IsNull(object value, string message = "")
16061607
{
1607-
if (value != null)
1608+
if (value is not null)
16081609
{
16091610
HandleFail("Assert.IsNull", message);
16101611
}
@@ -1624,10 +1625,10 @@ public static void IsNull(object value, string message = "")
16241625
/// </summary>
16251626
/// <param name="value">The object the test expects not to be null.</param>
16261627
/// <param name="message">The message to include in the exception when value is null. The message is shown in test results.</param>
1627-
/// <exception cref="AssertFailedException">Thrown if value is null./exception>
1628-
public static void IsNotNull(object value, string message = "")
1628+
/// <exception cref="AssertFailedException">Thrown if value is null.</exception>
1629+
public static void IsNotNull([NotNull] object value, string message = "")
16291630
{
1630-
if (value == null)
1631+
if (value is null)
16311632
{
16321633
HandleFail("Assert.IsNotNull", message);
16331634
}

source/TestFramework/nanoFramework.TestFramework.nfproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@
4747
<HintPath>..\..\packages\nanoFramework.CoreLibrary.1.15.5\lib\mscorlib.dll</HintPath>
4848
<Private>True</Private>
4949
</Reference>
50+
<Reference Include="nanoFramework.System.Runtime">
51+
<HintPath>..\..\packages\nanoFramework.System.Runtime.1.0.6\lib\nanoFramework.System.Runtime.dll</HintPath>
52+
</Reference>
53+
</ItemGroup>
54+
<ItemGroup>
55+
<Content Include="packages.lock.json" />
5056
</ItemGroup>
5157
<Import Project="..\TestFrameworkShared\TestFrameworkShared.projitems" Label="Shared" />
5258
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets')" />
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
33
<package id="nanoFramework.CoreLibrary" version="1.15.5" targetFramework="netnano1.0" />
4+
<package id="nanoFramework.System.Runtime" version="1.0.6" targetFramework="netnano1.0" />
45
<package id="Nerdbank.GitVersioning" version="3.6.133" developmentDependency="true" targetFramework="netnano1.0" />
56
</packages>

source/TestFramework/packages.lock.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
"resolved": "1.15.5",
99
"contentHash": "u2+GvAp1uxLrGdILACAZy+EVKOs28EQ52j8Lz7599egXZ3GBGejjnR2ofhjMQwzrJLlgtyrsx8nSLngDfJNsAg=="
1010
},
11+
"nanoFramework.System.Runtime": {
12+
"type": "Direct",
13+
"requested": "[1.0.6, 1.0.6]",
14+
"resolved": "1.0.6",
15+
"contentHash": "n87itPUMSsOJkUsdoXr0vhiBTggZBMgCtIIC7c+RsVAhF2u/0TU/h+ZLNyFL8Xhl0taPcTN4LiPPTkI+e95Q/g=="
16+
},
1117
"Nerdbank.GitVersioning": {
1218
"type": "Direct",
1319
"requested": "[3.6.133, 3.6.133]",

0 commit comments

Comments
 (0)