RazorDocs Search
API Reference

Config

Type

ConfigScalarTypes

Source

Provides the canonical scalar-type classification shared by configuration validation paths.

Method

IsScalar

bool IsScalar(Type type) Source

Returns whether type is treated as a scalar configuration value. Nullable wrappers are unwrapped before inspection. Supported scalar types are primitives, enums, string, decimal, DateTime, DateTimeOffset, TimeSpan, Guid, and Uri.

Parameters

  • typeThe declared or runtime value type to inspect.

Returns

true when type is a supported scalar type.

Type

ConfigAuditRedactor

Source

Applies the built-in audit redaction and value formatting policy.

Remarks

Matching is fragment based and case-insensitive across keys, config paths, applied paths, and environment variable names. Sensitive values are replaced with a fixed placeholder before rendering. Non-sensitive complex objects may produce a null display value so callers can rely on child entries instead of an unsafe dump. Formatting failures are swallowed intentionally to keep audit generation best-effort.

Method

CreatePolicy

ConfigAuditRedaction CreatePolicy() Source

Creates a snapshot of the redaction policy applied to reports.

Returns

A policy snapshot with a copy of the sensitive fragments and the placeholder text.

Method

FormatValue

RedactedValue FormatValue(string key, object? value, IReadOnlyList<ConfigAuditSourceRecord> sources) Source

Formats value for display and redacts it when the key or sources look sensitive.

Parameters

  • keyThe configuration key being formatted.
  • valueThe resolved value, if any.
  • sourcesThe sources that contributed to the value.

Returns

The display value and whether it was replaced by the redaction placeholder.

Type

RedactedValue

Source

Describes a formatted value after applying the redaction policy.

Parameters

  • DisplayValueThe safe display value, or null for non-scalar objects.
  • IsRedactedA value indicating whether the placeholder replaced the original value.
Type

EnvironmentConfigProvider

Source

A configuration provider that retrieves values from environment variables.

Method

NormalizeSegment

string NormalizeSegment(string value) Source

Converts a key/environment segment to uppercase (via string.ToUpperInvariant) and flattens separators by replacing '.' and '-' with a single '_'. Used for legacy flat environment-variable lookup.

Method

NormalizeHierarchicalKey

string NormalizeHierarchicalKey(string value) Source

Converts a key to uppercase (via string.ToUpperInvariant), splits on '.' and '-' as hierarchical delimiters, removes empty segments, and joins segments using "__". Used for hierarchical environment-variable lookup while preserving path boundaries.

Type

ConfigAuditKnownEntry

Source

Describes a configuration entry known to AppSurface's audit system.

Property

Key

string Key { get; } Source

Gets the configuration key.

Property

ConfigType

Type? ConfigType { get; } Source

Gets the config wrapper type, when this entry came from a wrapper.

Property

ValueType

Type ValueType { get; } Source

Gets the declared value type.

Type

ConfigAuditServiceCollectionExtensions

Source

Extension methods for registering additional configuration audit keys.

Method

AddConfigAuditKey

IServiceCollection AddConfigAuditKey<T>(this IServiceCollection services, string key) Source

Registers an additional configuration key for audit reports.

Type Parameters

  • TThe expected value type.

Parameters

  • servicesThe service collection.
  • keyThe configuration key.

Returns

The original services instance.

Remarks

Use this method for values that should appear in audit reports but are not backed by an IConfig or Config{T} wrapper discovered by assembly scanning. Prefer wrapper discovery when a typed wrapper already exists, because the wrapper can contribute defaults and validation diagnostics. Manual registration creates a ConfigAuditKnownEntry with ConfigAuditKnownEntry.ConfigType set to null and T as the expected value type; for example, AddConfigAuditKey<Uri>("Billing.Endpoint") includes a provider-only key in reports.

Type

IConfigProvider

Source

Defines a provider that can retrieve configuration values.

Method

GetValue

T? GetValue<T>(string environment, string key) Source

Retrieves a configuration value for a specific environment and key.

Type Parameters

  • TThe type of the configuration value.

Parameters

  • environmentThe environment name (e.g., "Production").
  • keyThe configuration key.

Returns

The configuration value, or the default value of T if not found.

Property

Priority

int Priority { get; } Source

Higher number means higher priority. When multiple providers provide the same key, the one with the highest priority wins.

Property

Name

string Name { get; } Source

Gets the name of the configuration provider.

