title: How to exclude nonserializable observers from a [Serializable] INotifyPropertyChanged implementor?
body: <p>I have almost a hundred of entity classes looking like that:</p>
  
  <pre><code>[Serializable]
  public class SampleEntity : INotifyPropertyChanged
  {
      private string name;
      public string Name
      {
          get { return this.name; }
          set { this.name = value; FirePropertyChanged("Name"); }
      }
  
      [field:NonSerialized]
      public event PropertyChangedEventHandler PropertyChanged;
  
      private void FirePropertyChanged(string propertyName)
      {
          if (this.PropertyChanged != null)
              this.PropertyChanged(this,
                  new PropertyChangedEventArgs(propertyName));
      }
  }
  </code></pre>
  
  <p>Notice the <code>[field:NonSerialized]</code> attribute on <code>PropertyChanged</code>. This is necessary as some of the observers (in my case - a grid displaying the entities for edition) may not be serializable, and the entity has to be serializable, because it is provided - via remoting - by an application running on a separater machine.</p>
  
  <p>This solution works fine for trivial cases. However, it is possible that some of the observers are <code>[Serializable]</code>, and would need to be preserved. How should I handle this?</p>
  
  <p>Solutions I am considering:</p>
  
  <ul>
  <li>full <code>ISerializable</code> - custom serialization requires writing a lot of code, I'd prefer not to do this</li>
  <li>using <code>[OnSerializing]</code> and <code>[OnDeserializing]</code> attributes to serialize <code>PropertyChanged</code> manually - but those helper methods provide only <code>SerializationContext</code>, which AFAIK does not store serialization data (<code>SerializationInfo</code> does that)</li>
  </ul>