* Fixed ChunkEnumerator.Current NRE
* Added Nullable Flow analysis annotation comment
* Changed TODO-NULLABLE comment to link to appropriate issue
/// <summary>
/// Implements the IEnumerator pattern.
/// </summary>
- public ReadOnlyMemory<char> Current => new ReadOnlyMemory<char>(_currentChunk!.m_ChunkChars, 0, _currentChunk.m_ChunkLength); // TODO-NULLABLE: NullReferenceException if called before calling MoveNext
+ public ReadOnlyMemory<char> Current
+ {
+ get
+ {
+ if (_currentChunk == null)
+ {
+ ThrowHelper.ThrowInvalidOperationException_InvalidOperation_EnumOpCantHappen();
+ }
+
+ return new ReadOnlyMemory<char>(_currentChunk!.m_ChunkChars, 0, _currentChunk.m_ChunkLength); // TODO-NULLABLE: https://github.com/dotnet/csharplang#538
+ }
+ }
#region private
internal ChunkEnumerator(StringBuilder stringBuilder)