Type

ConfigurationValidationException

Source

The exception thrown when a strongly typed configuration value fails validation during initialization.

Property

Key

string Key { get; } Source

Gets the configuration key being initialized.

Property

ConfigType

Type ConfigType { get; } Source

Gets the concrete configuration wrapper type being initialized.

Property

ValueType

Type ValueType { get; } Source

Gets the resolved value type that was validated.

Property

Failures

IReadOnlyList<ConfigurationValidationFailure> Failures { get; } Source

Gets the validation failures returned for the configuration value.

Type

Config<T>

Source

A base class for strongly-typed configuration objects. Values are resolved during IConfig.Init, then object-valued configuration models are validated with DataAnnotations and scalar values can be validated with AppSurface scalar attributes or ValidateValue. Invalid provider values and invalid defaults fail fast by throwing ConfigurationValidationException, so callers that activate config wrappers can catch that exception and surface its structured failures. Ensure defaults satisfy the same validation rules as configured values; an invalid default prevents initialization when no provider value exists. Apply ConfigKeyRequiredAttribute to require resolved provider/default presence.

Type Parameters

  • TThe type of the configuration value.
Method

Init

void Init(IConfigManager configManager, IEnvironmentProvider environmentProvider, string key) Source

Resolves the configured value for key and validates the resolved provider value or DefaultValue before initialization completes.

Parameters

  • configManagerThe configuration manager used to resolve the provider value.
  • environmentProviderThe environment provider used to choose the active environment.
  • keyThe configuration key to resolve.

Exceptions

  • ConfigurationValidationExceptionThrown when the wrapper requires a value and no provider/default value resolves, or when the provider value or default value violates object DataAnnotations or scalar validation rules.
Method

ValidateValue

IEnumerable<ValidationResult>? ValidateValue(T value, ValidationContext validationContext) Source

Validates a resolved non-null scalar configuration value. Override this method when a scalar rule is too specific for the built-in AppSurface scalar attributes.

Parameters

  • valueThe resolved provider or default scalar value.
  • validationContextThe validation context for the concrete configuration wrapper.

Returns

The validation results for value. Return null, an empty sequence, ValidationResult.Success, or null entries when validation succeeds.

Property

HasValue

bool HasValue { get; set; } Source

Gets a value indicating whether the configuration has a value (either from source or default).

Property

IsDefaultValue

bool IsDefaultValue { get; set; } Source

Gets a value indicating whether the current value is the default value.

Property

Value

T? Value { get; set; } Source

Gets the configuration value.

Property

DefaultValue

T? DefaultValue { get; } Source

Gets the default value for the configuration if none is found in the source.

Type

ConfigKeyRequiredAttribute

Source

Requires a strongly typed configuration wrapper to resolve a value during initialization.

Remarks

Apply this attribute to a concrete Config{T} or ConfigStruct{T} wrapper when startup should fail if provider/default resolution leaves the wrapper without a value. A Config{T}.DefaultValue or ConfigStruct{T}.DefaultValue satisfies the requirement because the requirement is resolved presence, not provider-source auditing.

This attribute is intentionally separate from scalar value validation attributes such as ConfigValueNotEmptyAttribute. Use ConfigKeyRequiredAttribute when absence should fail, and use value validation when a resolved value must satisfy shape or range rules.

Type

ConfigurationValidationFailure

Source

Describes one validation failure found while initializing a strongly typed configuration value.

Property

Key

string Key { get; } Source

Gets the configuration key being initialized.

Property

ConfigType

Type ConfigType { get; } Source

Gets the concrete configuration wrapper type being initialized.

Property

ValueType

Type ValueType { get; } Source

Gets the resolved value type that was validated.

Property

MemberNames

IReadOnlyList<string> MemberNames { get; } Source

Gets the member names or paths associated with the failure. Object-level failures use an empty list rather than null; consumers should treat that empty collection as a valid failure payload. The returned list is an immutable snapshot owned by this instance.

Property

Message

string Message { get; } Source

Gets the validation message.

Type

IConfigValuePatcher

Source

Provides object-graph patching for configuration providers that can supply child values beneath a requested key.

Remarks

This is an internal provider seam, not a consumer-facing configuration API. DefaultConfigManager uses it after direct provider resolution so hierarchical override sources can update only the supplied child values instead of replacing an entire options object.

Method

TryPatch

