-
Notifications
You must be signed in to change notification settings - Fork 0
Error‐Handling | Safety
-
BinaryViewReader.LengthPrefixMaxValue { get; set; } = long.MaxValue;
If a LengthPrefix above this value is read, anInvalidDataException
will be thrown. Useful to fail fast on corrupted data, opposed to having the program hang on trying to read gigabytes of wrong data. -
BinaryViewReader.ValidateNotEndOfStream { get; set; } = true;
Throw anEndOfStreamException
on attempt to read beyond end of stream.
-
BinaryViewWriter.ValidateLengthPrefix { get; set; } = true;
Gets or Sets a value indicating whether to ensure that the writen value fits in theLengthPrefix
type range.
If undetected, this will corrupt your stream, attempts to later read any data after will probably fail. -
BinaryViewWriter.ValidateEncoding { get; set; } = false;
Gets or Sets a value indicating whether that thestring
will still be the same when read again with the same encoding.
This check is relatively expensive and is only useful when using Encodings with a limited character set likeEncoding.ASCII
.
A failure here will not result in a corrupted stream, only the read string will have an incorrect value. -
BinaryViewWriter.ValidateTerminatedString { get; set; } = true;
Gets or Sets a value indicating whetherWriteTerminatedString()
should check, if the string contains escape characters.
If undetected, this will corrupt your stream, later attempts to read this string or any data after will probably fail.