Why is OnSerializingAttribute disabled for NET20?

Jun 30, 2010 at 8:20 PM

I had a problem where OnSerializingAttribute was not working as described in the documentation examples.  I noticed in DefaultContractResolver.cs that the code below is disabled for the NET20 target.

When I enabled this code and rebuilt Json.NET, everything seems to work fine.  Why was this disabled?


 

#if !PocketPC && !NET20
        if (IsValidCallback(method, parameters, typeof(OnSerializingAttribute), contract.OnSerializing, ref prevAttributeType))
        {
          contract.OnSerializing = method;
        }
        if (IsValidCallback(method, parameters, typeof(OnSerializedAttribute), contract.OnSerialized, ref prevAttributeType))
        {
          contract.OnSerialized = method;
        }
        if (IsValidCallback(method, parameters, typeof(OnDeserializingAttribute), contract.OnDeserializing, ref prevAttributeType))
        {
          contract.OnDeserializing = method;
        }
        if (IsValidCallback(method, parameters, typeof(OnDeserializedAttribute), contract.OnDeserialized, ref prevAttributeType))
        {
          contract.OnDeserialized = method;
        }
#endif

Coordinator
Jun 30, 2010 at 9:41 PM

I though those attributes were only available in .NET 3.0+ - guess not.