bool TryPatch<T>(string environment, string key, T? currentValue, out T? patchedValue) Source

Attempts to apply provider-owned child values beneath key to currentValue.

Type Parameters

  • TThe requested configuration value type.

Parameters

  • environmentThe active environment name.
  • keyThe configuration key whose child values may be present.
  • currentValueThe value supplied by a lower-priority provider, or default.
  • patchedValueWhen this method returns true, contains the patched value. Otherwise contains default.

Returns

true when at least one child value was applied.

Type

ConfigAuditTextRenderer

Source

Renders ConfigAuditReport instances as deterministic, human-readable text.

Method

Render

string Render(ConfigAuditReport report) Source

Renders report as text.

Parameters

  • reportThe report to render.

Returns

A human-readable report.

Type

AppSurfaceConfigModule

Source

A module that registers configuration management services and automatically discovers and registers configuration objects.

Remarks

AppSurfaceConfigModule registers core configuration services immediately, then defers typed IConfig discovery through StartupContext.CustomRegistrations so all module dependencies are known first. The deferred scan inspects dependency module assemblies, the entry assembly, and the root module assembly. Pitfall: config dependencies should be registered before the custom registration callback runs; otherwise discovered config objects may activate before their supporting services are available.

Method

ConfigureServices

void ConfigureServices(StartupContext context, IServiceCollection services) Source

Registers AppSurface config services and schedules typed config discovery after module registration.

Parameters

  • contextStartup context that supplies assemblies, dependency modules, and the custom registration log.
  • servicesService collection that receives the default configuration services.

Remarks

ConfigureServices(StartupContext, IServiceCollection) adds the default manager, providers, audit reporter, redactor, and file-location provider, then appends a StartupContext.CustomRegistrations callback. That callback scans dependency, entry, and root-module assemblies for concrete IConfig implementations and registers each as a singleton initialized from IConfigManager and IEnvironmentProvider.

Type

ConfigDataAnnotationsValidator

Source

Validates resolved Config{T} and ConfigStruct{T} values with DataAnnotations. The validator returns immediately for null values and scalar primitives, validates object and field annotations before initialization completes, and traverses nested members only when callers opt in with ValidateObjectMembersAttribute or ValidateEnumeratedItemsAttribute. Recursive traversal tracks the active object path by reference so cycles terminate while shared objects can still be reported at each reachable path. AppSurface owns this traversal and the ConfigurationValidationException shape; the custom validator type overloads on the Microsoft Options marker attributes are reported as unsupported failures rather than invoked.

Method

Validate

void Validate(string key, Type configType, Type valueType, object? value) Source

Validates a resolved configuration value and throws ConfigurationValidationException when DataAnnotations failures are found. Call this after provider/default resolution and before config initialization is considered complete. Null and scalar values short-circuit, recursive validation is marker-gated, and callers should catch ConfigurationValidationException to inspect the structured failures.

Parameters

  • keyThe configuration key being initialized.
  • configTypeThe concrete configuration wrapper type being initialized.
  • valueTypeThe resolved value type that is being validated.
  • valueThe resolved provider or default value.

Exceptions

  • ConfigurationValidationExceptionThrown when the resolved value or an opted-in nested value violates DataAnnotations validation rules.
Type

ConfigKeyAttribute

Source

Specifies the configuration key or path for a type.

Method

ExtractKey

2 overloads
string? ExtractKey(object obj) Source

Extracts the configuration key from an object's type attribute.

Parameters

  • objThe object to extract the key from.

Returns

The configuration key, or null if not specified.

string? ExtractKey(Type type) Source

Extracts the configuration key from a type's attribute.

Parameters

  • typeThe type to extract the key from.

Returns

The configuration key, or null if not specified.

Method

GetKeyPath

string GetKeyPath(Type type) Source

Computes the full configuration key path for a type, recursively including declaring types unless Root is true.

Parameters

  • typeThe type to compute the path for.

Returns

The computed configuration key path.

Property

Key

string Key { get; } Source

Gets the configuration key or path for this type.

Property

Root

bool Root { get; } Source

Gets a value indicating whether this key should be treated as a root key, ignoring the declaring type hierarchy.

Type

FileBasedConfigProvider

Source

A configuration provider that reads settings from JSON files (e.g., appsettings.json, config_*.json).

Type

ConfigStruct<T>

Source

