YamlDotNet
YamlDotNet copied to clipboard
Peak does not return next event
Peak<T> nomenclature and comment indicates that it should return the next event without consuming it.
Actual behaviour is to return the current event without consuming it.
https://github.com/aaubry/YamlDotNet/blob/2c6d52253cdd8d67256bbac6b26322ffcdeb49f0/YamlDotNet/Core/ParserExtensions.cs#L87-L99
Accept indicates it checks the current event.
https://github.com/aaubry/YamlDotNet/blob/2c6d52253cdd8d67256bbac6b26322ffcdeb49f0/YamlDotNet/Core/ParserExtensions.cs#L52-L67
This is from master currently.
Really what I want to achieve is to check the next event so that I can determine a sequence, so that I can avoid consuming DocumentEnd unless it is followed by a DocumentStart event.
if (reader.Accept<DocumentEnd>())
{
if (reader.Peek<DocumentStart>() != null)
{
reader.Allow<DocumentEnd>();
reader.Allow<DocumentStart>();
}
}