Feature Request: Check if classes are tagged as [Serializable]

Hi,

every now and then i need to serialize an object. In most cases, i forget to put a [Serializable]-Attribute above the class i want to serialize.

            try             {                 BinaryFormatter b = new BinaryFormatter();                 FileStream fs = new FileStream(Path.Combine(Directory, "Options.cfg"), FileMode.OpenOrCreate);                 b.Serialize(fs, CsOptions.Instance);                 fs.Close();             }             catch (Exception ex)             {                 Logger.Error("Error - CsOptions::Save(): {0}", ex.Message);                 throw;             }


As you can see, i want to serialize the Instance of my CsOptions-Singleton. I think it would be very nice, if ReSharper could check, if every Property of this instance is tagged as [Serializable]. Inside my Instance, there is a

        public List<CsServiceContainer> Services { get; set; }



--

    [Serializable]     public class CsServiceContainer     {         #region Properties         public string ServiceName { get; set; }         public List<string> Methods { get; set; }         public string Endpoint { get; set; }         public bool HasMethods         {             get { return Methods.Count > 0; }         }         #endregion         #region CTOR         public CsServiceContainer()         {             Methods = new List<string>();         }         #endregion     }



CsServiceContainer must be tagged as [Serializable], otherwise the program will throw an Error/Exception while trying to serialize it. I would like to have a check, before(!) i execute my program.
I would like to hear your opinion about that feature request. If this feature is already implemented and i'm just too studpid to find it, please let me know where to find it.

Greetings,
Sascha

Please sign in to leave a comment.