A base class for strongly-typed configuration objects where the value is a struct. Values are resolved during IConfig.Init, then object-valued configuration models are validated with DataAnnotations and scalar values can be validated with AppSurface scalar attributes or ValidateValue. Invalid provider values and invalid defaults fail fast by throwing ConfigurationValidationException, so callers that activate config wrappers can catch that exception and surface its structured failures. Ensure defaults satisfy the same validation rules as configured values; an invalid default prevents initialization when no provider value exists. Apply ConfigKeyRequiredAttribute to require resolved provider/default presence.

Type Parameters

  • TThe struct type of the configuration value.
Method

Init

void IConfig.Init(IConfigManager configManager, IEnvironmentProvider environmentProvider, string key) Source

Resolves the configured value for key and validates the resolved provider value or DefaultValue before initialization completes.

Parameters

  • configManagerThe configuration manager used to resolve the provider value.
  • environmentProviderThe environment provider used to choose the active environment.
  • keyThe configuration key to resolve.

Exceptions

  • ConfigurationValidationExceptionThrown when the wrapper requires a value and no provider/default value resolves, or when the provider value or default value violates object DataAnnotations or scalar validation rules.
Method

ValidateValue

IEnumerable<ValidationResult>? ValidateValue(T value, ValidationContext validationContext) Source

Validates a resolved non-null scalar configuration value. Override this method when a scalar rule is too specific for the built-in AppSurface scalar attributes.

Parameters

  • valueThe resolved provider or default scalar value.
  • validationContextThe validation context for the concrete configuration wrapper.

Returns

The validation results for value. Return null, an empty sequence, ValidationResult.Success, or null entries when validation succeeds.

Property

HasValue

bool HasValue { get; set; } Source

Gets a value indicating whether the configuration has a value.

Property

IsDefaultValue

bool IsDefaultValue { get; set; } Source

Gets a value indicating whether the current value is the default value.

Property

Value

T? Value { get; set; } Source

Gets the configuration value.

Property

DefaultValue

T? DefaultValue { get; } Source

Gets the default value for the configuration if none is found in the source.

Type

ConfigPresenceValidator

Source

Validates required resolved presence for strongly typed configuration wrappers.

Method

Validate

void Validate(string key, Type configType, Type valueType, bool hasValue) Source

Throws ConfigurationValidationException when a wrapper marked with ConfigKeyRequiredAttribute has no resolved provider or default value.

Parameters

  • keyThe configuration key being initialized.
  • configTypeThe concrete configuration wrapper type being initialized.
  • valueTypeThe declared configuration value type.
  • hasValueWhether provider/default resolution produced a value.
Type

IEnvironmentConfigProvider

Source

Defines a configuration provider that also provides environment information.

Remarks

IEnvironmentConfigProvider composes IConfigProvider with IEnvironmentProvider for implementations that need to resolve configuration and the active environment from the same source. Prefer the composite when environment-aware config lookup should be atomic or co-located in one implementation; use the separate interfaces when configuration and environment ownership differ. Implementations should be safe for repeated reads, define any caching or refresh behavior, and avoid assuming that all configuration is environment-exclusive. Disposal and lifetime follow the concrete provider registration.

Type

IConfigAuditReporter

Source

Produces structured configuration audit reports.

Remarks

Reporters inspect known configuration keys, provider provenance, validation diagnostics, and redacted display values. Implementations should return a report with diagnostics for recoverable provider and wrapper failures rather than throwing after argument validation succeeds.

Method

GetReport

ConfigAuditReport GetReport(string environment) Source

Builds a configuration audit report for environment.

Parameters

  • environmentThe environment to audit.

Returns

The completed audit report.

Type

ConfigAuditReporter

Source

Default implementation that mirrors configuration resolution while preserving source and diagnostic metadata.

Remarks

This internal reporter treats IEnvironmentConfigProvider as the override provider, excludes manager/internal provider registrations from the displayed provider list, and favors wrapper-discovered audit entries when duplicate keys are registered manually. Provider failures are converted into diagnostics so one broken provider does not prevent operators from seeing the rest of the report.

Type

ConfigValueResolution

Source

Captures a provider's value resolution result before wrapper inspection and redaction.

Parameters

  • KeyThe configuration key being resolved.
  • StateThe provider-level resolution state.
  • ValueThe resolved raw value, or null when missing or invalid.
  • SourcesThe sources that contributed to the value.
  • DiagnosticsDiagnostics emitted while resolving the value.

