21 public IReadOnlyList<FieldInfo>
Fields {
get; }
25 public IReadOnlyDictionary<string, FieldInfo>
FieldsByName {
get; }
27 internal bool ShouldEscapeObject {
get; }
29 internal Module? Collection {
get; }
35 Collection = colName !=
null ?
new Module(colName) : null;
38 bool hasAttributes = objAttr !=
null;
39 var fields =
new List<FieldInfo>();
40 var byName =
new Dictionary<string, FieldInfo>();
42 foreach (var prop
in ty.GetProperties())
44 var attr = hasAttributes ?
48 if (attr is
null)
continue;
50 var info =
new FieldInfo(ctx, attr, prop);
52 if (byName.ContainsKey(info.Name))
53 throw new ArgumentException($
"Duplicate field name {info.Name} in {ty}");
56 byName[info.Name] = info;
59 ShouldEscapeObject = Serializer.Tags.Overlaps(byName.Values.Select(i => i.Name));
60 Fields = fields.ToImmutableList();
63 var serType = typeof(ClassSerializer<>).MakeGenericType(
new[] { ty });
64 ClassSerializer = (
ISerializer)Activator.CreateInstance(serType,
this, Collection !=
null)!;
A class representing the mapping context to be used during serialization and deserialization.