ConfigurationResolveOptions Class
Definition
- Namespace
- Bodu.Text.Configuration
- Assembly
- Bodu.Text.Configuration.dll
- Package
- Bodu.Text.Configuration 1.3.0
Controls how a ConfigurationDocument is projected into a ConfigurationView for a specific target path.
public sealed class ConfigurationResolveOptions
- Inheritance
-
ConfigurationResolveOptions
- Inherited Members
- Extension Methods
Remarks
Resolution is path-aware: each section in the document either matches the supplied target path (under EditorConfig
glob semantics) or does not, and the resolved view layers the preamble and every matching section in source order,
with the last matching section's value winning. This options bag controls every variable that influences that
layering - which path root anchors anchored globs, whether preamble properties contribute, which string comparison
is used for path matching, and how the EditorConfig unset sentinel is handled.
PathRoot rebases the target path before matching: a target under the root is matched relative to it,
and any other target is matched as given. When PathRoot is not set, a document loaded with
Load(string, ConfigurationParseOptions?) is rooted at the directory of its
file, so a section's glob is relative to that file, as EditorConfig defines it; an explicit PathRoot
takes precedence. MissingPathRootMode applies only when Resolve receives no target path and no
root is known: UseEmptyRoot returns the preamble-only view, and
Throw raises InvalidOperationException.
KeyOptions should normally be the same instance passed to
KeyOptions so that lookups against the resolved view use the same comparer
and mapping that produced the parsed keys. The default Default matches the
Microsoft.Extensions.Configuration shape.
// The Bodu defaults, except that the unset sentinel removes a value.
ConfigurationView view = document.Resolve(
"src/App/Program.cs",
new ConfigurationResolveOptions
{
UnsetValueMode = ConfigurationUnsetValueMode.RemoveEffectiveValue,
});
// Or start from a profile's canonical option set, whose properties carry the profile's behaviour:
ConfigurationView strict = document.Resolve(
"src/App/Program.cs",
ConfigurationResolveOptions.For(ConfigurationProfile.Strict));
Constructors
ConfigurationResolveOptions()
public ConfigurationResolveOptions()
Properties
ApplyPreambleProperties
Gets a value indicating whether preamble (global) properties contribute to resolution. Defaults to
true for the Bodu profile and false for EditorConfig-compatible. The
preamble's root pair never contributes: it marks the file as the root of its directory tree, and the
document keeps it in its global section for the caller that collects files up the tree.
public bool ApplyPreambleProperties { get; init; }
Property Value
Bodu
Gets the canonical option set for the default Bodu profile.
public static ConfigurationResolveOptions Bodu { get; }
Property Value
- ConfigurationResolveOptions
A cached default options instance.
EditorConfigCompatible
Gets the canonical option set for the EditorConfig-compatible profile: preamble properties left out, the
unset sentinel removing a value, a path root or target path required, and the
Identity key mapping with keys lowercased, so a key is kept as written,
its dots and colons included, and reads as EditorConfig lowercases it.
public static ConfigurationResolveOptions EditorConfigCompatible { get; }
Property Value
- ConfigurationResolveOptions
A cached EditorConfig-compatible options instance.
KeyOptions
Gets the key options used when expanding raw keys into configuration keys for the resolved view.
public ConfigurationKeyOptions KeyOptions { get; init; }
Property Value
- ConfigurationKeyOptions
The selected key options.
MissingPathRootMode
Gets how a resolve with no target path behaves when no root is known: PathRoot is not set and the document was not loaded from a file.
public ConfigurationMissingPathRootMode MissingPathRootMode { get; init; }
Property Value
- ConfigurationMissingPathRootMode
The selected mode.
PathComparison
Gets the comparison used when matching target paths against section patterns.
public StringComparison PathComparison { get; init; }
Property Value
- StringComparison
The selected StringComparison.
PathRoot
Gets the optional path root that a target path is rebased against before glob patterns are matched. When null, a document loaded from a file is rooted at that file's directory; when neither is available, a target path is matched as given, and MissingPathRootMode governs a resolve with no target path.
public string? PathRoot { get; init; }
Property Value
Profile
Gets the profile this option set was created from. The default is Bodu.
public ConfigurationProfile Profile { get; init; }
Property Value
- ConfigurationProfile
The profile the option set is labeled with.
Remarks
The property is informational: the resolver does not read it, and setting it changes no other property. Use For(ConfigurationProfile) or a preset to select a profile's behavior.
UnsetValueMode
Gets the unset-value handling mode used by the resolver.
public ConfigurationUnsetValueMode UnsetValueMode { get; init; }
Property Value
- ConfigurationUnsetValueMode
The selected unset-value mode.
Methods
For(ConfigurationProfile)
Returns the canonical option set for the specified profile.
public static ConfigurationResolveOptions For(ConfigurationProfile profile)
Parameters
profileConfigurationProfileThe profile to materialize.
Returns
- ConfigurationResolveOptions
An options instance configured for
profile.
Exceptions
- ArgumentOutOfRangeException
profileis not a defined value.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |