From a39672ce0b37a3056777e6634d71e23dc38296d6 Mon Sep 17 00:00:00 2001 From: Atif Aziz Date: Wed, 9 Nov 2022 09:09:37 +0100 Subject: [PATCH] Enable nullable context in "Flatten" tests Adds to #803. --- MoreLinq.Test/FlattenTest.cs | 16 +++++++++------- MoreLinq.Test/MoreLinq.Test.csproj | 1 + 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/MoreLinq.Test/FlattenTest.cs b/MoreLinq.Test/FlattenTest.cs index f3b5b4a6c..84b9c0a93 100644 --- a/MoreLinq.Test/FlattenTest.cs +++ b/MoreLinq.Test/FlattenTest.cs @@ -15,6 +15,8 @@ // limitations under the License. #endregion +#nullable enable + namespace MoreLinq.Test { using System.Collections.Generic; @@ -395,7 +397,7 @@ public void FlattenSelectorWithTree() var result = new[] { source }.Flatten(obj => obj switch { int => null, - Tree tree => new object[] { tree.Left, tree.Value, tree.Right }, + Tree tree => new object?[] { tree.Left, tree.Value, tree.Right }, IEnumerable inner => inner, _ => Enumerable.Empty() }); @@ -407,23 +409,23 @@ public void FlattenSelectorWithTree() class Series { - public string Name; - public Attribute[] Attributes; + public required string Name; + public required Attribute[] Attributes; } class Attribute { - public int[] Values; + public required int[] Values; } class Tree { public readonly T Value; - public readonly Tree Left; - public readonly Tree Right; + public readonly Tree? Left; + public readonly Tree? Right; public Tree(T value) : this(null, value, null) {} - public Tree(Tree left, T value, Tree right) + public Tree(Tree? left, T value, Tree? right) { Left = left; Value = value; diff --git a/MoreLinq.Test/MoreLinq.Test.csproj b/MoreLinq.Test/MoreLinq.Test.csproj index 470cfcab3..273866c9b 100644 --- a/MoreLinq.Test/MoreLinq.Test.csproj +++ b/MoreLinq.Test/MoreLinq.Test.csproj @@ -35,6 +35,7 @@ +