<?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>Peter Ritchie's MVP Blog : Resharper</title><link>http://msmvps.com/blogs/peterritchie/archive/tags/Resharper/default.aspx</link><description>Tags: Resharper</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP2 (Build: 40407.4157)</generator><item><title>Working with Resharper's External Annotation XML Files</title><link>http://msmvps.com/blogs/peterritchie/archive/2008/07/21/working-with-resharper-s-external-annotation-xml-files.aspx</link><pubDate>Mon, 21 Jul 2008 20:32:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1640964</guid><dc:creator>PeterRitchie</dc:creator><slash:comments>5</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/peterritchie/rsscomments.aspx?PostID=1640964</wfw:commentRss><comments>http://msmvps.com/blogs/peterritchie/archive/2008/07/21/working-with-resharper-s-external-annotation-xml-files.aspx#comments</comments><description>&lt;p&gt;Resharper 4.0 has external annotation XML files that you can create to give Resharper more information about your code.&amp;nbsp; For example, you can tell Resharper that a particular method does not accept a null argument.&amp;nbsp; For example, the following method does not accept a null argument:&lt;/p&gt;
&lt;div style="font-size:10pt;background:white;color:black;font-family:Courier New;border:black 1px solid;"&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&lt;span style="color:blue;"&gt;using&lt;/span&gt; System;&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&lt;span style="color:blue;"&gt;namespace&lt;/span&gt; Utility&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;{&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;static&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Text&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;static&lt;/span&gt; &lt;span style="color:blue;"&gt;int&lt;/span&gt; GetLength(&lt;span style="color:#2b91af;"&gt;String&lt;/span&gt; text)&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;if&lt;/span&gt; (text == &lt;span style="color:blue;"&gt;null&lt;/span&gt;) &lt;span style="color:blue;"&gt;throw&lt;/span&gt; &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;ArgumentNullException&lt;/span&gt;(&lt;span style="color:#a31515;"&gt;&amp;quot;text&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:blue;"&gt;return&lt;/span&gt; text.Length;&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;An external annotation file can be created to inform Resharper of this fact and have it warn you when possible null values are passed as an argument:&lt;/p&gt;
&lt;div style="font-size:10pt;background:white;color:black;font-family:Courier New;border:black 1px solid;"&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#2b91af;"&gt;String&lt;/span&gt; text = &lt;span style="color:blue;"&gt;null&lt;/span&gt;;&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Utility.Text.GetLength(text);&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;First, you need to create a directory within the Resharper ExternalAnnotations directory.&amp;nbsp; This ExternalAnnotations directory is usually in the form of &amp;quot;%SystemDrive%\Program Files\JetBrains\ReSharper\vBuild#\Bin\ExternalAnnotations&amp;quot; for example &amp;quot;C:\Program Files\JetBrains\ReSharper\v4.0.816.4\Bin\ExternalAnnotations&amp;quot;.&lt;/p&gt;
&lt;p&gt;The directory we need to create is the same name as our assembly (without the extension).&amp;nbsp; In our case this would be &amp;quot;C:\Program Files\JetBrains\ReSharper\v4.0.816.4\Bin\ExternalAnnotations\Utility&amp;quot;.&lt;/p&gt;
&lt;p&gt;Next, we need to create an XML file to contain the information required by Resharper.&amp;nbsp; The name of this file is the same as the directory name, plus &amp;quot;.xml&amp;quot;.&amp;nbsp; So, the full file name would be &amp;quot;C:\Program Files\JetBrains\ReSharper\v4.0.816.4\Bin\ExternalAnnotations\Utility\Utility.xml&amp;quot;.&amp;nbsp; This file essentially has an assembly element with child member elements that provide meta-data about methods and arguments.&amp;nbsp; In our case we want to tell Resharper that the Utility.Text.GetLength(String) method does not accept null values for the argument named &amp;quot;text&amp;quot;.&amp;nbsp; To do this we populate the file with the following XML:&lt;/p&gt;
&lt;div style="font-size:10pt;background:white;color:black;font-family:Courier New;border:black 1px solid;"&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color:#a31515;"&gt;xml&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;version&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;1.0&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;encoding&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;utf-8&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; ?&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;assembly&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;name&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;Utility&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;member&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;name&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;M:Utility.Text.GetLength(System.String)&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;parameter&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;name&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;text&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;attribute&lt;/span&gt;&lt;span style="color:blue;"&gt; &lt;/span&gt;&lt;span style="color:red;"&gt;ctor&lt;/span&gt;&lt;span style="color:blue;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt;M:JetBrains.Annotations.NotNullAttribute.#ctor&lt;/span&gt;&amp;quot;&lt;span style="color:blue;"&gt; /&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;parameter&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;member&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&lt;span style="color:blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;assembly&lt;/span&gt;&lt;span style="color:blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;After restarting Visual Studio, Resharper will now warn that &amp;quot;text&amp;quot;, when passed to GetLength, in the following code, has a &amp;quot;Possible &amp;#39;null&amp;#39; assignment to entity marked with &amp;quot;NotNull&amp;quot; attribute&amp;quot;.&lt;/p&gt;
&lt;div style="font-size:10pt;background:white;color:black;font-family:Courier New;border:black 1px solid;"&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color:#2b91af;"&gt;String&lt;/span&gt; text = &lt;span style="color:blue;"&gt;null&lt;/span&gt;;&lt;/pre&gt;
&lt;pre style="background:cornsilk;margin:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Utility.Text.GetLength(text);&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;I&amp;#39;ve tried this with the GA build and with both Visual Studio 2005 (SP1) and Visual Studio 2008.&lt;/p&gt;
&lt;p&gt;For more information about the annotation options, search for AssertionConditionType in the Resharper help and browse around &amp;quot;%SystemDrive%\Program Files\JetBrains\ReSharper\vBuild#\Bin\ExternalAnnotations&amp;quot; for examples.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1640964" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/.NET+Development/default.aspx">.NET Development</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Software+Development/default.aspx">Software Development</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Visual+Studio+2008/default.aspx">Visual Studio 2008</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Resharper/default.aspx">Resharper</category></item><item><title>Comparing CodeRush Refactor! Pro and Resharper 4, part 1 or N -- first glance.</title><link>http://msmvps.com/blogs/peterritchie/archive/2008/06/25/comparing-coderush-refactor-pro-and-resharper-4-part-1-or-n-first-glance.aspx</link><pubDate>Thu, 26 Jun 2008 01:17:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1637792</guid><dc:creator>PeterRitchie</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/peterritchie/rsscomments.aspx?PostID=1637792</wfw:commentRss><comments>http://msmvps.com/blogs/peterritchie/archive/2008/06/25/comparing-coderush-refactor-pro-and-resharper-4-part-1-or-n-first-glance.aspx#comments</comments><description>&lt;p&gt;&lt;strong&gt;Metadata view of code in referenced assemblies&lt;br /&gt;&lt;/strong&gt;This is a big one for me.&amp;nbsp; For whatever reason, Refactor 4 (and prior) completely disables this and sends you to the Object Browser instead.&amp;nbsp;&amp;nbsp; You get metadata view with CodeRush Refactor! Pro.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Keyboard layout&lt;br /&gt;&lt;/strong&gt;As you might imagine, CodeRush Refactor! Pro and Resharper had completely different keyboard layouts.&amp;nbsp; So, if you&amp;#39;re used to R# then Refactor! Pro will take a bit of getting used to.&lt;/p&gt;
&lt;p&gt;One thing I don&amp;#39;t like with the default Refactor! Pro keyboard layout, is they&amp;#39;ve replaced Ctrl-. with Quick Navigation.&amp;nbsp; I use Ctrl-. (instead of Shift-Alt-F10 to get at the smart-tag menu).&amp;nbsp; Shift-Alt-F10 for smart-tag menu seems more common; so I&amp;#39;ll have to get use to Shift-Alt-F10.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Refactor! Pro&amp;#39;s Editor enhancements&lt;br /&gt;&lt;/strong&gt;R# doesn&amp;#39;t change to how the editor looks as much as CodeRush Refactor! Pro.&amp;nbsp; It has the Marker Bar, error/warning/info colouring, and action light-bulbs.&amp;nbsp; Refactor! Pro with CodeRush has many more, like region painting, flow-break evaluation, Visibility Icons, structural highlighting,&amp;nbsp;etc. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Real-time analysis&lt;br /&gt;&lt;/strong&gt;Both R# and CodeRush Refactor! Pro do real-time code analysis.&amp;nbsp; R# has text colouring and the right-hand marker bar.&amp;nbsp; CodeRush Refactor Pro has a marker bar on both the left and the right.&amp;nbsp; The left marker bar in CodeRush Refactor! Pro highlights issues for each line, and the right (as does R#) shows a file-wide view of issues.&amp;nbsp; I find the R# marker bar sometimes doesn&amp;#39;t align with the scroll bar so that an issue may be beside the scroll-bar in the marker bar but is actually scrolled off the screen.&amp;nbsp; CodeRush Refactor Pro doesn&amp;#39;t do that and in fact shows the visible portion of the document in its marker bar.&amp;nbsp; i.e. the marker bar is beside the Visual Studio Indicator Margin (where the breakpoint bullets appear).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Refactorings&lt;br /&gt;&lt;/strong&gt;They both have many of the same refactorings.&amp;nbsp; When it comes to non-refactorings the two sometimes approach things differently.&amp;nbsp; For example R# deals with adding members to a class through &amp;quot;Generate Code&amp;quot; list; whereas CodeRush Refactor Pro uses templates.&amp;nbsp; E.g. in R#, to add a constructor you hit Alt-Ins and select Constructor.&amp;nbsp; With Refactor you simply enter &amp;quot;cc &amp;quot;(that &amp;#39;c&amp;#39;, &amp;#39;c&amp;#39;, space).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Smart-Tags&lt;/strong&gt;&lt;br /&gt;Both approach smart-tags slightly differently.&amp;nbsp; With R# they use the actions light-bulb at the left margin.&amp;nbsp; This includes fixes for warnings, errors, plus refactorings, but doesn&amp;#39;t include code generation options.&amp;nbsp; CodeRush Refactor Pro uses an ellipsis-like icon that appears right at the site of the potential refactoring. Code Refactor Pro is a richer experience.&amp;nbsp; It will show you the result of a refactoring with arrows showing where things will move, red strike-out showing what will be removed, and highlights for things that will be changed/renamed. &lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1637792" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/.NET+Development/default.aspx">.NET Development</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Software+Development/default.aspx">Software Development</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Resharper/default.aspx">Resharper</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/CodeRush+Refactor_2100_+Pro/default.aspx">CodeRush Refactor! Pro</category></item><item><title>Resharper 4.0 EAP Settings and Installing Latest Build</title><link>http://msmvps.com/blogs/peterritchie/archive/2008/05/19/resharper-4-0-eap-settings-and-installing-latest-build.aspx</link><pubDate>Tue, 20 May 2008 02:10:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1624746</guid><dc:creator>PeterRitchie</dc:creator><slash:comments>3</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/peterritchie/rsscomments.aspx?PostID=1624746</wfw:commentRss><comments>http://msmvps.com/blogs/peterritchie/archive/2008/05/19/resharper-4-0-eap-settings-and-installing-latest-build.aspx#comments</comments><description>&lt;p&gt;The 4.0 EAP tends to do a full uninstall before installing (it&amp;#39;s pre-beta, pre-alpha even; so it&amp;#39;s no wonder).&lt;/p&gt;
&lt;p&gt;This tends to blow away your settings changes.&amp;nbsp; If that&amp;#39;s a pain point for you, the settings are stored in &amp;quot;%userprofile%\application data\jetbrains\resharper\v4.0\vs9.0&amp;quot;.&amp;nbsp; There are a couple of xml files in there that store your settings.&amp;nbsp; Before you upgrade to the latest build, just copy those to another directory.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;It&amp;#39;s very likely that the format of these files has changed since the last build so copying the backups over the new version could possibly make Resharper to blow-up.&amp;nbsp; So, use with caution.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1624746" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/C_2300_+3.0/default.aspx">C# 3.0</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Resharper/default.aspx">Resharper</category></item><item><title>Resharper Isn't Always Smart</title><link>http://msmvps.com/blogs/peterritchie/archive/2008/03/31/resharper-isn-t-always-smart.aspx</link><pubDate>Mon, 31 Mar 2008 17:47:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1564070</guid><dc:creator>PeterRitchie</dc:creator><slash:comments>11</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/peterritchie/rsscomments.aspx?PostID=1564070</wfw:commentRss><comments>http://msmvps.com/blogs/peterritchie/archive/2008/03/31/resharper-isn-t-always-smart.aspx#comments</comments><description>&lt;p&gt;I was writing some code today, essentially like this:&lt;/p&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Courier New;"&gt;
&lt;p style="MARGIN:0px;"&gt;&lt;span style="COLOR:blue;"&gt;public&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;class&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;MyClass&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;{&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;private&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;int&lt;/span&gt; value;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;public&lt;/span&gt; MyClass(&lt;span style="COLOR:blue;"&gt;int&lt;/span&gt; value)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;this&lt;/span&gt;.value = value;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;public&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;static&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;bool&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;operator&lt;/span&gt;==(&lt;span style="COLOR:#2b91af;"&gt;MyClass&lt;/span&gt; left, &lt;span style="COLOR:#2b91af;"&gt;MyClass&lt;/span&gt; right)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;return&lt;/span&gt; left.value == right.value;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;public&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;static&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;bool&lt;/span&gt; &lt;span style="COLOR:blue;"&gt;operator&lt;/span&gt; !=(&lt;span style="COLOR:#2b91af;"&gt;MyClass&lt;/span&gt; left, &lt;span style="COLOR:#2b91af;"&gt;MyClass&lt;/span&gt; right)&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;return&lt;/span&gt; !(left == right);&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;}&lt;/p&gt;&lt;/div&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Courier New;"&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:green;"&gt;//...&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:#2b91af;"&gt;MyClass&lt;/span&gt; myClass1 = &lt;span style="COLOR:blue;"&gt;new&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;MyClass&lt;/span&gt;(1);&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:#2b91af;"&gt;MyClass&lt;/span&gt; myClass2 = &lt;span style="COLOR:blue;"&gt;new&lt;/span&gt; &lt;span style="COLOR:#2b91af;"&gt;MyClass&lt;/span&gt;(1);&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;if&lt;/span&gt;((&lt;span style="COLOR:#2b91af;"&gt;Object&lt;/span&gt;)myClass1 != (&lt;span style="COLOR:#2b91af;"&gt;Object&lt;/span&gt;)myClass2) &lt;span style="COLOR:green;"&gt;// &amp;quot;Type cast is reundant&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:#2b91af;"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="COLOR:#a31515;"&gt;&amp;quot;not equal&amp;quot;&lt;/span&gt;);&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;else&lt;/span&gt;&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:#2b91af;"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="COLOR:#a31515;"&gt;&amp;quot;equal&amp;quot;&lt;/span&gt;);&lt;/p&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;...where&amp;nbsp;Resharper warned that both the casts to Object were redundant and offered a &amp;quot;Quick-fix&amp;quot; (red light bulb) to &amp;quot;Remove cast&amp;quot;.&amp;nbsp; Well, doing that to one of the casts results in a compile error so you have to manually change the other; but what it&amp;#39;s suggesting is this:&lt;/p&gt;
&lt;div style="FONT-SIZE:10pt;BACKGROUND:white;COLOR:black;FONT-FAMILY:Courier New;"&gt;
&lt;p style="MARGIN:0px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR:blue;"&gt;if&lt;/span&gt;(myClass1 != myClass2)&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;This completely changes the output of my application from &amp;quot;not equal&amp;quot; to&amp;nbsp;&amp;quot;equal&amp;quot;.&amp;nbsp; What&amp;nbsp;Resharper&amp;nbsp;doesn&amp;#39;t know (or doesn&amp;#39;t care to check)&amp;nbsp;is that removing those casts switches from a reference comparison to a value comparison&amp;nbsp;and may&amp;nbsp;have different results.&amp;nbsp; What I wrote with the original code was to test if the two references&amp;nbsp;referenced the same object.&amp;nbsp; The default behaviour of a class is to do a reference check; but I&amp;#39;ve overloaded&amp;nbsp;operator== (and operator&amp;nbsp;!=) to perform a value comparison (I&amp;#39;ve left out the lovely&amp;nbsp;bits that truly&amp;nbsp;gives MyClass value semantics for clarity).&lt;/p&gt;
&lt;p&gt;So, when Resharper offers to change your code, be sure you know side-effects of that change before you let it do it.&amp;nbsp; You could introduce a nasty bug.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fmsmvps.com%2fblogs%2fpeterritchie%2farchive%2f2008%2f03%2f31%2fresharper-isn-t-always-smart.aspx"&gt;&lt;img alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fmsmvps.com%2fblogs%2fpeterritchie%2farchive%2f2008%2f03%2f31%2fresharper-isn-t-always-smart.aspx" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1564070" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Resharper/default.aspx">Resharper</category><category domain="http://msmvps.com/blogs/peterritchie/archive/tags/Product+Bugs/default.aspx">Product Bugs</category></item></channel></rss>