From 33861089dfaedbe757b2141b9626c47f193dfe13 Mon Sep 17 00:00:00 2001 From: RogueException Date: Sat, 12 Aug 2017 04:15:31 -0300 Subject: [PATCH] Scan base types when searching for serializable props --- src/Discord.Net.Serialization/Serializer.cs | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/Discord.Net.Serialization/Serializer.cs b/src/Discord.Net.Serialization/Serializer.cs index b58354103..acac27bb9 100644 --- a/src/Discord.Net.Serialization/Serializer.cs +++ b/src/Discord.Net.Serialization/Serializer.cs @@ -56,18 +56,23 @@ namespace Discord.Serialization return _maps.GetOrAdd(typeof(TModel), _ => { var type = typeof(TModel).GetTypeInfo(); - var propInfos = type.DeclaredProperties - .Where(x => x.CanRead && x.CanWrite) - .ToArray(); - var properties = new List(); - for (int i = 0; i < propInfos.Length; i++) + while (type != null) { - if (propInfos[i].GetCustomAttribute() != null) + var propInfos = type.DeclaredProperties + .Where(x => x.CanRead && x.CanWrite) + .ToArray(); + + for (int i = 0; i < propInfos.Length; i++) { - var propMap = MapProperty(propInfos[i]); - properties.Add(propMap); + if (propInfos[i].GetCustomAttribute() != null) + { + var propMap = MapProperty(propInfos[i]); + properties.Add(propMap); + } } + + type = type.BaseType?.GetTypeInfo(); } return new ModelMap(this, type, properties); }) as ModelMap;