Write header/schema row when WriteAll called.
The behavior of TypedWriter.WriteAll
is somewhat unintuitive when called with no records. The expectation is that the header is written when performing this bulk operation; otherwise, the caller has to explicitly call WriteSchema
beforehand. This slightly changes the behavior of the code, such that it might result in headers/schema being written in cases where the file was blank before. However, when IsFirstRecordSchema
is true
, it is extremely unlikely consumers would expect a blank file to be generated.
During my testing, I also discovered a bug where the schema was getting set, then unset, when the header/schema record was the only record in the file. You should be able to try to Read
the first record of an empty file and get false
back, then get the schema via GetSchema
; however, my code was throwing an InvalidOperationException
or, worse, a NullReferenceException
.