<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>The danger of over simplification: Enum.IsDefined() </title><link>http://blogs.msdn.com/brada/archive/2003/11/29/50903.aspx</link><description>I just stumbled across this guideline in the Design Guidelines document and I thought it needed more explanation.. Do argument validation . Do not assume enum arguments will be in the defined range. It is legal to cast any integer value into an enum even</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>RE: The danger of over simplification: Enum.IsDefined() </title><link>http://blogs.msdn.com/brada/archive/2003/11/29/50903.aspx#50904</link><pubDate>Sun, 30 Nov 2003 07:30:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:50904</guid><dc:creator>Frank Hileman</dc:creator><description>I wasn't too happy to discover, by using a profiler, that Enum.IsDefined is taking a significant fraction of CPU in our app that uses System.Drawing. There are some checks in there, and there is nothing we can do to get rid of them.</description></item><item><title>RE: The danger of over simplification: Enum.IsDefined() </title><link>http://blogs.msdn.com/brada/archive/2003/11/29/50903.aspx#50905</link><pubDate>Mon, 01 Dec 2003 18:58:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:50905</guid><dc:creator>Ian Griffiths</dc:creator><description>Even worse, Enum.IsDefined ignores the [Flags] attribute.  Given the following:

[Flags]
enum Foo
{
  X = 1,
  Y = 2
}

the value Foo.X | Foo.Y is allowed.  But Enum.IsDefined indicates that it's not a valid value!</description></item><item><title>RE: The danger of over simplification: Enum.IsDefined() </title><link>http://blogs.msdn.com/brada/archive/2003/11/29/50903.aspx#50906</link><pubDate>Mon, 01 Dec 2003 19:36:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:50906</guid><dc:creator>sharpie</dc:creator><description>Therefore would it be safe to say one should simply not be using Enum.IsDefined for anything at all? If there is no good reason for it, why does it exist? WIll it be deprecated in a future release?</description></item><item><title>RE: The danger of over simplification: Enum.IsDefined() </title><link>http://blogs.msdn.com/brada/archive/2003/11/29/50903.aspx#50907</link><pubDate>Sat, 06 Dec 2003 04:25:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:50907</guid><dc:creator>vitabath</dc:creator><description /></item><item><title>RE: The danger of over simplification: Enum.IsDefined() </title><link>http://blogs.msdn.com/brada/archive/2003/11/29/50903.aspx#50908</link><pubDate>Wed, 17 Dec 2003 02:58:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:50908</guid><dc:creator>James</dc:creator><description>Why not make Enum.IsDefined inlined at compiletime like a #define -- that's essentially what you're asking us to do in our verification code.  If there's a standard thing that we should be doing, there should be a compiler/tool way to make it automated.

I guess there's some value to making people look at it, but I think it's less of a benefit than making IsDefined (or some IsDefinedAtLastCompile equivalent) easier to do (and therefore more likely to be done).  

IMHO, there would probably be more errors by people's manual maintenance of this validation code than by not having to handedit the values and missing the assumptions broken by the introduction of new values.</description></item><item><title>DateTime Compatability Issue</title><link>http://blogs.msdn.com/brada/archive/2003/11/29/50903.aspx#74915</link><pubDate>Tue, 17 Feb 2004 19:49:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:74915</guid><dc:creator>Brad Abrams </dc:creator><description /></item><item><title>DateTime Compatibility Issue</title><link>http://blogs.msdn.com/brada/archive/2003/11/29/50903.aspx#74916</link><pubDate>Tue, 17 Feb 2004 19:53:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:74916</guid><dc:creator>Brad Abrams </dc:creator><description /></item><item><title>Enum.IsDefined</title><link>http://blogs.msdn.com/brada/archive/2003/11/29/50903.aspx#75752</link><pubDate>Wed, 18 Feb 2004 23:24:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:75752</guid><dc:creator>Mathew Nolton Blog</dc:creator><description /></item><item><title>How useful are enums?</title><link>http://blogs.msdn.com/brada/archive/2003/11/29/50903.aspx#75782</link><pubDate>Wed, 18 Feb 2004 23:57:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:75782</guid><dc:creator>Mathew Nolton Blog</dc:creator><description /></item><item><title>A compilation of new .NET Design Guidelines</title><link>http://blogs.msdn.com/brada/archive/2003/11/29/50903.aspx#77089</link><pubDate>Fri, 20 Feb 2004 18:46:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:77089</guid><dc:creator>Ken Brubaker</dc:creator><description>For my own reference, I thought I'd compile a quick list of design guidelines added by Brad Abrams, et al.</description></item><item><title>re: Enum Switches</title><link>http://blogs.msdn.com/brada/archive/2003/11/29/50903.aspx#116090</link><pubDate>Mon, 19 Apr 2004 20:50:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:116090</guid><dc:creator>Omer van Kloeten's .NET Zen</dc:creator><description /></item><item><title>re: Enum Switches</title><link>http://blogs.msdn.com/brada/archive/2003/11/29/50903.aspx#116197</link><pubDate>Mon, 19 Apr 2004 23:29:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:116197</guid><dc:creator>Omer van Kloeten's .NET Zen</dc:creator><description /></item><item><title>Working with Enums</title><link>http://blogs.msdn.com/brada/archive/2003/11/29/50903.aspx#421710</link><pubDate>Wed, 25 May 2005 16:35:06 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:421710</guid><dc:creator>Darrell Norton's Blog [MVP]</dc:creator><description>Geoff wrote a whole bunch of code for dealing with Enums. Enums are annoying because you can cast any...</description></item><item><title>re: C# Tips: Enumなプロパティのsetterの冒頭は</title><link>http://blogs.msdn.com/brada/archive/2003/11/29/50903.aspx#550999</link><pubDate>Tue, 14 Mar 2006 09:35:03 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:550999</guid><dc:creator>菊池 Blog</dc:creator><description>re: C# Tips: Enumなプロパティのsetterの冒頭は</description></item><item><title>C# Enum.Parse() Bug &amp;laquo; The Pursuit of a Life</title><link>http://blogs.msdn.com/brada/archive/2003/11/29/50903.aspx#6732219</link><pubDate>Tue, 11 Dec 2007 10:21:41 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:6732219</guid><dc:creator>C# Enum.Parse() Bug « The Pursuit of a Life</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://xidey.wordpress.com/2007/12/10/c-enumparse-bug/"&gt;http://xidey.wordpress.com/2007/12/10/c-enumparse-bug/&lt;/a&gt;&lt;/p&gt;
</description></item></channel></rss>