Skip to content
Permalink
Browse files
First pass at nullable reference types. Enabled for main project (tes…
…ts remain nullable oblivious to ease testing).

Squash of 37 commits over 120+ files.
  • Loading branch information
kevin-montrose committed Nov 1, 2019
1 parent 2f5228a commit 4b68060e42c18dc50d2959208aadf2298bf2fbe0
Showing 94 changed files with 2,198 additions and 1,012 deletions.
@@ -1054,7 +1054,7 @@ public void DefaultDescriber_Deserialize()
// reset
Assert.Collection(
cols,
a => Assert.Null(a.Reset),
a => Assert.False(a.HasReset),
a => Assert.Same(mtd, a.Reset.Method)
);
}
@@ -2968,8 +2968,8 @@ public void DefaultDescriber_Serialize()
// should serialize
Assert.Collection(
cols,
a => Assert.Null(a.ShouldSerialize),
b => Assert.Null(b.ShouldSerialize),
a => Assert.False(a.HasShouldSerialize),
b => Assert.False(b.HasShouldSerialize),
c => Assert.Same(typeof(_Serialize).GetMethod(nameof(_Serialize.ShouldSerializeShouldSerializeProp)), c.ShouldSerialize.Method),
d => Assert.Same(typeof(_Serialize).GetMethod(nameof(_Serialize.ShouldSerializeShouldSerializeStaticProp)), d.ShouldSerialize.Method)
);
@@ -3034,10 +3034,10 @@ public void DefaultDescriber_SerializeDataMember()
// should serialize
Assert.Collection(
cols,
a => Assert.Null(a.ShouldSerialize),
a => Assert.False(a.HasShouldSerialize),
a => Assert.Same(typeof(_SerializeDataMember).GetMethod(nameof(_SerializeDataMember.ShouldSerializeWORLD)), a.ShouldSerialize.Method),
a => Assert.Null(a.ShouldSerialize),
a => Assert.Null(a.ShouldSerialize)
a => Assert.False(a.HasShouldSerialize),
a => Assert.False(a.HasShouldSerialize)
);

// formatter
@@ -16,7 +16,7 @@ internal sealed class AsyncCountingAndForcingConfig<T> : BoundConfigurationBase<
private ITestableAsyncProvider Single;

