title: How should you type an enumerable property in .NET Core configuration when using options?
body: <p>I'm trying to work out the best way of using enumerable properties in an options object that's populated through appsettings.json configuration.</p>
  <p>I have an example object below that I'll be configuring from an appsettings.json file that looks like this:</p>
  <pre class="lang-cs prettyprint-override"><code>public class MyOptions
  {
      public ICollection&lt;string&gt; ListOne { get; set; } = Array.Empty&lt;string&gt;();
  
      public string[] ListTwo { get; set; } = Array.Empty&lt;string&gt;();
  
      public ICollection&lt;string&gt; ListThree { get; } = Array.Empty&lt;string&gt;();
  }
  </code></pre>
  <pre><code>{
      &quot;MyOptions&quot;: {
          &quot;ListOne&quot;: [ &quot;one&quot;, &quot;two&quot;, &quot;three&quot; ],
          &quot;ListTwo&quot;: [ &quot;one&quot;, &quot;two&quot;, &quot;three&quot; ],
          &quot;ListThree&quot;: [ &quot;one&quot;, &quot;two&quot;, &quot;three&quot; ]
      }
  }
  </code></pre>
  <p>The problem here is that when using FxCop analysers a warning is raised against ListOne: <code>CA2227: Collection properties should be read only</code>.
  And a different one against ListTwo: <code>CA1819: Properties should not return arrays</code>.
  And if you the setter from ListOne like done in ListThree to fix the warning then the configuration isn't read in at all because it needs a setter.</p>
  <p>So my question is really, well if you can't any of that, how do you populate an enumerable property without any warnings?</p>