Mapping samples
Select one delegate near the top of
Program.cs,
then run:
dotnet run --project mapping/samples/Valiant.Mapping.Samples
Program.cs is intentionally only a selector. Each folder is self-contained,
and the Sample class owns the explanation of the behavior it invokes.
| Delegate | Demonstrates | Source |
|---|---|---|
Basic.Sample.Run | The smallest useful mapper: matching members mapped by convention into an immutable constructor target | Basic |
ExplicitMapping.Sample.Run | A custom source transform, a renamed target member, and an intentionally ignored target member | ExplicitMapping |
ConditionalMapping.Sample.Run | Native if/else, a chained When condition, and the equivalent Fallback and Default APIs | ConditionalMapping |
NullHandling.Sample.Run | Mapper-wide null policy, IgnoreNull, MapNull, AllowNull, and a fallback for an ignored null | NullHandling |
FlatteningAndEnums.Sample.Run | Convention-based flattening, unflattening, and compatible enum conversion | FlatteningAndEnums |
Composition.Sample.Run | Constructor-injected mapper reuse for a nested object and collection elements | Composition |
DependencyInjection.Sample.Run | Generated registration; typed mapper, non-generic facade, and factory; successful and missing Try APIs | DependencyInjection |
The basic and convention samples show what the generator can infer. Samples
with a Configure override demonstrate behavior supported by both the
debuggable runtime backend and the fast generated backend. The dependency
injection sample leaves ValiantMappingMode.Auto selected, so Debug builds use
the debuggable backend and Release builds use generated fast mapping.
Continue with Convention mapping, Explicit mapping, or Composition and dependency injection for the complete contracts and constraints.