Remarks

The reporter uses this internal contract to keep value state, provenance, and diagnostics together while it walks providers in precedence order. Missing values should be represented with Missing(string).

Method

Missing

ConfigValueResolution Missing(string key) Source

Creates a missing resolution with a synthetic missing source record for key.

Parameters

  • keyThe missing configuration key.

Returns

A missing resolution that can still be rendered with provenance.

Type

ConfigPatchDiagnosticResult

Source

Describes the result of tracing environment patches onto an existing provider value.

Parameters

  • PatchedA value indicating whether any member was patched.
  • ValueThe patched value, or the original/current value when unchanged.
  • SourcesThe environment sources that successfully patched the value.
  • DiagnosticsDiagnostics produced while reading patch candidates.
Type

ConfigWrapperInspection

Source

Describes wrapper inspection after provider resolution.

Parameters

  • ValueThe value to display and expand after defaulting or validation.
  • StateThe wrapper-adjusted state, or null to keep provider state.
  • DefaultSourceThe default source when the wrapper supplied a fallback value.
  • DiagnosticsValidation and wrapper diagnostics.
Type

IConfigDiagnosticProvider

Source

Allows providers to expose audit-specific resolution details and report-level diagnostics.

Remarks

Implementations should avoid throwing for expected parse or source errors and return diagnostics instead. The reporter catches unexpected exceptions and converts them into provider diagnostics.

Method

Resolve

ConfigValueResolution Resolve(string environment, string key, Type valueType, ConfigAuditSourceRole role) Source

Resolves key for audit reporting without losing source metadata.

Parameters

  • environmentThe environment being audited.
  • keyThe configuration key.
  • valueTypeThe expected value type.
  • roleThe role the provider plays in final resolution.

Returns

The provider-specific resolution result.

Method

GetReportDiagnostics

IReadOnlyList<ConfigAuditDiagnostic> GetReportDiagnostics(string environment) Source

Gets diagnostics that apply to the whole report rather than one key.

Parameters

  • environmentThe environment being audited.

Returns

Report-level diagnostics. Return an empty list when there are none.

Type

IConfigDiagnosticPatcher

Source

Allows an override provider to trace member-level patches onto a base provider value.

Remarks

The environment provider uses this to explain mixed provenance for object values without mutating the provider instance that supplied the base value.

Method

TracePatch

ConfigPatchDiagnosticResult TracePatch(string environment, string key, object? currentValue, Type valueType) Source

Traces patch candidates for key and returns a cloned patched value when possible.

Parameters

  • environmentThe environment being audited.
  • keyThe configuration key.
  • currentValueThe lower-priority provider value to patch, when any.
  • valueTypeThe expected value type.

Returns

The patch result, including successful patch sources and diagnostics.

Type

IConfigInspectable

Source

Allows config wrappers to add defaults and validation diagnostics to an audit entry.

Remarks

Implementations receive the raw provider value and should return structured diagnostics rather than throwing for validation failures. Unexpected exceptions are caught by the wrapper implementations.

Method

Inspect

ConfigWrapperInspection Inspect(string key, object? rawValue, ConfigAuditEntryState resolutionState) Source

Inspects a resolved value for defaults and validation.

Parameters

  • keyThe configuration key.
  • rawValueThe raw provider value, or null when missing.
  • resolutionStateThe state determined during provider resolution.

Returns

The wrapper inspection result.

Type

IConfigFileLocationProvider

Source

Provides the base directory used to resolve AppSurface configuration files.

Remarks

Implementations should return a stable absolute path that exists and is readable by the process. The default implementation returns AppContext.BaseDirectory. Callers should validate Directory before opening files and report a configuration error when it is null, empty, missing, unreadable, or unsuitable for the current platform. Paths should not depend on the current working directory; symlinks and platform separators are implementation details callers should normalize before comparison.

Property

Directory

string Directory { get; } Source

Gets the absolute directory path containing configuration files.

Remarks

The value should be an absolute path without a required trailing slash. The provider does not own the directory lifetime and should not create, delete, or lock it. A typical consumer checks System.IO.Directory.Exists(provider.Directory) before resolving known config file names below that path and returns a clear validation failure when the directory is unavailable.

Type

DefaultConfigFileLocationProvider

Source

Default implementation of IConfigFileLocationProvider that uses the application's base directory.

Remarks

