Skip to content

Commit 9d8317b

Browse files
author
Mark Junker
committed
Fixed some hints from Rider
1 parent 1bbc5e4 commit 9d8317b

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

FluentMigrator.BatchParser/SearchStatus.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,10 @@ private SearchStatus FindRangeEnd()
164164
if (_context.StripComments && searcher.IsComment)
165165
{
166166
reader = reader.Advance(result.Index - reader.Index);
167+
Debug.Assert(reader != null, "The returned ILineReader must not be null");
167168
}
168169

170+
Debug.Assert(result.NestedRangeSearcher != null, "result.NestedRangeSearcher != null");
169171
return UseNewRange(reader, new RangeStart(result.NestedRangeSearcher, result.Index));
170172
}
171173

FluentMigrator.BatchParser/Sources/LinesSource.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
// limitations under the License.
1515
#endregion
1616

17+
using System;
1718
using System.Collections.Generic;
1819

1920
using JetBrains.Annotations;
@@ -25,14 +26,14 @@ namespace FluentMigrator.BatchParser.Sources
2526
/// </summary>
2627
public class LinesSource : ITextSource
2728
{
28-
[NotNull]
29+
[NotNull, ItemNotNull]
2930
private readonly IEnumerable<string> _batchSource;
3031

3132
/// <summary>
3233
/// Initializes a new instance of the <see cref="LinesSource"/> class.
3334
/// </summary>
3435
/// <param name="batchSource">The collection of lines to be used as source</param>
35-
public LinesSource([NotNull] IEnumerable<string> batchSource)
36+
public LinesSource([NotNull, ItemNotNull] IEnumerable<string> batchSource)
3637
{
3738
_batchSource = batchSource;
3839
}
@@ -55,9 +56,10 @@ public LineReader([NotNull] IEnumerator<string> enumerator, int index)
5556
{
5657
_enumerator = enumerator;
5758
Index = index;
59+
Line = _enumerator.Current ?? throw new InvalidOperationException("The returned line must not be null");
5860
}
5961

60-
public string Line => _enumerator.Current;
62+
public string Line { get; private set; }
6163

6264
public int Index { get; }
6365

@@ -81,12 +83,14 @@ public ILineReader Advance(int length)
8183
length -= remaining;
8284
if (!_enumerator.MoveNext())
8385
return null;
86+
8487
currentIndex = 0;
85-
currentLine = _enumerator.Current;
88+
currentLine = _enumerator.Current ?? throw new InvalidOperationException("The returned line must not be null");
8689
remaining = currentLine.Length;
8790
} while (length >= remaining && length != 0);
8891
}
8992

93+
Line = currentLine;
9094
currentIndex += length;
9195
return new LineReader(_enumerator, currentIndex);
9296
}

0 commit comments

Comments
 (0)