1414// limitations under the License.
1515#endregion
1616
17+ using System ;
1718using System . Collections . Generic ;
1819
1920using 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