JSON Serialization
Fallback to True Reflection
Section titled “Fallback to True Reflection”For objects that don’t have the [Reflector] attribute, you can opt into a runtime reflection fallback. Property reflection is lazy-loaded — it won’t inspect the type until you actually access a property.
var reflector = someObject.GetReflector(fallbackToTrueReflection: true);JSON Serialization
Section titled “JSON Serialization”Use ReflectorJsonConverter for AOT-safe System.Text.Json serialization that doesn’t rely on runtime reflection:
var options = new JsonSerializerOptions();
// Factory converter — works for all [Reflector] typesoptions.Converters.Add(new ReflectorJsonConverter());
// Or target a specific typeoptions.Converters.Add(new ReflectorJsonConverter<MyModel>());
var json = JsonSerializer.Serialize(model, options);var deserialized = JsonSerializer.Deserialize<MyModel>(json, options);