DefaultConfigFileLocationProvider returns AppContext.BaseDirectory from Directory. This is appropriate for simple apps that keep configuration beside application binaries. Use a custom IConfigFileLocationProvider for environment-specific, user-scoped, container-mounted, or service-hosted configuration. Pitfall: AppContext.BaseDirectory is not necessarily System.IO.Directory.GetCurrentDirectory and can vary by deployment model, test runner, or host.

Type

ConfigValueValidationAttribute

Source

Base class for AppSurface scalar configuration value validation attributes. Apply derived attributes to concrete Config{T} or ConfigStruct{T} wrapper types to validate resolved scalar values during configuration initialization.

Remarks

Scalar validation runs after provider/default resolution and only when the resolved value is non-null. These attributes validate the value itself; they do not make a missing configuration key required. Use a default value or an application startup presence check when absence should fail.

Validation is intentionally strict about value types. Built-in scalar attributes return validation failures for unsupported runtime types instead of converting values. Use an options object with DataAnnotations when validation spans multiple members, needs nested object traversal, or should model required presence separately from value shape.

The validation context object is the concrete config wrapper and does not provide application dependency injection services. Override Config{T}.ValidateValue or ConfigStruct{T}.ValidateValue for scalar rules that cannot be expressed as reusable attributes.

Type

ConfigValueNotEmptyAttribute

Source

Validates that a resolved scalar configuration value is not empty. Supported value types are string and Guid.

Remarks

A null value is treated as successful validation so optional or missing scalar values remain optional. Non-null strings must contain non-whitespace characters, and non-null Guid values must not be Guid.Empty.

Runtime type matching is strict: only string and Guid are supported. Applying this attribute to a different scalar value type returns a validation failure rather than attempting a conversion. Use an options object with member-level DataAnnotations when required presence, cross-field rules, or richer object validation is part of the contract.

Type

ConfigValueRangeAttribute

Source

Validates that a resolved scalar numeric configuration value is inside an inclusive range. Supported value types are int and double.

Remarks

A null value is treated as successful validation so optional or missing scalar values remain optional. Non-null values are compared against the inclusive minimum and maximum supplied to the constructor.

Range validation accepts resolved int and double values. Integer bounds are widened when validating a double value, so attribute arguments such as [ConfigValueRange(1, 5)] work for ConfigStruct<double> wrappers. Unsupported runtime types return validation failures instead of being converted. Use an options object when validation needs multiple numeric fields, required presence, or object-level DataAnnotations.

Property

Minimum

object Minimum { get; } Source

Gets the inclusive minimum allowed value as a boxed int or double, matching the constructor overload used to create the attribute.

Remarks

The integer constructor stores a boxed int, and the double constructor stores a boxed double. Callers should unbox this value according to the constructor overload they used. The attribute treats the bound as inclusive and may widen integer bounds when validating double values.

Property

Maximum

object Maximum { get; } Source

Gets the inclusive maximum allowed value as a boxed int or double, matching the constructor overload used to create the attribute.

Remarks

The integer constructor stores a boxed int, and the double constructor stores a boxed double. Callers should unbox this value according to the constructor overload they used. The attribute treats the bound as inclusive and may widen integer bounds when validating double values.

Type

ConfigValueMinLengthAttribute

Source

Validates that a resolved scalar string configuration value has at least the configured length.

Remarks

A null value is treated as successful validation so optional or missing scalar values remain optional. Non-null strings must have a length greater than or equal to Length.

Runtime type matching is strict: only string values are supported. Applying this attribute to another scalar value type returns a validation failure rather than converting the value. Use an options object with DataAnnotations when string length is only one part of a larger model contract or when required presence should be represented separately.

Property

Length

int Length { get; } Source

Gets the minimum allowed string length.

Type

DefaultConfigManager

Source

Default implementation of IConfigManager that aggregates configuration from multiple sources.

Method

LogKeyNotFound

void LogKeyNotFound(string key, string environment) Source

Logs that a configuration key was not found.

Parameters

  • keyThe configuration key.
  • environmentThe environment name.
Method

LogRetrievedFromEnvironment

void LogRetrievedFromEnvironment(string key, string environment, string source) Source

Logs that a configuration key was retrieved from a specific source.

Parameters

  • keyThe configuration key.
  • environmentThe environment name.
  • sourceThe source of the configuration value.
Type

ConfigValidationFailureFactory

Source

