I recently encountered a compiler error, where I could not apply the [NonSerialized] attribute on a field that was an event.
The error that I got was: Attribute 'NonSerialized' is not valid on this declaration type. It is only valid on 'field' declarations.
I made the assumption that, the reason for that is that events are not serialized by the serializers and so went ahead and left the field without any serialization modification attribute. Alas, the next day, I got emails from a bunch of people at work that my checkin had broken the app! FIRE DRILL.
Apparently, on fields that are events, one needs to attribute them using [field:NonSerialized] attribute.That fixed the problem and life continued on as usual.
No comments:
Post a Comment