You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -259,7 +259,7 @@ Get errors at compile time, not runtime:
259
259
260
260
### ⚙️ OptionsBindingGenerator
261
261
262
-
Eliminate boilerplate configuration binding code. Decorate your options classes with `[OptionsBinding]` and let the generator create type-safe configuration bindings automatically. Supports DataAnnotations validation, startup validation, and custom `IValidateOptions<T>` validators for complex business rules.
262
+
Eliminate boilerplate configuration binding code. Decorate your options classes with `[OptionsBinding]` and let the generator create type-safe configuration bindings automatically. Supports DataAnnotations validation, startup validation, fail-fast validation for missing configuration sections (`ErrorOnMissingKeys`), and custom `IValidateOptions<T>` validators for complex business rules.
**Description**: Throw exceptions when required configuration keys are missing instead of silently setting properties to null/default.
303
+
**Description**: Throw exceptions when required configuration sections are missing instead of silently binding to null/default values.
303
304
304
305
**User Story**:
305
306
> "As a developer, I want my application to fail at startup if critical configuration like database connection strings is missing, rather than failing in production with NullReferenceException."
-**🧠 Automatic section name inference** - Smart resolution from explicit names, const fields (`SectionName`, `NameTitle`, `Name`), or auto-inferred from class names
-**🎯 Custom validation** - Support for `IValidateOptions<T>` for complex business rules beyond DataAnnotations
746
+
-**🚨 Error on missing keys** - Fail-fast validation when configuration sections are missing (`ErrorOnMissingKeys`) to catch deployment issues at startup
744
747
-**📛 Named options** - Multiple configurations of the same options type with different names (e.g., Primary/Secondary email servers)
745
748
-**🎯 Explicit section paths** - Support for nested sections like `"App:Database"` or `"Services:Email"`
746
749
-**📦 Multiple options classes** - Register multiple configuration sections in a single assembly with one method call
The `ErrorOnMissingKeys` feature provides fail-fast validation when configuration sections are missing, preventing runtime errors from invalid or missing configuration.
1037
+
1038
+
**When to use:**
1039
+
- Critical configuration that must be present (database connections, API keys, etc.)
1040
+
- Detect configuration issues at application startup instead of later at runtime
1041
+
- Ensure deployment validation catches missing configuration files or sections
System.InvalidOperationException: Configuration section 'Database' is missing.
1100
+
Ensure the section exists in your appsettings.json or other configuration sources.
1101
+
```
1102
+
1031
1103
### ⏱️ Options Lifetimes
1032
1104
1033
1105
Control which options interface consumers should inject. **All three interfaces are always available**, but the `Lifetime` property indicates the recommended interface for your use case:
0 commit comments