Creates ConfigurationValidationFailure instances from DataAnnotations results while preserving AppSurface's member-path formatting contract.

Method

FromValidationResult

ConfigurationValidationFailure FromValidationResult(string key, Type configType, Type valueType, string? path, ValidationResult result, string? defaultMemberName = null) Source

Converts a ValidationResult into a configuration-validation failure payload.

Parameters

  • keyThe configuration key being validated.
  • configTypeThe concrete configuration wrapper type.
  • valueTypeThe resolved value type being validated.
  • pathOptional member path prefix. When present, validation-result member names are combined under this path using dot notation, and the path itself is used when the result has no member names.
  • resultThe validation result to convert.
  • defaultMemberNameOptional fallback member name used when result has no member names, such as field-level validation where DataAnnotations did not bind the member name itself.

Returns

A normalized ConfigurationValidationFailure.

Type

IConfig

Source

Defines a configuration object that can be initialized using a configuration manager.

Method

Init

void Init(IConfigManager configManager, IEnvironmentProvider environmentProvider, string key) Source

Initializes the configuration object, resolving its provider or default value and failing fast with ConfigurationValidationException when required presence is not satisfied or when the resolved value violates object DataAnnotations rules or scalar value validation rules. Exceptions thrown by scalar Config{T}.ValidateValue or ConfigStruct{T}.ValidateValue overrides are not wrapped, so callers that activate config wrappers during startup should let unexpected programming errors fail the startup path.

Parameters

  • configManagerThe configuration manager to use for retrieving values.
  • environmentProviderThe environment provider.
  • keyThe root configuration key for this object.

Exceptions

  • ConfigurationValidationExceptionThrown when the wrapper requires a value and no provider/default value resolves, or when the resolved provider value or default value violates object DataAnnotations or scalar validation rules.
  • ExceptionThrown when a concrete scalar validation override throws; override exceptions are not wrapped.
Type

ConfigAuditReport

Source

Describes the resolved configuration state for an AppSurface environment.

Remarks

Reports are immutable snapshots from the caller's perspective: provider order, entries, diagnostics, and redaction policy describe one audit run and should not be treated as live configuration. Use Entries for machine inspection and ConfigAuditTextRenderer when operators need a deterministic text dump.

Property

Environment

string Environment { get; init; } Source

Gets the environment this report describes.

Property

GeneratedAt

DateTimeOffset GeneratedAt { get; init; } Source

Gets the time when this report was generated.

Property

Providers

IReadOnlyList<ConfigAuditProvider> Providers { get; init; } Source

Gets the provider precedence used while producing this report.

Property

Entries

IReadOnlyList<ConfigAuditEntry> Entries { get; init; } Source

Gets the known configuration entries resolved for this environment.

Property

Diagnostics

IReadOnlyList<ConfigAuditDiagnostic> Diagnostics { get; init; } Source

Gets report-level diagnostics that are not tied to a single entry.

Property

Redaction

ConfigAuditRedaction Redaction { get; init; } Source

Gets the redaction policy applied before this report was returned.

Type

ConfigAuditProvider

Source

Describes one provider in the audit report precedence list.

Remarks

Precedence is the display order used by audit reports. Environment providers are marked as overrides because they are checked before normal priority-ordered providers.

Property

Name

string Name { get; init; } Source

Gets the provider name.

Property

Priority

int Priority { get; init; } Source

Gets the provider priority.

Property

Precedence

int Precedence { get; init; } Source

Gets the precedence rank used by the configuration manager. Lower ranks are checked first.

Property

IsOverride

bool IsOverride { get; init; } Source

Gets a value indicating whether the manager treats this provider as an override outside normal priority order.

Type

ConfigAuditEntry

Source

Describes one known configuration entry and its source records.

Remarks

State summarizes the entry as a whole. Object entries can contain Children with more specific provenance, including nested ConfigAuditEntryState.PartiallyResolved states when descendants are patched. DisplayValue is already redacted and can be null for complex values; callers should inspect children instead of assuming a full object dump is available.

Property

Key

string Key { get; init; } Source

Gets the configuration key.

Property

DeclaredType

string? DeclaredType { get; init; } Source

Gets the declared value type name when known.

Property

State

ConfigAuditEntryState State { get; init; } Source

Gets the resolved entry state.

Property

DisplayValue

string? DisplayValue { get; init; } Source

Gets the display-safe value. Sensitive values are already redacted.

Property

IsRedacted