public AsyncCountingAndForcingConfig(BoundConfigurationBase<T> inner) :
base(inner.TypeDescriber, inner.ValueSeparator, inner.EscapedValueStartAndStop, inner.EscapeValueEscapeChar, inner.RowEnding, inner.ReadHeader, inner.WriteHeader, inner.WriteTrailingNewLine, inner.MemoryPool, inner.CommentChar, inner.WriteBufferSizeHint, inner.ReadBufferSizeHint, inner.DynamicRowDisposal)
base(inner._TypeDescriber, inner.ValueSeparator, inner.EscapedValueStartAndStop, inner.EscapeValueEscapeChar, inner.RowEnding, inner.ReadHeader, inner.WriteHeader, inner.WriteTrailingNewLine, inner.MemoryPool, inner.CommentChar, inner.WriteBufferSizeHint, inner.ReadBufferSizeHint, inner.DynamicRowDisposal)
{
InnerConfig = inner;
GoAsyncAfter = -1;
@@ -9,8 +9,24 @@ private class _Item : IIntrusiveLinkedList<_Item>
{
public int Value { get; set; }

public _Item Next { get; set; }
public _Item Previous { get; set; }
public bool HasNext => _Next != null;

private _Item _Next;
public _Item Next
{
get => Utils.NonNull(_Next);
set => _Next = value;
}
public void ClearNext() => Next = null;

public bool HasPrevious => _Previous != null;
private _Item _Previous;
public _Item Previous
{
get => Utils.NonNull(_Previous);
set => _Previous = value;
}
public void ClearPrevious() => Previous = null;
}

[Fact]
@@ -42,7 +58,14 @@ public void AddAfter()
for (var i = 0; i <= 10_000; i++)
{
Assert.Equal(i, cur.Value);
cur = cur.Next;
if (cur.HasNext)
{
cur = cur.Next;
}
else
{
cur = null;
}
}

Assert.Null(cur);
@@ -54,7 +77,14 @@ public void AddAfter()
for (var i = 10_000; i >= 0; i--)
{
Assert.Equal(i, cur.Value);
cur = cur.Previous;
if (cur.HasPrevious)
{
cur = cur.Previous;
}
else
{
cur = null;
}
}

Assert.Null(cur);
@@ -82,7 +112,14 @@ public void AddHead()
for (var i = 10_000; i >= 0; i--)
{
Assert.Equal(i, cur.Value);
cur = cur.Next;
if (cur.HasNext)
{
cur = cur.Next;
}
else
{
cur = null;
}
}

Assert.Null(cur);
@@ -94,7 +131,14 @@ public void AddHead()
for (var i = 0; i <= 10_000; i++)
{
Assert.Equal(i, cur.Value);
cur = cur.Previous;
if (cur.HasPrevious)
{
cur = cur.Previous;
}
else
{
cur = null;
}
}

Assert.Null(cur);
@@ -139,8 +183,8 @@ public void Remove()
// remove 100
{
head.Remove(ref head, oneZeroZero);
Assert.Null(oneZeroZero.Previous);
Assert.Null(oneZeroZero.Next);
Assert.False(oneZeroZero.HasPrevious);
Assert.False(oneZeroZero.HasNext);

// read forward
{
@@ -150,7 +194,14 @@ public void Remove()
if (i == 100) continue;

Assert.Equal(i, cur.Value);
cur = cur.Next;
if (cur.HasNext)
{
cur = cur.Next;
}
else
{
cur = null;
}
}

Assert.Null(cur);
@@ -164,7 +215,15 @@ public void Remove()
if (i == 100) continue;

Assert.Equal(i, cur.Value);
cur = cur.Previous;

if (cur.HasPrevious)
{
cur = cur.Previous;
}
else
{
cur = null;
}
}

Assert.Null(cur);
@@ -174,8 +233,8 @@ public void Remove()
// remove 200
{
head.Remove(ref head, twoZeroZero);
Assert.Null(twoZeroZero.Previous);
Assert.Null(twoZeroZero.Next);
Assert.False(twoZeroZero.HasPrevious);
Assert.False(twoZeroZero.HasNext);

// read forward
{
@@ -186,7 +245,15 @@ public void Remove()
if (i == 200) continue;

Assert.Equal(i, cur.Value);
cur = cur.Next;

if (cur.HasNext)
{
cur = cur.Next;
}
else
{
cur = null;
}
}

Assert.Null(cur);
@@ -201,7 +268,15 @@ public void Remove()
if (i == 200) continue;

Assert.Equal(i, cur.Value);
cur = cur.Previous;

if (cur.HasPrevious)
{
cur = cur.Previous;
}
else
{
cur = null;
}
}

Assert.Null(cur);
@@ -211,8 +286,8 @@ public void Remove()
// remove 333
{
head.Remove(ref head, threeThreeThree);
Assert.Null(threeThreeThree.Previous);
Assert.Null(threeThreeThree.Next);
Assert.False(threeThreeThree.HasPrevious);
Assert.False(threeThreeThree.HasNext);

// read forward
{
@@ -224,7 +299,15 @@ public void Remove()
if (i == 333) continue;

Assert.Equal(i, cur.Value);
cur = cur.Next;

if (cur.HasNext)
{
cur = cur.Next;
}
else
{
cur = null;
}
}

Assert.Null(cur);
@@ -240,7 +323,15 @@ public void Remove()
if (i == 333) continue;

Assert.Equal(i, cur.Value);
cur = cur.Previous;

if (cur.HasPrevious)
{
cur = cur.Previous;
}
else
{
cur = null;
}
}

Assert.Null(cur);
@@ -252,8 +343,8 @@ public void Remove()
var oldHead = head;

head.Remove(ref head, head);
Assert.Null(oldHead.Previous);
Assert.Null(oldHead.Next);
Assert.False(oldHead.HasPrevious);
Assert.False(oldHead.HasNext);

Assert.NotNull(head);
Assert.Equal(9_999, head.Value);
@@ -269,7 +360,15 @@ public void Remove()
if (i == 333) continue;

Assert.Equal(i, cur.Value);
cur = cur.Next;

if (cur.HasNext)
{
cur = cur.Next;
}
else
{
cur = null;
}
}

Assert.Null(cur);
@@ -286,7 +385,15 @@ public void Remove()
if (i == 333) continue;

Assert.Equal(i, cur.Value);
cur = cur.Previous;

if (cur.HasPrevious)
{
cur = cur.Previous;
}
else
{
cur = null;
}
}

Assert.Null(cur);
@@ -299,8 +406,8 @@ public void Remove()
var newTail = tail.Previous;

head.Remove(ref head, tail);
Assert.Null(oldTail.Previous);
Assert.Null(oldTail.Next);
Assert.False(oldTail.HasPrevious);
Assert.False(oldTail.HasNext);

tail = newTail;
Assert.Equal(1, tail.Value);
@@ -317,7 +424,15 @@ public void Remove()
if (i == 333) continue;

Assert.Equal(i, cur.Value);
cur = cur.Next;

if (cur.HasNext)
{
cur = cur.Next;
}
else
{
cur = null;
}
}

Assert.Null(cur);
@@ -335,7 +450,15 @@ public void Remove()
if (i == 333) continue;

Assert.Equal(i, cur.Value);
cur = cur.Previous;

if (cur.HasPrevious)
{
cur = cur.Previous;
}
else
{
cur = null;
}
}

Assert.Null(cur);
@@ -348,8 +471,8 @@ public void Remove()
{
var oldHead = head;
head.Remove(ref head, head);
Assert.Null(oldHead.Previous);
Assert.Null(oldHead.Next);
Assert.False(oldHead.HasPrevious);
Assert.False(oldHead.HasNext);
}

Assert.Null(head);

0 comments on commit 4b68060

Please sign in to comment.