This project is read-only.

Patch to support [NonSerialized] attribute

Jan 5, 2013 at 5:55 AM

This patch allows you to control what properties will be serialized.

[Serializable]

public class foo {

 public object bar;

[NonSerialized] public object FooBar;

}

 

Index: Reflection.cs
===================================================================
--- Reflection.cs    (revision 15)
+++ Reflection.cs    (working copy)
@@ -272,6 +272,12 @@
                 if (att != null && att.Length > 0)
                     continue;
 
+                var o = p.GetCustomAttributes(typeof(System.NonSerializedAttribute), false);
+                if (o != null && o.Length > 0)
+                {
+                    continue;
+                }
+
                 GenericGetter g = CreateGetMethod(type, p);
                 if (g != null)
                 {
@@ -290,6 +296,12 @@
                 if (att != null && att.Length > 0)
                     continue;
 
+                var o = f.GetCustomAttributes(typeof (System.NonSerializedAttribute), false);
+                if(o != null && o.Length > 0)
+                {
+                    continue;
+                }
+
                 GenericGetter g = CreateGetField(type, f);
                 if (g != null)
                 {