[Mono-devel-list] System.IO.BinaryReader

Nick Vaughan dev at 6wardlaw.freeserve.co.uk
Thu Dec 4 15:22:30 EST 2003


This is a copy of an email I sent to the people who's names were at the top of the BinaryReader implementation file.

I have made this change but am unsure how to submit it as a patch.

Any pointers?

Thanks.

> I am currently attempting to move our .net based server from Microsoft
> to Mono and came across an issue with the BinaryReader class. The
> particular function in question is the PeekChar( ) method. As
> implemented, this function actually modifies the underlying stream (
> increments the position by one character ) which seems to go against the
> notion of peeking. The peeked character is read into a 'Peek Buffer'
> which is then used when next reading from the BinaryReader.
> This causes 2 problems. 
> A) The underlying stream is not in the same state before the function
> call as after.
> B) If the underlying stream position is changed subsequent to a
> PeekChar( ) the bytes in the 'Peek Buffer' will still be read regardles.
> 
> I would therefore like to propose a change to the implementation of this
> class which would be in line with the Microsoft .net implementation:
> 
> If the underlying stream is 'seekable' -> read the first character's
> bytes from the stream and then reposition the stream to it's original
> position.
> 
> If the underlying stream is 'unseekable' -> return -1.
> 
> What do you think?



More information about the Mono-devel-list mailing list