|
10 | 10 | using System.Linq; |
11 | 11 | using System.Reflection; |
12 | 12 | using com.IvanMurzak.ReflectorNet.Model; |
| 13 | +using com.IvanMurzak.ReflectorNet.Utils; |
13 | 14 | using Microsoft.Extensions.Logging; |
14 | 15 |
|
15 | 16 | namespace com.IvanMurzak.ReflectorNet.Converter |
@@ -63,9 +64,25 @@ public virtual SerializedMember Serialize( |
63 | 64 | foreach (var field in fields) |
64 | 65 | { |
65 | 66 | if (GetIgnoredFields().Contains(field.Name)) |
| 67 | + { |
| 68 | + if (logger?.IsEnabled(LogLevel.Trace) == true) |
| 69 | + logger.LogTrace("{padding} Skipping serialization of field '{fieldName}' in '{objType}' because it is ignored.\nPath: {path}", |
| 70 | + StringUtils.GetPadding(depth + 1), field.Name, objType.GetTypeId(), context?.GetPath(obj)); |
| 71 | + continue; |
| 72 | + } |
| 73 | + if (reflector.Converters.IsTypeBlacklisted(field.FieldType)) |
| 74 | + { |
| 75 | + if (logger?.IsEnabled(LogLevel.Trace) == true) |
| 76 | + logger.LogTrace("{padding} Skipping serialization of field '{fieldName}' of type '{type}' in '{objType}' because its type is blacklisted.\nPath: {path}", |
| 77 | + StringUtils.GetPadding(depth + 1), field.Name, field.FieldType.GetTypeId(), objType.GetTypeId(), context?.GetPath(obj)); |
66 | 78 | continue; |
| 79 | + } |
67 | 80 | try |
68 | 81 | { |
| 82 | + if (logger?.IsEnabled(LogLevel.Trace) == true) |
| 83 | + logger.LogTrace("{padding} Serializing field '{fieldName}' of type '{type}' in '{objType}'.\nPath: {path}", |
| 84 | + StringUtils.GetPadding(depth + 1), field.Name, field.FieldType.GetTypeId(), objType.GetTypeId(), context?.GetPath(obj)); |
| 85 | + |
69 | 86 | var value = field.GetValue(obj); |
70 | 87 | var fieldType = field.FieldType; |
71 | 88 |
|
@@ -112,9 +129,25 @@ public virtual SerializedMember Serialize( |
112 | 129 | foreach (var prop in properties) |
113 | 130 | { |
114 | 131 | if (GetIgnoredProperties().Contains(prop.Name)) |
| 132 | + { |
| 133 | + if (logger?.IsEnabled(LogLevel.Trace) == true) |
| 134 | + logger.LogTrace("{padding} Skipping serialization of property '{propertyName}' in '{objType}' because it is ignored.\nPath: {path}", |
| 135 | + StringUtils.GetPadding(depth + 1), prop.Name, objType.GetTypeId(), context?.GetPath(obj)); |
| 136 | + continue; |
| 137 | + } |
| 138 | + if (reflector.Converters.IsTypeBlacklisted(prop.PropertyType)) |
| 139 | + { |
| 140 | + if (logger?.IsEnabled(LogLevel.Trace) == true) |
| 141 | + logger.LogTrace("{padding} Skipping serialization of property '{propertyName}' of type '{type}' in '{objType}' because its type is blacklisted.\nPath: {path}", |
| 142 | + StringUtils.GetPadding(depth + 1), prop.Name, prop.PropertyType.GetTypeId(), objType.GetTypeId(), context?.GetPath(obj)); |
115 | 143 | continue; |
| 144 | + } |
116 | 145 | try |
117 | 146 | { |
| 147 | + if (logger?.IsEnabled(LogLevel.Trace) == true) |
| 148 | + logger.LogTrace("{padding} Serializing property '{propertyName}' of type '{type}' in '{objType}'.\nPath: {path}", |
| 149 | + StringUtils.GetPadding(depth + 1), prop.Name, prop.PropertyType.GetTypeId(), objType.GetTypeId(), context?.GetPath(obj)); |
| 150 | + |
118 | 151 | var value = prop.GetValue(obj); |
119 | 152 | var propType = prop.PropertyType; |
120 | 153 |
|
|
0 commit comments