Bodu.Text.Delimited Namespace
- Package
-
Bodu.Text.Delimited 1.0.0
Purpose
Bodu.Text.Delimited parses and emits delimited records - CSV, TSV, and other character-separated value documents - as a standalone System.Text.Json-shaped library: a typed record serializer, a forward-only UTF-8 token reader/writer pair, a mutable node DOM, and a read-only document DOM. It ships as its own package (also available through the Bodu.Text.Formats umbrella); see also Bodu.Text.DotEnv, Bodu.Text.Ini, Bodu.Text.Bencode, and Bodu.Text.Toml.
Key types
- DelimitedSerializer - static serializer: typed records ↔ delimited text, including the
IAsyncEnumerablerecord-streaming overloads. - DelimitedSerializerOptions - naming policy, case sensitivity, dialect characters, and header mode for binding.
- Utf8DelimitedReader / Utf8DelimitedWriter - forward-only
ref structtoken surfaces over UTF-8, with DelimitedReaderOptions carrying the dialect policies. - DelimitedFieldCountBehavior / DelimitedMalformedRecordBehavior / DelimitedDuplicateHeaderBehavior - the strictness knobs for real-world files.
- DelimitedDocument / DelimitedElement - read-only, disposable document model (records as header-keyed objects or positional arrays).
- DelimitedNode - mutable DOM root for parse → edit → write scenarios.
- DelimitedFormatException / DelimitedSerializationException - malformed input vs. binding failures.
Example
using Bodu.Text.Delimited;
using Bodu.Text.Serialization;
var options = new DelimitedSerializerOptions { PropertyNamingPolicy = NamingPolicy.SnakeCaseLower };
List<Trade> trades = DelimitedSerializer.Deserialize<Trade>("trade_id,symbol\n1,AAPL\n", options);
string csv = DelimitedSerializer.Serialize(trades, options);
Notes
- Streaming preferred for large inputs. Use
DeserializeAsyncEnumerableAsync<TRecord>for typed rows, or theUtf8DelimitedReadertoken loop for full control. - Round-trip determinism. Writing quotes only the fields that require it under the configured delimiter/quote characters.
- See also: the line-formats introduction and the delimited guide.
Namespaces
Classes
- DelimitedFormatException
Represents an error that occurs when delimited (CSV/TSV) data is malformed, such as an unterminated quoted field or a record whose field count violates the configured policy.
- DelimitedRecordAttribute
Marks a partial record POCO for compile-time delimited binding: the
Bodu.Text.Formats.Generatorssource generator emits an IDelimitedRecordFactory<TRecord> implementation for the type, exposed through a generated staticDelimitedFactoryproperty.
- DelimitedSerializationException
Represents an error that occurs while mapping .NET records to or from delimited text with DelimitedSerializer, such as a non-collection root or a value that cannot be converted to the target column type.
- DelimitedSerializer
Provides methods for serializing collections of .NET records to delimited (RFC 4180 CSV/TSV) text and deserializing delimited text into records, shaped after
System.Text.Json'sJsonSerializer.
- DelimitedSerializerOptions
Provides configuration for DelimitedSerializer, controlling column naming, case sensitivity, field inclusion, and the output delimiter, quote, and header behaviour.
Interfaces
- IDelimitedRecordFactory<TRecord>
Provides reflection-free conversion between a record type and its delimited field representation, consumed by the DelimitedSerializer factory overloads.
Enums
- DelimitedDuplicateHeaderBehavior
Specifies how a delimited reader resolves a header row that contains the same column name more than once.
- DelimitedFieldCountBehavior
Specifies how a delimited reader treats a data record whose field count differs from the header's.
- DelimitedMalformedRecordBehavior
Specifies how a delimited reader responds to a record that violates the configured field-count policy.
- DelimitedSerializerDefaults
Specifies a set of default settings a DelimitedSerializerOptions can be initialized from.
- DelimitedTokenType
Enumerates the token kinds a Utf8DelimitedReader reports as it advances through a delimited (CSV/TSV) document.
- DelimitedValueKind
Enumerates the value kinds a delimited node or element can represent.