mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-09 23:25:43 +00:00
[ci skip] docs: add comment explaining my absolute pain
This commit is contained in:
parent
9d26f3da60
commit
57ff32ee94
@ -15,6 +15,17 @@ public partial class TextWriterTests
|
|||||||
{
|
{
|
||||||
_stream = new MemoryStream();
|
_stream = new MemoryStream();
|
||||||
_writer = new StreamWriter(_stream, Encoding.UTF8);
|
_writer = new StreamWriter(_stream, Encoding.UTF8);
|
||||||
|
|
||||||
|
// When StreamWriter flushes for the first time, an encoding preamble is written to the stream,
|
||||||
|
// which is correctly mirrored by the behaviour of StreamReader.
|
||||||
|
// however, we're not using StreamReader, we read the contents of the stream
|
||||||
|
// using MemoryStream.ToArray(). This was causing one test to fail, as the first test
|
||||||
|
// that runs would cause the preamble to be written and not be accounted for when reading.
|
||||||
|
// Subsequent tests would pass since the preamble would not be written again.
|
||||||
|
// The following 4 lines ensure that the preamble is written by manually flushing the
|
||||||
|
// writer after writing a single space character. We then clear the stream, and allow
|
||||||
|
// unit tests to do their thing. This took me an HOUR AND A HALF to narrow down.
|
||||||
|
// I want to fucking die.
|
||||||
_writer.Write(' ');
|
_writer.Write(' ');
|
||||||
_writer.Flush();
|
_writer.Flush();
|
||||||
_stream.SetLength(0);
|
_stream.SetLength(0);
|
||||||
|
Loading…
Reference in New Issue
Block a user