bool IsRedacted { get; init; } Source

Gets a value indicating whether DisplayValue was redacted.

Property

Sources

IReadOnlyList<ConfigAuditSourceRecord> Sources { get; init; } Source

Gets the source records that contributed to this entry.

Property

Children

IReadOnlyList<ConfigAuditEntry> Children { get; init; } Source

Gets child entries for object-valued configuration.

Property

Diagnostics

IReadOnlyList<ConfigAuditDiagnostic> Diagnostics { get; init; } Source

Gets diagnostics specific to this entry.

Type

ConfigAuditSourceRecord

Source

Describes one source that contributed to a configuration entry.

Remarks

Source records identify where a value came from and how it was applied. File paths, environment variable names, and config paths are optional because not every provider exposes the same provenance. The source role is especially important for mixed values: a base source can be combined with patch sources from higher-priority providers.

Property

Kind

ConfigAuditSourceKind Kind { get; init; } Source

Gets the source kind.

Property

ProviderName

string? ProviderName { get; init; } Source

Gets the provider name when applicable.

Property

ProviderPriority

int? ProviderPriority { get; init; } Source

Gets the provider priority when applicable.

Property

FilePath

string? FilePath { get; init; } Source

Gets the file path for file-sourced values.

Property

EnvironmentVariableName

string? EnvironmentVariableName { get; init; } Source

Gets the environment variable name for environment-sourced values.

Property

ConfigPath

string? ConfigPath { get; init; } Source

Gets the source config path.

Property

AppliedToPath

string? AppliedToPath { get; init; } Source

Gets the target config path affected by this source.

Property

Role

ConfigAuditSourceRole Role { get; init; } Source

Gets the role this source played in resolution.

Property

Sensitivity

ConfigAuditSensitivity Sensitivity { get; init; } Source

Gets the sensitivity classification supplied by the source.

Type

ConfigAuditDiagnostic

Source

Describes a diagnostic emitted while building a configuration audit report.

Remarks

Diagnostic messages are intended to be display-safe and stable enough for operators. Use Code for programmatic handling, and use Source when a diagnostic can be tied to one provider, file, or environment variable.

Property

Severity

ConfigAuditDiagnosticSeverity Severity { get; init; } Source

Gets the diagnostic severity.

Property

Code

string Code { get; init; } Source

Gets a stable diagnostic code.

Property

Message

string Message { get; init; } Source

Gets the display-safe diagnostic message.

Property

Key

string? Key { get; init; } Source

Gets the configuration key associated with the diagnostic, when any.

Property

ConfigPath

string? ConfigPath { get; init; } Source

Gets the member/config path associated with the diagnostic, when any.

Property

Source

ConfigAuditSourceRecord? Source { get; init; } Source

Gets the source associated with the diagnostic, when any.

Type

ConfigAuditRedaction

Source

Describes the redaction policy applied to a configuration audit report.

Remarks

The built-in policy is always enabled and uses fragment matching before values are exposed through ConfigAuditEntry.DisplayValue. MatchedFragments is a snapshot for explanation, not a mutable policy hook.

Property

Enabled

bool Enabled { get; init; } Source

Gets a value indicating whether redaction was enabled.

Property

MatchedFragments

IReadOnlyList<string> MatchedFragments { get; init; } Source

Gets the sensitive fragments matched by the built-in redactor.

Property

Placeholder

string Placeholder { get; init; } Source

Gets the display placeholder used for redacted values.

Enum

ConfigAuditEntryState

Source

Identifies the resolution state for an audited configuration entry.

Remarks

Values are explicit and append-only so serialized reports remain stable across releases.

Enum

ConfigAuditSourceKind

Source

Identifies the kind of configuration source.

Remarks

Values are explicit and append-only so serialized reports remain stable across releases.

Enum

ConfigAuditSourceRole

Source

Identifies how a source contributed to the final value.

Remarks

Values are explicit and append-only so serialized reports remain stable across releases.

Enum

ConfigAuditSensitivity

Source

Classifies source or value sensitivity.

Remarks

Values are explicit and append-only so serialized reports remain stable across releases.

Enum

ConfigAuditDiagnosticSeverity

Source

Identifies diagnostic severity.

Remarks

Values are explicit and append-only so serialized reports remain stable across releases.

Type

IConfigManager

Source

Defines the central manager for configuration, which aggregates multiple IConfigProvider instances.