EnvoyConfig 0.1.0-alpha.1

This is a prerelease version of EnvoyConfig.
There is a newer version of this package available.
See the version list below for details.
dotnet add package EnvoyConfig --version 0.1.0-alpha.1
                    
NuGet\Install-Package EnvoyConfig -Version 0.1.0-alpha.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="EnvoyConfig" Version="0.1.0-alpha.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EnvoyConfig" Version="0.1.0-alpha.1" />
                    
Directory.Packages.props
<PackageReference Include="EnvoyConfig" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add EnvoyConfig --version 0.1.0-alpha.1
                    
#r "nuget: EnvoyConfig, 0.1.0-alpha.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package EnvoyConfig@0.1.0-alpha.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=EnvoyConfig&version=0.1.0-alpha.1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=EnvoyConfig&version=0.1.0-alpha.1&prerelease
                    
Install as a Cake Tool

<p align="center"> <img src="assets/logo.svg" alt="EnvoyConfig Logo" width="64"/> </p>

🚀 EnvoyConfig

Build Status NuGet License: GPL-3.0-or-later

EnvoyConfig is a modern C# library for .NET 8+ that loads strongly-typed configuration objects from environment variables at runtime using reflection. It supports advanced attribute-based mapping, type safety, nested objects, lists, dictionaries, and flexible prefixing—all with minimal boilerplate.

✨ Features

  • Attribute-based configuration: [Env] attribute for mapping properties to env vars
  • Supports primitives, enums, nullable types, lists, arrays, dictionaries, and nested objects
  • Multiple initialization modes: direct key, comma-separated/numbered lists, dictionary/map, nested prefix
  • Global/static prefix support
  • Logging integration with adapters (Microsoft, Serilog, NLog)
  • Thread-safe, high performance (caching)
  • Zero external dependencies in core

📦 Installation

dotnet add package EnvoyConfig

Optional:

dotnet add package EnvoyConfig.Adapters.Microsoft  # For Microsoft.Extensions.Logging

🚀 Quick Start

public class MyConfig {
    [Env(Key = "MYAPP_PORT", Default = "8080")]
    public int Port { get; set; }

    [Env(Key = "MYAPP_FEATURES", IsList = true)]
    public List<string> Features { get; set; } = new();
}

EnvConfig.GlobalPrefix = "MYAPP_";
var config = EnvConfig.Load<MyConfig>();

🔧 Advanced Usage & Features

  • Prefix Handling: Set EnvConfig.GlobalPrefix to prepend to all lookups.
  • Attribute Modes:
    • [Env(Key = "FOO")] (direct key)
    • [Env(Key = "BAR", IsList = true)] (comma-separated list)
    • [Env(ListPrefix = "ITEM_")] (numbered list: ITEM_1, ITEM_2, ...)
    • [Env(MapPrefix = "MAP_")] (dictionary: MAP_key1=val1, MAP_key2=val2)
    • [Env(NestedPrefix = "DB_")] (nested object)
  • Supported Types: string, int, bool, double, enums, nullable types, List<T>, T[], Dictionary<TKey,TValue>
  • Logging: Pass a custom logger (IEnvLogSink) or use an adapter for your framework.

📚 Documentation

See here for Documentation.

🛠️ Troubleshooting / FAQ

  • Type conversion errors: check env var values and types
  • Missing env vars: use Default or handle nulls
  • Prefix confusion: ensure GlobalPrefix and attribute keys are set as intended
  • Logging: implement or use provided adapters for structured logs

🤝 Contributing

Contributions are welcome! Please open issues or PRs for bugs, features, or questions.

📜 License

GPL-3.0-or-later. See LICENSE.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on EnvoyConfig:

Package Downloads
EnvoyConfig.Adapters.NLog

Package Description

EnvoyConfig.Adapters.Serilog

Package Description

EnvoyConfig.Adapters.Microsoft

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 558 6/25/2025
0.1.0-beta.108 128 6/24/2025
0.1.0-beta.96 132 6/22/2025
0.1.0-beta.81 191 6/15/2025
0.1.0-alpha.1 64 5/3/2025