Browse Source

Fix for private property serialization

Brad Robinson 10 years ago
parent
commit
3b33db8a7a
1 changed files with 10 additions and 10 deletions
  1. 10 10
      PetaJson.cs

+ 10 - 10
PetaJson.cs

@@ -1840,7 +1840,7 @@ namespace PetaJson
                 var pi = mi as PropertyInfo;
                 if (pi != null)
                 {
-                    var gm = pi.GetGetMethod();
+                    var gm = pi.GetGetMethod(true);
                     return (gm != null && gm.IsPublic);
                 }
 
@@ -2509,7 +2509,7 @@ namespace PetaJson
                     {
                         // Ignore write only properties
                         var pi = m.Member as PropertyInfo;
-                        if (pi != null && pi.GetGetMethod() == null)
+                        if (pi != null && pi.GetGetMethod(true) == null)
                         {
                             continue;
                         }
@@ -2547,9 +2547,9 @@ namespace PetaJson
                         {
                             // Call property's get method
                             if (type.IsValueType)
-                                il.Emit(OpCodes.Call, pi.GetGetMethod());
+                                il.Emit(OpCodes.Call, pi.GetGetMethod(true));
                             else
-                                il.Emit(OpCodes.Callvirt, pi.GetGetMethod());
+                                il.Emit(OpCodes.Callvirt, pi.GetGetMethod(true));
 
                             // If we need the address then store in a local and take it's address
                             if (NeedValueAddress)
@@ -2784,7 +2784,7 @@ namespace PetaJson
                         // Ignore write only properties
                         var pi = m.Member as PropertyInfo;
                         var fi = m.Member as FieldInfo;
-                        if (pi != null && pi.GetSetMethod() == null)
+                        if (pi != null && pi.GetSetMethod(true) == null)
                         {
                             continue;
                         }
@@ -2803,7 +2803,7 @@ namespace PetaJson
 
                         // Assign it
                         if (pi != null)
-                            il.Emit(OpCodes.Call, pi.GetSetMethod());
+                            il.Emit(OpCodes.Call, pi.GetSetMethod(true));
                         if (fi != null)
                             il.Emit(OpCodes.Stfld, fi);
 
@@ -2931,13 +2931,13 @@ namespace PetaJson
                     // Ignore write only properties
                     var pi = m.Member as PropertyInfo;
                     var fi = m.Member as FieldInfo;
-                    if (pi != null && pi.GetSetMethod() == null)
+                    if (pi != null && pi.GetSetMethod(true) == null)
                     {
                         continue;
                     }
 
                     // Ignore read only properties that has KeepInstance attribute
-                    if (pi != null && pi.GetGetMethod() == null && m.KeepInstance)
+                    if (pi != null && pi.GetGetMethod(true) == null && m.KeepInstance)
                     {
                         continue;
                     }
@@ -2956,7 +2956,7 @@ namespace PetaJson
                         // Get existing existing instance
                         il.Emit(OpCodes.Dup);
                         if (pi != null)
-                            il.Emit(OpCodes.Callvirt, pi.GetGetMethod());
+                            il.Emit(OpCodes.Callvirt, pi.GetGetMethod(true));
                         else
                             il.Emit(OpCodes.Ldfld, fi);
 
@@ -2987,7 +2987,7 @@ namespace PetaJson
 
                     // Assign it
                     if (pi != null)
-                        il.Emit(OpCodes.Callvirt, pi.GetSetMethod());
+                        il.Emit(OpCodes.Callvirt, pi.GetSetMethod(true));
                     if (fi != null)
                         il.Emit(OpCodes.Stfld, fi);