<?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>ArgumentNullException and refactoring</title><link>http://blogs.msdn.com/kevinpilchbisson/archive/2008/10/27/argumentnullexception-and-refactoring.aspx</link><description>I hate using strings to represent program elements!&amp;#160; One of the big problems is that it hinders automated refactoring.&amp;#160; Strings don’t have any semantic meaning, so refactoring tools don’t know which references to the string need to be updated.</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: ArgumentNullException and refactoring</title><link>http://blogs.msdn.com/kevinpilchbisson/archive/2008/10/27/argumentnullexception-and-refactoring.aspx#9018426</link><pubDate>Mon, 27 Oct 2008 18:50:05 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9018426</guid><dc:creator>int19h</dc:creator><description>&lt;p&gt;We use a similar trick for our INotifyPropertyChanged implementations for mostly the same reasons (refactoring, plus it's so easy to mistype a property name when it's a string, and the compiler doesn't check).&lt;/p&gt;</description></item><item><title>re: ArgumentNullException and refactoring</title><link>http://blogs.msdn.com/kevinpilchbisson/archive/2008/10/27/argumentnullexception-and-refactoring.aspx#9019435</link><pubDate>Tue, 28 Oct 2008 02:35:19 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9019435</guid><dc:creator>Jay Bazuzi</dc:creator><description>&lt;p&gt;If you're willing to take a small performance hit, you can skip the first 'value' argument, and replace 'value == null' with 'arg.Compile()()() == null'. &amp;nbsp;This results in a cleaner usage / DRY:&lt;/p&gt;
&lt;p&gt;Argument.NotNull(() =&amp;gt; () =&amp;gt; args);&lt;/p&gt;
&lt;p&gt;The perf hit is the Compile() call. &amp;nbsp;For me, avoiding the bug where I copy/paste one call to create other calls, and forget to replace one of the parameters is worth the tradeoff most of the time.&lt;/p&gt;
&lt;p&gt;I think I'd keep both as overloads (sharing some implementation). &amp;nbsp;I'd use the 1-parameter version until performance analysis revealed the bottleneck in my code, and there switch to the other.&lt;/p&gt;
&lt;p&gt;Kevin knows all of this, of course: I'm trying to be useful to the other readers.&lt;/p&gt;</description></item><item><title>re: ArgumentNullException and refactoring</title><link>http://blogs.msdn.com/kevinpilchbisson/archive/2008/10/27/argumentnullexception-and-refactoring.aspx#9023927</link><pubDate>Thu, 30 Oct 2008 10:57:52 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9023927</guid><dc:creator>Kirill Osenkov</dc:creator><description>&lt;p&gt;Wouldn't it be nice if the language &amp;quot;understood&amp;quot; more of it's own constructs, like it &amp;quot;understands&amp;quot; types and methods (delegates)?&lt;/p&gt;
&lt;p&gt;A method parameter list should be a tuple, and people should be able to not only access values of the tuple, but also the tuple field information. A lot of things would become easier with this - currying, chaining calls (instead of ugly &amp;quot;out&amp;quot; parameters that don't compose at all, one could just return a tuple).&lt;/p&gt;
&lt;p&gt;Unfortunately, C# wasn't designed with meta-programming in mind, that's why we have to resort to ingenious tricks (I admit it, the trick itself is seriously cool, especially given the constraints) to mimic introspection that comes for free in languages like Lisp, Boo or Nemerle.&lt;/p&gt;</description></item><item><title>re: ArgumentNullException and refactoring</title><link>http://blogs.msdn.com/kevinpilchbisson/archive/2008/10/27/argumentnullexception-and-refactoring.aspx#9056160</link><pubDate>Sun, 09 Nov 2008 22:41:38 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9056160</guid><dc:creator>Markus Hjärne</dc:creator><description>&lt;p&gt;It would be nice (and much easier than the suggested code) if the compiler would support a nameof operator similar to the typeof operator.&lt;/p&gt;
&lt;p&gt;static void Main(string[] args)&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;if (arges == null)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp;throw new ArgumentNullException(nameof(args));&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;The nameof operator should support as many types of identifiers as possible and return the name of the identifier as a string.&lt;/p&gt;</description></item></channel></rss>