Table of Contents

Bodu.Text.DotEnv Namespace

Package

Bodu.Text.DotEnv

Purpose

Bodu.Text.DotEnv parses and emits .env files - a flat object of KEY=value entries with export prefixes, quoting, and comments - as a standalone System.Text.Json-shaped library: a typed settings serializer, a forward-only UTF-8 token reader/writer pair, a mutable node DOM, and a read-only document DOM. Values are deliberately literal: no ${VAR} interpolation happens at parse time. It ships as its own package (also available through the Bodu.Text.Formats umbrella); see also Bodu.Text.Delimited and Bodu.Text.Ini.

Key types

Example

using Bodu.Text.DotEnv;
using Bodu.Text.DotEnv.Document;

using DotEnvDocument env = DotEnvDocument.Parse("export APP_ENV=production\nAPP_PORT=8080\n"u8);
string appEnv = env.RootElement.GetProperty("APP_ENV").GetString();

Notes

Namespaces

Bodu.Text.DotEnv.Document
Bodu.Text.DotEnv.Nodes
Bodu.Text.DotEnv.Reader
Bodu.Text.DotEnv.Writer

Classes

DotEnvFormatException

Represents an error that occurs when DotEnv data is malformed.

DotEnvSerializationException

Represents an error that occurs while mapping a .NET object to or from DotEnv with DotEnvSerializer, such as an unsupported root type, a missing required key, or a value that cannot be converted to the target type.

DotEnvSerializer

Provides methods for serializing .NET objects to DotEnv text and deserializing DotEnv text into .NET objects, shaped after System.Text.Json's JsonSerializer.

DotEnvSerializerOptions

Provides configuration for DotEnvSerializer, controlling property naming, case sensitivity, field inclusion, null handling, and the export prefix on the write path.

Enums

DotEnvSerializerDefaults

Specifies a set of default settings a DotEnvSerializerOptions can be initialized from.

DotEnvTokenType

Enumerates the token kinds a Utf8DotEnvReader reports as it advances through a DotEnv document.

DotEnvValueKind

Enumerates the value kinds a DotEnv node or element can represent.