Table of Contents

Bodu.Text.DotEnv.Document Namespace

Package

Bodu.Text.DotEnv.Document

Purpose

Bodu.Text.DotEnv.Document is the read-only document object model of Bodu.Text.DotEnv, shaped after System.Text.Json's JsonDocument / JsonElement. A parse produces a disposable DotEnvDocument whose root is the flat object of entries; each DotEnvElement is a lightweight struct cursor over the root or a single string value. Prefer it over the mutable Bodu.Text.DotEnv.Nodes tier when you only need to look values up.

Key types

Example

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();
if (env.RootElement.TryGetProperty("APP_PORT", out DotEnvElement port))
    Console.WriteLine(port.GetString());

Notes

  • Lifetime. Elements are only valid while their document is undisposed.
  • Export flag not surfaced. The read-only model exposes names and values only; use the DotEnvObject DOM or the reader's CurrentIsExport when the prefix matters.
  • Literal values. No ${VAR} interpolation is applied.
  • See also: the line-formats introduction and the DotEnv guide (Pattern 1 - query a document).

Classes

DotEnvDocument

Provides a read-only, forward-parsed view over a DotEnv document, shaped after System.Text.Json's JsonDocument. The document is a flat object of string-valued keys; comment trivia is not retained.

Structs

DotEnvElement

Represents a single element - the root object or one of its string values - within a DotEnvDocument, shaped after System.Text.Json's JsonElement.

DotEnvElement.ObjectEnumerator

Enumerates the properties of a DotEnvElement object.

DotEnvProperty

Represents a single name/value property of a DotEnvElement object.