<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://msmvps.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>Resharper Isn't Always Smart</title><link>http://msmvps.com/blogs/peterritchie/archive/2008/03/31/resharper-isn-t-always-smart.aspx</link><description>I was writing some code today, essentially like this: public class MyClass { private int value; public MyClass( int value) { this .value = value; } public static bool operator ==( MyClass left, MyClass right) { return left.value == right.value; } public</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP2 (Build: 40407.4157)</generator><item><title>re: Resharper Isn't Always Smart</title><link>http://msmvps.com/blogs/peterritchie/archive/2008/03/31/resharper-isn-t-always-smart.aspx#1565957</link><pubDate>Tue, 01 Apr 2008 19:30:02 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1565957</guid><dc:creator>PeterRitchie</dc:creator><description>&lt;p&gt;@Wayne: I ran VS 2008 Code Analysis.&lt;/p&gt;
&lt;p&gt;But, there are some valid reasons for implementing the equality operator; it's not without consequences/work; but valid.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1565957" width="1" height="1"&gt;</description></item><item><title>re: Resharper Isn't Always Smart</title><link>http://msmvps.com/blogs/peterritchie/archive/2008/03/31/resharper-isn-t-always-smart.aspx#1565890</link><pubDate>Tue, 01 Apr 2008 18:37:05 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1565890</guid><dc:creator>Wayne Bradney</dc:creator><description>&lt;p&gt;Really? I get CA1046 right away when compiling your sample:&lt;/p&gt;
&lt;p&gt;Warning	5	CA1046 : Microsoft.Design : &amp;#39;MyClass&amp;#39; should not overload the equality operator.	C:\Users\wayne_bradney\Documents\Visual Studio 2008\Projects\ConsoleApplication7\ConsoleApplication7\Program.cs	7	ConsoleApplication7&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1565890" width="1" height="1"&gt;</description></item><item><title>re: Resharper Isn't Always Smart</title><link>http://msmvps.com/blogs/peterritchie/archive/2008/03/31/resharper-isn-t-always-smart.aspx#1565523</link><pubDate>Tue, 01 Apr 2008 14:12:41 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1565523</guid><dc:creator>PeterRitchie</dc:creator><description>&lt;p&gt;@David: &amp;nbsp;Depends on point of view, I guess. &amp;nbsp;To me and all the developers I work with (Object)x==(Object)y is obvious to me.&lt;/p&gt;
&lt;p&gt;It is apparent that ReferenceEquals is more R#-friendly.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1565523" width="1" height="1"&gt;</description></item><item><title>re: Resharper Isn't Always Smart</title><link>http://msmvps.com/blogs/peterritchie/archive/2008/03/31/resharper-isn-t-always-smart.aspx#1565513</link><pubDate>Tue, 01 Apr 2008 13:59:16 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1565513</guid><dc:creator>David Nelson</dc:creator><description>&lt;p&gt;I am well aware of how ReferenceEquals operates. I was not saying that it does something different; I was merely pointing out that it is more explicit about your intent and tends to be less confusing.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1565513" width="1" height="1"&gt;</description></item><item><title>re: Resharper Isn't Always Smart</title><link>http://msmvps.com/blogs/peterritchie/archive/2008/03/31/resharper-isn-t-always-smart.aspx#1565274</link><pubDate>Tue, 01 Apr 2008 11:29:17 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1565274</guid><dc:creator>PeterRitchie</dc:creator><description>&lt;p&gt;@Derik: Yes, 4 EAP. &amp;nbsp;It could know. &amp;nbsp;And if they don't want to check, then don't suggest the &amp;quot;quick-fix&amp;quot;.&lt;/p&gt;
&lt;p&gt;It's the same with Code Analysis, don't change the code simply to get rid of a warning, unless you know what you're doing...&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1565274" width="1" height="1"&gt;</description></item><item><title>re: Resharper Isn't Always Smart</title><link>http://msmvps.com/blogs/peterritchie/archive/2008/03/31/resharper-isn-t-always-smart.aspx#1565271</link><pubDate>Tue, 01 Apr 2008 11:26:43 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1565271</guid><dc:creator>PeterRitchie</dc:creator><description>&lt;p&gt;@Wayne: no complaints from Code Analysis about overloading operator==.&lt;/p&gt;
&lt;p&gt;@David &amp;amp; Wayne: &amp;nbsp;All ReferenceEquals does is cast (implicitly) and perform operator==.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1565271" width="1" height="1"&gt;</description></item><item><title>re: Resharper Isn't Always Smart</title><link>http://msmvps.com/blogs/peterritchie/archive/2008/03/31/resharper-isn-t-always-smart.aspx#1564591</link><pubDate>Tue, 01 Apr 2008 01:07:07 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1564591</guid><dc:creator>Derik Whittaker</dc:creator><description>&lt;p&gt;@Peter,&lt;/p&gt;
&lt;p&gt;Is this with 4 EAP?&lt;/p&gt;
&lt;p&gt;Well, to be fair. &amp;nbsp;#R does not know that you changed the default meaning of the != operator.&lt;/p&gt;
&lt;p&gt;But your message is true, and it is not just when using #R. &amp;nbsp;Anytime ANYTHING changes your code you need to know the intent of the change before you allow it.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1564591" width="1" height="1"&gt;</description></item><item><title>re: Resharper Isn't Always Smart</title><link>http://msmvps.com/blogs/peterritchie/archive/2008/03/31/resharper-isn-t-always-smart.aspx#1564560</link><pubDate>Tue, 01 Apr 2008 00:40:37 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1564560</guid><dc:creator>Wayne Bradney</dc:creator><description>&lt;p&gt;Isn&amp;#39;t this just the kind of thing that Object.ReferenceEquals() was invented for?&lt;/p&gt;
&lt;p&gt;(Also, Code Analysis does suggest that overriding == is a bad idea for most reference types)&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1564560" width="1" height="1"&gt;</description></item><item><title>re: Resharper Isn't Always Smart</title><link>http://msmvps.com/blogs/peterritchie/archive/2008/03/31/resharper-isn-t-always-smart.aspx#1564398</link><pubDate>Mon, 31 Mar 2008 21:43:15 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1564398</guid><dc:creator>David Nelson</dc:creator><description>&lt;p&gt;This is exactly why I never use a cast to Object to perform a reference comparison: it is confusing to the reader, whether the reader is a human or a refactoring program. Instead I use ReferenceEquals; it immediately and clearly signifies what kind of comparison I am trying to accomplish.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1564398" width="1" height="1"&gt;</description></item><item><title>re: Resharper Isn't Always Smart</title><link>http://msmvps.com/blogs/peterritchie/archive/2008/03/31/resharper-isn-t-always-smart.aspx#1564326</link><pubDate>Mon, 31 Mar 2008 21:17:48 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1564326</guid><dc:creator>Steve</dc:creator><description>&lt;p&gt;Yup, had the same problem a few times, this one still compiles but some &amp;quot;fixes&amp;quot; even generate compile errors, but I always report problems like this.&lt;/p&gt;
&lt;p&gt;Anyways, ReferenceEquals is always usefull for this ;)&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1564326" width="1" height="1"&gt;</description></item><item><title>A case where Resharper will break your code with a </title><link>http://msmvps.com/blogs/peterritchie/archive/2008/03/31/resharper-isn-t-always-smart.aspx#1564134</link><pubDate>Mon, 31 Mar 2008 18:45:02 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1564134</guid><dc:creator>DotNetKicks.com</dc:creator><description>&lt;p&gt;You&amp;#39;ve been kicked (a good thing) - Trackback from DotNetKicks.com&lt;/p&gt;
&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1564134" width="1" height="1"&gt;</description></item></channel></rss>