11 public IReadOnlyList<FieldInfo>
Fields {
get; }
12 public IReadOnlyDictionary<string, FieldInfo>
FieldsByName {
get; }
14 internal bool ShouldEscapeObject {
get; }
15 internal IClassDeserializer Deserializer {
get; }
23 var hasAttributes = objAttr !=
null;
24 var fields =
new List<FieldInfo>();
25 var byName =
new Dictionary<string, FieldInfo>();
27 foreach (var prop
in ty.GetProperties())
29 var attr = hasAttributes ?
33 if (attr is
null)
continue;
35 var info =
new FieldInfo(ctx, attr, prop);
37 if (byName.ContainsKey(info.Name))
38 throw new ArgumentException($
"Duplicate field name {info.Name} in {ty}");
41 byName[info.Name] = info;
44 ShouldEscapeObject = Serializer.Tags.Overlaps(byName.Values.Select(i => i.Name));
45 Fields = fields.ToImmutableList();
48 var deserType = typeof(ClassDeserializer<>).MakeGenericType(
new[] { ty });
49 Deserializer = (IClassDeserializer)Activator.CreateInstance(deserType,
new[] {
this })!;