title: Serializing a collection and comply to Code Analysis
body: <p>While running Code Analysis on an existing project I came across the messages <em>Do not expose generic lists</em> and <em>Collection properties should be read only</em>.
  However, this class is used to read/write from/to an xml configuration file.
  Is it possible to make this class comply to <a href="http://msdn.microsoft.com/en-us/library/ms182142.aspx" rel="noreferrer">CA1002</a> and <a href="http://msdn.microsoft.com/en-us/library/ms182327.aspx" rel="noreferrer">CA2227</a> or do I have to suppress these rules for XML-related classes (there are a lot of them in the project)?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Changing <code>List&lt;string&gt;</code> to <code>Collection&lt;string&gt;</code> solved CA1002.
  Still no clue on how to solve CA2227 and still be able to (de)serialize the whole thing.</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Collections.ObjectModel;
  using System.Xml.Serialization;
  
  /// &lt;summary&gt;
  /// Class containing the Configuration Storage
  /// &lt;/summary&gt;
  [XmlRoot("Configuration")]
  public class ConfigurationStorage
  {
      /// &lt;summary&gt;
      /// Gets or sets the list of executers.
      /// &lt;/summary&gt;
      [XmlArray("Executers")]
      [XmlArrayItem("Executer")]
      public Collection&lt;string&gt; Executers { get; set; }
  
      /// &lt;summary&gt;
      /// Gets or sets the list of IPG prefixes.
      /// &lt;/summary&gt;
      [XmlArray("IpgPrefixes")]
      [XmlArrayItem("IpgPrefix")]
      public Collection&lt;string&gt; IpgPrefixes { get; set; }
  
  }
  </code></pre>
  
  <p>Reading the xml-file:</p>
  
  <pre><code>    public static ConfigurationStorage LoadConfiguration()
      {
          if (File.Exists(ConfigFile))
          {
              try
              {
                  using (TextReader r = new StreamReader(ConfigFile))
                  {
                      var s = new XmlSerializer(typeof(ConfigurationStorage));
                      var config = (ConfigurationStorage)s.Deserialize(r);
                      return config;
                  }
              }
              catch (InvalidOperationException invalidOperationException)
              {
                  throw new StorageException(
                      "An error occurred while deserializing the configuration XML file.", invalidOperationException);
              }
          }
      }
  </code></pre>