Commit 61195bf0 authored by Rob Mackenzie's avatar Rob Mackenzie

Snapshotter now supports private properties.

Private properties can serve as helpful passthroughs to more complex
public properties.  SqlMapper honors private properties when mapping
properties, so it seems natural for Snapshotter to follow suit on the
'get' side of things within the Dapper ecosystem.
parent 2b659bc7
......@@ -58,10 +58,10 @@ private static DynamicParameters Diff(T original, T current)
static List<PropertyInfo> RelevantProperties()
{
return typeof(T).GetProperties(BindingFlags.Instance | BindingFlags.Public)
return typeof(T).GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
.Where(p =>
p.GetSetMethod() != null &&
p.GetGetMethod() != null &&
p.GetSetMethod(true) != null &&
p.GetGetMethod(true) != null &&
(p.PropertyType == typeof(string) ||
p.PropertyType.IsValueType() ||
(p.PropertyType.IsGenericType() && p.PropertyType.GetGenericTypeDefinition() == typeof(Nullable<>)))
......@@ -98,11 +98,11 @@ private static bool AreEqual<U>(U first, U second)
// []
il.Emit(OpCodes.Ldarg_0);
// [original]
il.Emit(OpCodes.Callvirt, prop.GetGetMethod());
il.Emit(OpCodes.Callvirt, prop.GetGetMethod(true));
// [original prop val]
il.Emit(OpCodes.Ldarg_1);
// [original prop val, current]
il.Emit(OpCodes.Callvirt, prop.GetGetMethod());
il.Emit(OpCodes.Callvirt, prop.GetGetMethod(true));
// [original prop val, current prop val]
il.Emit(OpCodes.Dup);
......@@ -183,9 +183,9 @@ private static bool AreEqual<U>(U first, U second)
// [clone]
il.Emit(OpCodes.Ldarg_0);
// [clone, source]
il.Emit(OpCodes.Callvirt, prop.GetGetMethod());
il.Emit(OpCodes.Callvirt, prop.GetGetMethod(true));
// [clone, source val]
il.Emit(OpCodes.Callvirt, prop.GetSetMethod());
il.Emit(OpCodes.Callvirt, prop.GetSetMethod(true));
// []
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment