Skip to content

Commit 278b1f4

Browse files
author
Oren (electricessence)
committed
Improved nullability.
1 parent 7ee8e8d commit 278b1f4

4 files changed

Lines changed: 23 additions & 5 deletions

File tree

IElement.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1-
namespace Open.Hierarchy
1+
using System.Diagnostics.CodeAnalysis;
2+
3+
namespace Open.Hierarchy
24
{
35
public interface IElement<T>
46
{
7+
#if NETSTANDARD2_1
8+
[AllowNull]
9+
#endif
510
T Value { get; set; }
611
}
712
}

Node.Factory.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Open.Disposable;
22
using System;
3+
using System.Diagnostics.CodeAnalysis;
34
using System.Diagnostics.Contracts;
45

56
namespace Open.Hierarchy
@@ -56,6 +57,9 @@ public Node<T> GetNodeWithValue(T value, bool asUnmapped = false)
5657
/// </summary>
5758
/// <param name="node">The node to be recycled.</param>
5859
/// <returns>The value contained in the node.</returns>
60+
#if NETSTANDARD2_1
61+
[return: MaybeNull]
62+
#endif
5963
public T Recycle(Node<T> node)
6064
{
6165
if (node == null) throw new ArgumentNullException(nameof(node));
@@ -66,6 +70,9 @@ public T Recycle(Node<T> node)
6670
return RecycleInternal(node);
6771
}
6872

73+
#if NETSTANDARD2_1
74+
[return: MaybeNull]
75+
#endif
6976
internal T RecycleInternal(Node<T> n)
7077
{
7178
var value = n.Value;

Node.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,16 @@ void AssertNotRecycled()
3030
throw new InvalidOperationException("Attempting to modify a node that has been recyled.");
3131
}
3232

33-
// ReSharper disable once UnusedAutoPropertyAccessor.Global
33+
#if NETSTANDARD2_1
34+
[AllowNull]
35+
#endif
36+
private T _value;
37+
3438
/// <summary>
3539
/// The value for the node to hold on to.
3640
/// </summary>
37-
private T _value;
3841
#if NETSTANDARD2_1
39-
[MaybeNull]
42+
[AllowNull]
4043
#endif
4144
public T Value
4245
{
@@ -312,6 +315,9 @@ public void TeardownChildren()
312315
/// <summary>
313316
/// Recycles this node.
314317
/// </summary>
318+
#if NETSTANDARD2_1
319+
[return: MaybeNull]
320+
#endif
315321
// ReSharper disable once UnusedMethodReturnValue.Global
316322
public T Recycle()
317323
{

Open.Hierarchy.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<RepositoryUrl>https://github.com/electricessence/Open.Hierarchy/</RepositoryUrl>
1717
<RepositoryType>git</RepositoryType>
1818
<PackageTags>dotnet, dotnetcore, cs, tree, node, hierarchy, parent, child, root</PackageTags>
19-
<Version>1.7.1</Version>
19+
<Version>1.7.2</Version>
2020
<PackageReleaseNotes></PackageReleaseNotes>
2121
<PackageLicenseExpression>MIT</PackageLicenseExpression>
2222
<Nullable>enable</Nullable>

0 commit comments

Comments
 (0)