<story><title>A Preview of C# 8 [video]</title><url>https://channel9.msdn.com/Blogs/Seth-Juarez/A-Preview-of-C-8-with-Mads-Torgersen</url></story><parent_chain><item><author>ajennings</author><text>Very excited about the Nullable Reference Types.&lt;p&gt;Besides that, the feature I want most in C# is enum exhaustion checking.  So I can write:&lt;p&gt;&lt;pre&gt;&lt;code&gt;  enum Color { red, green, blue };
  public static string SuperheroFromColor(Color c)
  {
    if (c == Color.red)
    {
      return &amp;quot;Superman&amp;quot;;
    }
    else if (c == Color.green)
    {
      return &amp;quot;Green Lantern&amp;quot;;
    }
    else if (c == Color.blue)
    {
      return &amp;quot;Spiderman&amp;quot;;
    }
  }
&lt;/code&gt;&lt;/pre&gt;
and not get a compiler error (that not all code paths return a value).  But if I added &amp;quot;yellow&amp;quot; as an enum option, then I would get a compiler error.  I realize that Color can be cast from an out-of-range int, so it&amp;#x27;s a little complicated.  I&amp;#x27;m willing to put something extra after the last else:&lt;p&gt;&lt;pre&gt;&lt;code&gt;  unreachable return null;
&lt;/code&gt;&lt;/pre&gt;
or use a special switch statement.  I just want something so the compiler checks that I have accounted for all normal enum values.&lt;p&gt;Is anyone talking about such a feature, or where would I request it?  Can I write it myself as a Roslyn extension?</text></item></parent_chain><comment><author>ajennings</author><text>I wrote myself a compiler extension to check this for me:&lt;p&gt;&lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;abjennings&amp;#x2F;EnumAnalyzer&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;abjennings&amp;#x2F;EnumAnalyzer&lt;/a&gt;</text></comment>
<story><title>A Preview of C# 8 [video]</title><url>https://channel9.msdn.com/Blogs/Seth-Juarez/A-Preview-of-C-8-with-Mads-Torgersen</url></story><parent_chain><item><author>ajennings</author><text>Very excited about the Nullable Reference Types.&lt;p&gt;Besides that, the feature I want most in C# is enum exhaustion checking.  So I can write:&lt;p&gt;&lt;pre&gt;&lt;code&gt;  enum Color { red, green, blue };
  public static string SuperheroFromColor(Color c)
  {
    if (c == Color.red)
    {
      return &amp;quot;Superman&amp;quot;;
    }
    else if (c == Color.green)
    {
      return &amp;quot;Green Lantern&amp;quot;;
    }
    else if (c == Color.blue)
    {
      return &amp;quot;Spiderman&amp;quot;;
    }
  }
&lt;/code&gt;&lt;/pre&gt;
and not get a compiler error (that not all code paths return a value).  But if I added &amp;quot;yellow&amp;quot; as an enum option, then I would get a compiler error.  I realize that Color can be cast from an out-of-range int, so it&amp;#x27;s a little complicated.  I&amp;#x27;m willing to put something extra after the last else:&lt;p&gt;&lt;pre&gt;&lt;code&gt;  unreachable return null;
&lt;/code&gt;&lt;/pre&gt;
or use a special switch statement.  I just want something so the compiler checks that I have accounted for all normal enum values.&lt;p&gt;Is anyone talking about such a feature, or where would I request it?  Can I write it myself as a Roslyn extension?</text></item></parent_chain><comment><author>wvenable</author><text>Use the switch statement without a default clause.  If you haven&amp;#x27;t exhausted the options, you get an error.</text></comment>