Class ScalarValuePathTracking
- Namespace
- Trellis.Asp.Validation
- Assembly
- Trellis.Asp.dll
Registry of compile-time-closed path-tracking converters, keyed by the property or container type
they wrap. It is the Native AOT counterpart to the reflection pipeline's runtime
Type.MakeGenericType construction: AOT forbids building a closed generic at runtime, so the
closed instantiations are created by the source generator at compile time and registered here.
public static class ScalarValuePathTracking
- Inheritance
-
ScalarValuePathTracking
- Inherited Members
Remarks
Consumers do not normally call this type. The Trellis ASP source generator emits a
[ModuleInitializer] that registers every scalar property and container type in the DTO graph
reachable from a [JsonSerializable]-annotated JsonSerializerContext, so index-precise
validation field paths (/members/0/email) work identically in reflection and Native AOT.
Manual registration is supported for the cases the generator cannot see — for example a DTO reached
only through a hand-written JsonSerializerContext in another assembly, or a bespoke collection
shape. Registration is idempotent and last-call-wins; it is expected to happen once at startup
(module initialization), before any deserialization, and is safe to call concurrently.
A property type that is not registered simply falls back to the reflection pipeline (when dynamic code is available) or to leaf-only field names (under AOT) — never to an error.
Methods
RegisterCollection<TCollection, TElement>()
Registers a collection property type so failures inside its elements report an index-precise
path (e.g. /members/0/email).
public static void RegisterCollection<TCollection, TElement>()
Type Parameters
TCollectionThe declared collection property type —
List<TElement>,TElement[], or an interface (IList/ICollection/IEnumerable/IReadOnlyList/IReadOnlyCollectionofTElement) thatList<TElement>is assignable to.TElementThe element type.
RegisterDictionary<TDictionary, TValue>()
Registers a string-keyed dictionary property type so failures inside its values report a
key-precise path (e.g. /prices/USD/amount).
public static void RegisterDictionary<TDictionary, TValue>()
Type Parameters
TDictionaryThe declared dictionary property type —
Dictionary<string, TValue>, or an interface (IDictionary/IReadOnlyDictionaryofstringandTValue) that it is assignable to.TValueThe value type.
Remarks
Only string-keyed dictionaries are supported: a non-string key has no faithful RFC 6901 rendering, so those shapes fall back to leaf-only paths rather than emitting a pointer a client cannot map back to its input.
RegisterObject<T>()
Registers a nested-object property type so failures inside it report the full path
(e.g. /contact/email rather than /email).
public static void RegisterObject<T>()
Type Parameters
TThe object property type appearing in a DTO — for example
AddressDtofor aContactproperty.
RegisterProperty<T>()
Registers a scalar property type so failures use its effective JSON property name under Native
AOT, including names selected by a naming policy or JsonPropertyNameAttribute.
public static void RegisterProperty<T>()
Type Parameters
TThe scalar or optional scalar property type.