~ruther/NosSmooth

0e9c9ae4a70953f2e8471818bf4df53b84798743 — František Boháček 3 years ago 1330279
fix: set enumerator level ReachedEnd to null if not known
1 files changed, 13 insertions(+), 6 deletions(-)

M Core/NosSmooth.Packets/PacketStringEnumerator.cs
M Core/NosSmooth.Packets/PacketStringEnumerator.cs => Core/NosSmooth.Packets/PacketStringEnumerator.cs +13 -6
@@ 208,9 208,9 @@ public struct PacketStringEnumerator
            return cachedToken;
        }

        if (_data.ReachedEnd || _currentLevel.ReachedEnd)
        if (_data.ReachedEnd || (_currentLevel.ReachedEnd ?? false))
        {
            return new PacketEndReachedError(_data.Data, _currentLevel.ReachedEnd);
            return new PacketEndReachedError(_data.Data, _currentLevel.ReachedEnd ?? false);
        }

        var currentIndex = _data.Cursor;


@@ 259,9 259,9 @@ public struct PacketStringEnumerator
    private void UpdateCurrentAndParentLevels(PacketToken token)
    {
        // If the token is last in the current level, then set reached end of the current level.
        if (token.IsLast ?? false)
        if (_currentLevel.ReachedEnd != true)
        {
            _currentLevel.ReachedEnd = true;
            _currentLevel.ReachedEnd = token.IsLast;
        }

        // IsLast is set if parent separator was encountered. The parent needs to be updated.


@@ 298,7 298,14 @@ public struct PacketStringEnumerator
    /// </summary>
    /// <returns>Whether the last token was read. Null if cannot determine (ie. there are multiple levels with the same separator.)</returns>
    public bool? IsOnLastToken()
        => _data.ReachedEnd || _currentLevel.ReachedEnd;
    {
        if (_data.ReachedEnd)
        {
            return true;
        }

        return _currentLevel.ReachedEnd;
    }

    /// <summary>
    /// Checks if the given character is a separator.


@@ 393,6 400,6 @@ public struct PacketStringEnumerator

        public uint TokensRead { get; set; }

        public bool ReachedEnd { get; set; }
        public bool? ReachedEnd { get; set; }
    }
}
\ No newline at end of file

Do not follow this link