tag:blogger.com,1999:blog-44393867066178713222024-03-13T11:39:00.273+03:00ReSharper HorizonsReSharper Product Manager's Random ThoughtsIlya Ryzhenkovhttp://www.blogger.com/profile/14966746474791511643noreply@blogger.comBlogger70125tag:blogger.com,1999:blog-4439386706617871322.post-83463579585492081862009-10-29T11:10:00.006+03:002009-11-05T19:50:54.343+03:00ReSharper 5 -- Less Shifting Means More Speed<a href="http://blogs.jetbrains.com/dotnet/">JetBrains .NET blog</a> and web site are talking about major features in ReSharper 5, like showing metadata for library classes, downloading source code for .NET Framework, code inspections, ASP.NET MVC support and other great things. But there are many more improvements in ReSharper 5 which deserve attention and I thought I should blog about them. <br /><br />When ReSharper first introduced CamelHumps to .NET world (and then other tools and Visual Studio 2010 followed), it worked only in Go To Type and similar features. It is very convenient to type just "TMV" and see "<strong>T</strong>ree<strong>M</strong>odel<strong>V</strong >iew" in the list. In previous version of ReSharper we added CamelHumps matching to intellisense and that increased productivity once again. In ReSharper-enabled teams one can often hear people talking abbreviations. <br /><br />But <em>original</em> style of typing abbreviations has one issue - to much Shift use. Now, with ReSharper 5, it is no longer needed:<br /> <br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxA_-tzNHIp6HTwAgVxUbTRh820hzoXMPXirNZRkGz8a04jwHEU5XMLM7OGVlHyzDFkkk9m1e5Zp9RTbvC2zuTykhuZYuBDMq4SZb-ioLVyyPGw-evUHsXjkKQDaZXuBJftqwWFuQrFz4/s1600-h/LowerCaseMatching.png"><img style="margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 75px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxA_-tzNHIp6HTwAgVxUbTRh820hzoXMPXirNZRkGz8a04jwHEU5XMLM7OGVlHyzDFkkk9m1e5Zp9RTbvC2zuTykhuZYuBDMq4SZb-ioLVyyPGw-evUHsXjkKQDaZXuBJftqwWFuQrFz4/s320/LowerCaseMatching.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5397939276646717042" /></a><br /><br />ReSharper can recognize CamelHumps and match them to lower case letters. This of course works in completion too:<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHT2gqUE9lPemTvvmQTn9YR1qORyAbwNr-IbaeFms8gA7jk3Vy5eOgrX4dJndBtnSVaxtBUQ8wFOkwXHpZoGAbqeDMrGNs47tS2swwP_7fxFQbdJMV8EaqUO-80elrmfxVkRfakoKZ5B0/s1600-h/LowerCaseCompletion.png"><img style="margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 256px; height: 66px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHT2gqUE9lPemTvvmQTn9YR1qORyAbwNr-IbaeFms8gA7jk3Vy5eOgrX4dJndBtnSVaxtBUQ8wFOkwXHpZoGAbqeDMrGNs47tS2swwP_7fxFQbdJMV8EaqUO-80elrmfxVkRfakoKZ5B0/s320/LowerCaseCompletion.png" border="0" alt=""id="BLOGGER_PHOTO_ID_5397940028580861266" /></a><br /><br />That tiny feature alone can increase code crafting speed and make you more productive, especially when you have longer descriptive type names. <br /><br /><em>ReSharper 5 early builds are currently available throught <a href="http://www.jetbrains.net/confluence/display/ReSharper/ReSharper+Early+Access+Program">Early Access Program</a>. ReSharper 4.5 purchases made on or after October 15, 2009, qualify for a FREE upgrade to ReSharper 5.0</em>Ilya Ryzhenkovhttp://www.blogger.com/profile/14966746474791511643noreply@blogger.com4tag:blogger.com,1999:blog-4439386706617871322.post-63278343850614828692009-07-08T12:07:00.003+04:002009-07-08T12:22:46.425+04:00Migrating Source -- Switching Unit Testing FrameworkI noticed <a href="http://blog.eweibel.net/?p=303">several</a> <a href="http://stackoverflow.com/questions/709331/switching-between-using-nunit-and-mstest-for-unit-testing">people</a> are migrating their source code base from NUnit to MSTest and vice versa. I thought I could share a useful technique to automate this process with ReSharper, and it appears to be large enough topic to not fit my <a href="http://twitter.com/orangy">my twitter</a> feed. Obviously, it applies not just to Unit Testing Framework switching, but to almost any library migrations.<br /><br />If I were faced with the task to migrate NUnit to MSTest I wouldn't use search-and-replace, but instead migrate it via <strong>temporary stubs</strong>. It would require me do several pretty easy steps:<br /><ol><li>Remove references to <em>nuint.framework.dll</em>. I will get lots of red code, but we'll fix it in a minute. </li><br /><li>Add nunit.framework.dll source code to solution (if permitted by license), or write stubs for what I use, like TestFixture, Test, Setup and TearDown attributes and assertion classes. When I'm done with that, all code should be green again, which you can instantly verify with <em>Solution Wide Analysis</em>.</li><br /><li>Move all those types to MSTest namespaces.</li><br /><li>Rename types to match MSTest types.</li><br /><li>For assertions, implement missing members using existing API and use <em>Inline Method</em> refactoring to get rid of them.</li><br /><li>Remove stubs and add references to MSTest assemblies.</li><br /><li>Enjoy MSTest runner in ReSharper 4.5 to run your beloved tests.</li><br /></ol><br /><br />Using this technique, or variation of it, you can easily migrate your source code to different API, library or technology, even if you don't have source code for it. <br /><br /><em>Develop with pleasure!</em>Ilya Ryzhenkovhttp://www.blogger.com/profile/14966746474791511643noreply@blogger.com3tag:blogger.com,1999:blog-4439386706617871322.post-26517945284543744972009-04-08T16:18:00.005+04:002009-04-08T21:33:08.817+04:00ReSharper 4.5 ReleasedWe just released ReSharper 4.5, minor version aimed at performance, stability, compatibility and less memory usage. All the same great features plus some <a href="http://www.jetbrains.com/resharper/features/newfeatures.html">nice additions</a>, free for owners of ReSharper 4.x licenses. You can read more about <a href="http://resharper.blogspot.com/2009/03/resharper-45-what-were-we-doing.html">what we were doing</a> to improve quality of our product for your pleasure. <br /><br /><a href="http://www.jetbrains.com/resharper/download/index.html">Download ReSharper 4.5</a> and enjoy your productivity boost!<br /><br />From now on, we are going to focus on ReSharper 5 with the main goal to support Visual Studio 2010 and C# 4. But that is not the whole story about next major version! I will be blogging about ReSharper 5 cool new features during our way to the next release. <br /><br /><em>Develop with pleasure!</em>Ilya Ryzhenkovhttp://www.blogger.com/profile/14966746474791511643noreply@blogger.com5tag:blogger.com,1999:blog-4439386706617871322.post-70241370029882111042009-04-06T12:48:00.018+04:002009-04-08T00:47:23.479+04:00Mortal Kode -- Quite Simple GenericsIt is very important for a tool to understand <strong>correctly</strong> what is written in the code. You just can't underestimate the importance of this ability. If the code is not correctly parsed, resolved, analyzed and understood by the tool's core, any other feature of the tool can easily fail. Nobody wants Rename refactoring to miss changes, code completion to insert unavailable symbols and code navigation to put the caret in a wrong position. Actually, the most annoying thing would be wrong code analysis, when code is incorrectly flagged with error, when in fact it compiles just fine. This all can easily happen if underlying code model is wrong.<br /><br />That's why here at JetBrains, we put a lot of effort into our code model, language understanding and work hard to handle even most complex cases -- after all, they can easily be found in real applications.<br /><br />Today we will look at complexity of code involving generics in C#. Consider the following example (thanks to Vladimir for this one):<br /><br /><div style=" background: white;font-family:Courier New;font-size:9pt;color:black;"><pre style="margin: 0px;"> <span style="color:blue;">abstract</span> <span style="color:blue;">class</span> <span style="color:#2b91af;">A</span><<span style="color:#010001;">T</span>></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color:blue;">public</span> <span style="color:blue;">abstract</span> <span style="color:blue;">void</span> <span style="color:#010001;">Foo</span>(<span style="color:#010001;">T</span> <span style="color:#010001;">x</span>);</pre><pre style="margin: 0px;"> <span style="color:blue;">public</span> <span style="color:blue;">abstract</span> <span style="color:blue;">class</span> <span style="color:#2b91af;">B</span><<span style="color:#010001;">S</span>> : <span style="color:#2b91af;">A</span><<span style="color:#2b91af;">B</span><<span style="color:#010001;">S</span>>></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color:blue;">public</span> <span style="color:blue;">class</span> <span style="color:#2b91af;">C</span><<span style="color:#010001;">U</span>> : <span style="color:#2b91af;">B</span><<span style="color:#2b91af;">C</span><<span style="color:#010001;">U</span>>> </pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre></div><br />I think not too many people out there can easily say what would be the correct signature for the implementation of method Foo in the nested class C<U>. As for me, I can't. Doing it manually is simply too much.<br /><br />First, we try Visual Studio "override" helper and we get the following:<br /><br /><div style=" background: white;font-family:Courier New;font-size:9pt;color:black;"><pre style="margin: 0px;"> <span style="color:blue;">public</span> <span style="color:blue;">override</span> <span style="color:blue;">void</span> <span style="color:#010001;">Foo</span>(<span style="color:#2b91af;">A</span><<span style="color:#2b91af;">B</span><<span style="color:#010001;">S</span>>>.<span style="color:#2b91af;">B</span><<span style="color:#2b91af;">C</span><<span style="color:#010001;">U</span>>> <span style="color:#010001;">x</span>)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color:blue;">throw</span> <span style="color:blue;">new</span> <span style="color:#2b91af;">NotImplementedException</span>();</pre><pre style="margin: 0px;"> }</pre></div><br />Complex enough, and not quite correct:<br /><pre>error CS0115: 'A<T>.B<S>.C<U>.Foo(A<A<A<A<T>.B<S>>.B<A<T>.B<S>.C<U>>>.B<S>>.B<A<A<T>.B<S>>.B<A<T>.B<S>.C<U>>.C<U>>)': no suitable method found to override <br />error CS0534: 'A<T>.B<S>.C<U>' does not implement inherited abstract member 'A<A<A<T>.B<S>>.B<A<T>.B<S>.C<U>>>.Foo(A<A<T>.B<S>>.B<A<T>.B<S>.C<U>>)'</pre><br />Let's see what ReSharper 4.5 inserts when developer uses "Implement missing members" action from the "Generate" menu:<br /><br /><div style=" background: white;font-family:Courier New;font-size:9pt;color:black;"><pre style="margin: 0px;"> <span style="color:blue;">public</span> <span style="color:blue;">override</span> <span style="color:blue;">void</span> <span style="color:#010001;">Foo</span>(<span style="color:#2b91af;">A</span><<span style="color:#2b91af;">A</span><<span style="color:#010001;">T</span>>.<span style="color:#2b91af;">B</span><<span style="color:#010001;">S</span>>>.<span style="color:#2b91af;">B</span><<span style="color:#2b91af;">A</span><<span style="color:#010001;">T</span>>.<span style="color:#2b91af;">B</span><<span style="color:#010001;">S</span>>.<span style="color:#2b91af;">C</span><<span style="color:#010001;">U</span>>> <span style="color:#010001;">x</span>)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> }</pre></div><br />You can see that parameter type is exactly the same as expected by compiler. Needless to say the signature is <strong>correct</strong>, and you don't have to compile it first.<br /><br /><em>Does <strong>your</strong> tool understand non-trivial code?</em><br /><br />Next time, we'll take a look at some lambda fun.Ilya Ryzhenkovhttp://www.blogger.com/profile/14966746474791511643noreply@blogger.com4tag:blogger.com,1999:blog-4439386706617871322.post-51061131445868079902009-03-20T10:50:00.005+03:002009-03-20T16:30:09.701+03:00ReSharper 4.5 -- From Beta to ReleaseIt's been a while since we released <a href="http://www.jetbrains.com/resharper/beta.html">ReSharper 4.5 Beta</a> and it went pretty cool. Those who like fresh bits <a href="http://www.nablasoft.com/guardian/index.php/2009/03/19/resharper-45-beta-give/">posted</a> <a href="http://www.nablasoft.com/alkampfer/index.php/2009/03/18/reshaper-45-beta/">some</a> <a href="http://scipbe.wordpress.com/2009/03/18/resharper-45-beta/">feedback</a> <a href="http://leriksen71.wordpress.com/2009/03/18/resharper-45-first-impression/">about</a> Beta already, and they like it! <br /><br />Of course, Beta is not Release and it has its own problems, which we are working on all days long. <a href="http://www.jetbrains.net/confluence/display/ReSharper/ReSharper+4.5+Nightly+Builds">Nightly Builds</a> are published and quality constantly improves. You can see community-based build rating improving from "Works" to "Stable", and we aim at five stars "No problems at all" for final version!<br /><br />There is only one issue with achieving best quality for everyone:<br /><br /><center><strong>Every combination of <br />project, environment and developer <br />is unique</strong></center><br /><br />We thoroughly test lots of cases: various packages and extensions installed into Visual Studio, operating system versions, types and sizes of projects, configurations of the environment. But there are thousands other unique combinations of those things, and of course <strong>your</strong> unique way of working with code. <br /><br />In our course from ReSharper 4.5 beta to release, we welcome you to participate in the process of making ReSharper best productivity tool <strong>for you</strong>. Please, do not hide in shadows waiting for release. Tell us anything and everything you feel wrong about latests builds. Don't wait for someone else to report the problem, it can very well happen there is no someone else. Write in comments, post to <a href="http://twitter.com/resharper">Twitter</a>, submit requests to our <a href="http://jetbrains.net/jira/browse/RSRP">issue tracker</a>, or send email to support at JetBrains. We are in hunger for your feedback! And we <strong>promise</strong> to <a href="http://twitter.com/KatMagic/statuses/1354847943">do</a> our <a href="http://twitter.com/jpboodhoo/statuses/1323569920">best</a> to <a href="http://twitter.com/HowardvRooijen/statuses/1347249835">improve</a> your experience with ReSharper. <br /><br />Thank you for your participation in the Early Access Program! <br /><br />PS: Try Scott's <a href="http://sleepoverrated.com/archive/2009/02/downloader-for-resharper-nightly-builds/">Nightly Builds Updater</a>, it will help you run the most recent bits of ReSharper.Ilya Ryzhenkovhttp://www.blogger.com/profile/14966746474791511643noreply@blogger.com0tag:blogger.com,1999:blog-4439386706617871322.post-51435232754456130072009-03-12T18:00:00.013+03:002009-03-13T01:06:24.201+03:00ReSharper 4.5 -- What Were We Doing?<a href="http://resharper.blogspot.com/2009/03/resharper-45-looking-in-past.html">Recently</a> we looked at ReSharper's past. You probably noticed that we often have x.5 releases, aimed at performance and stabilization. After the big marathon run for C# 3.0 and VS2008, we finally got some time to perform housekeeping, clean out and sweeping tasks. Not just for beautiful code, but for <strong>improvements in speed and memory</strong> that require architecture changes.<br /><br />Since ReSharper 4.1 release in September, we spent lots of time with <a href="http://www.jetbrains.com/profiler/">dotTrace</a>, running hundreds of use cases and analyzing results. We identified several major bottlenecks that hindered performance, and hundreds of smaller problems. We also analyzed managed and unmanaged memory usage in many types of solutions of different sizes. For many issues, small changes here and there just weren’t enough. We <span style="font-weight:bold;">had to change</span> data structures, algorithms, dependencies, ownership of objects, and sometimes even basic principles of our code.<br /><br />Tough decision, but we decided that performance, memory usage and building a <span style="font-weight:bold;">foundation for further improvements</span> were of a higher priority than API compatibility. Without that massive code cleanup we would have been spending more and more resources to make our product better for you, and without much success. Please accept our apologies, plug-in developers! We really had to do that to gain <span style="font-weight:bold;">30% speed improvement</span> overall, up to 60% in many cases if you use multicore processor. We‘re hoping to extend parallel processing capabilities in ReSharper 5 and improve speed even more, but we had to lay a foundation for this.<br /><br />Another big part of our work was dedicated to <span style="font-weight:bold;">Visual Studio integration</span>. It is too early to speak about Visual Studio 2010 integration at the moment, but even earlier versions required substantial efforts. We <span style="font-weight:bold;">improved integration</span> with various packages, provided fixes or workarounds for a good deal of problems. We spent lots of time doing low level debugging in mixed (managed/unmanaged) environment and I must admit -- it was fun but also very hard. Microsoft Development Tools Division did a great job helping us solve issues and answering our questions (which were far from being trivial, as you might guess). In fact, during the past year we got much more assistance from Microsoft than ever! Thank you guys, I hope you don't have my picture attached to your dartboards :)<br /><br />Developing <span style="font-weight:bold;">new features</span> and improving existing ones was the last, but not the least piece of our work. We reworked ReSharper <span style="font-weight:bold;">naming system</span> and, finally, you can configure a style for virtually any identifier . We added more functionality to <span style="font-weight:bold;">Solution Wide Analysis</span> -- it is now able to highlight globally unused symbols for you, redundant virtual keyword, parameters that are not used in any overrides, and much more. My favorite global inspection detects potential problems in cross-casts, like when you cast a variable of type IFoo to IBar, but there is no class in solution that implements both interfaces! New <span style="font-weight:bold;">Go to Implementation</span> feature allows you to jump straight to the code that might run, skipping all interfaces and abstract classes. <span style="font-weight:bold;">Find Referenced Code</span> can now run on any selection in Solution Explorer, quickly showing you dependencies of a particular part of your solution. <span style="font-weight:bold;">MSTest</span> is now built into ReSharper, <span style="font-weight:bold;">Visual Basic .NET</span> support has been greatly improved, and many reworked <span style="font-weight:bold;">refactorings</span> are now particularly rock solid.<br /><br />These days we are preparing to publish <span style="font-weight:bold;">ReSharper 4.5 Beta</span>. As more and more people download ReSharper 4.5 <a href="http://www.jetbrains.net/confluence/display/ReSharper/ReSharper+4.5+Nightly+Builds">nightly builds</a>, we get invaluable feedback to make this release really shiny. It is currently very stable, with several known glitches that we are fixing. Each new build is better than previous ones.<br /><br />Don’t hesitate to <a href="http://www.jetbrains.net/confluence/display/ReSharper/ReSharper+4.5+Nightly+Builds">download it</a>, try it yourself and <a href="http://www.jetbrains.net/devnet/community/resharper/resharper_eap">tell us</a> how it works for you!<br />We mean it: we really, really need to know how it behaves in your unique environment with your unique solution, and it’s only you who can <a href="http://jetbrains.net/jira/browse/RSRP">let</a> <a href="http://twitter.com/orangy">us</a> <a href="http://www.jetbrains.net/devnet/community/resharper/resharper_eap">know</a> about it!Ilya Ryzhenkovhttp://www.blogger.com/profile/14966746474791511643noreply@blogger.com12tag:blogger.com,1999:blog-4439386706617871322.post-7075111112299368962009-03-12T13:37:00.008+03:002009-03-12T18:20:22.624+03:00ReSharper 4.5 -- Looking in the PastI didn't post anything for 4 months and I want to fix that. Where is my light bulb I wonder? Not that I had nothing to say, more like I was wearing developer's hat. Anyway, I thought I could explain what's been going on and what we've been doing for the upcoming release, ReSharper 4.5.<br /><br />But before I start talking about the new release, I'd like to look back at ReSharper history.<br /><br />2004, July: <strong>ReSharper 1.0</strong><br />First release of JetBrains ReSharper, productivity add-in for Visual Studio 2003 and C# 1.1. <em>Code analysis</em>, <em>quick fixes</em> and <em>context actions</em>, <em>refactorings</em> and <em>templates</em>, all in JetBrains' intelligent style. <pre><br /> System.Console.Out.WriteLine("Hello .NET world");<br /></pre><br />2005, March: <strong>ReSharper 1.5</strong> <br />Added 8 new refactorings. <em>Performance</em> was significantly improved. <br /><br />2006, May: <strong>ReSharper 2.0</strong><br />With this new release, ReSharper makes a step up from a simple add-in to a real development environment. Support for Visual Studio 2005 and C# 2.0, more <em>refactorings</em>, <em>ASP.NET</em> support, <em>Unit Testing</em>, <em>build script</em> support, additional navigation commands and more.<br /><br />2006, December: <strong>ReSharper 2.5</strong><br />Focus on the <em>performance</em> improvements and usability to improve developers' experience. Of course we couldn't resist a few new features as well: <em>null-reference analysis</em>, <em>Navigate from Here</em> and <em>Go to File Member</em>.<br /><br />2007, June: <strong>ReSharper 3.0</strong><br />Major feature-loaded release, bringing many productivity enhancements to the table. Many of them are now perceived as if they've been there forever. <em>Go to Symbol</em>, find <em>referenced and dependent code</em>, automatic <em>member reordering</em>, rearranging statements and members, to-do browser. Code analysis got suggestions, VB got many of the features previously available only for C#, and XAML made it to the list of supported technologies.<br /><br />2008, June: <strong>ReSharper 4.0</strong><br />This release introduced support for Visual Studio 2008 and C# 3.0 with vars, extension methods, lambdas, LINQ, object & collection initializers, anonymous types, and partial methods. This alone would be sufficient for a new major release. However, we did more: <em>Solution-Wide Analysis</em>, <em>Code Cleanup</em>, <em>Complete Statement</em>, more <em>refactorings</em>, improved <em>IntelliSense</em>, <em>recent edits</em> and other tools to simplify everyday development tasks. <br /><br />That is how ReSharper have been evolving in the past. What's next?<br /><br />2009, March-April: <strong><a href="http://www.jetbrains.net/confluence/display/ReSharper/ReSharper+4.5+Nightly+Builds">ReSharper 4.5</a></strong><br /><br /><em>To be continued...</em>Ilya Ryzhenkovhttp://www.blogger.com/profile/14966746474791511643noreply@blogger.com2tag:blogger.com,1999:blog-4439386706617871322.post-83360447956684103742008-11-07T16:57:00.004+03:002008-11-07T17:23:42.816+03:00Microsoft Tech·Ed EMEA 2008 / DevelopersWe'll be there, at Microsoft Tech·Ed EMEA 2008 Developers, Barcelona, booth E3. If you are going to be there come visit us and let's talk! Whether you like to learn about ReSharper or TeamCity or dotTrace, grab some tips and tricks, learn what we are going to do in future versions, or just talk about how wonderful the world is - you're welcome at our booth. See you!Ilya Ryzhenkovhttp://www.blogger.com/profile/14966746474791511643noreply@blogger.com3tag:blogger.com,1999:blog-4439386706617871322.post-39969228122345410542008-11-01T15:00:00.000+03:002008-11-01T15:00:00.941+03:00Wild World of Visual Studio -- Proxies confront HooksHow can Internet Explorer settings interfere with productivity add-in to Visual Studio, such as ReSharper? And even lead to Visual Studio crash when doing some seemingly unrelated operations, like checking out source code from Team Foundation Server?<br /><br /><span style="font-weight:bold;">Story 3 -- Proxies confront Hooks</span><br /><br />We've got a number of reports about Visual Studio crash when doing repository operations using TFS. Of course, when ReSharper is disabled, no crashes occurs, which make users think ReSharper is guilty. We couldn't reproduce the problem in the labs, and we again tried to assert/log/verify everything we can think about. We even got some dumps with the crash, but could not find anything really useful there, besides evidence that there are numerous SecurityExceptions instances in the managed heap waiting to be collected. We needed reproducible case with WinDbg attached. Thanks to Vasily, we got one. <br /><br />It is funny how we were debugging this crash. Since we were not able to reproduce the problem in the labs, we needed access to the faulty computer. However, due to corporate rules on the user's side, we were not able to arrange real remote session. But we had WinDbg with command line interface, and we had instant messaging. So I was sending WinDbg commands, he copied them into WinDbg, executed, and then copied back the result. We laughed about it and were kidding about extension to WinDbg which would be Jabber client :)<br /><br />After several days being in this copy-paste process, we finally found the problem. Three components playing together made it explosive: <br /><ul><br /><li> Connecting to web site with HTTP when automatic proxy configuration script is enabled (It is basically JScript function which gives proxy address for given host)<br /><li> Managed hooks installed (here is ReSharper's role in the problem, but could be any other plugin)<br /><li> Pumping messages during JScript code execution<br /></ul><br />Remove one, and all is fine again. So, what is happening in our case? Now, watch my hands. <ol><br /><li> TeamFoundation client is going to communicate to server.<br /><li> It initiates connection to web service.<br /><li> HttpWebRequest is asking for proxy information.<br /><li> WebProxy detects that automatic proxy configuration script is enabled.<br /><li> AutoWebProxyScriptEngine downloads script and uses JScript engine to execute it<br /><li> JScript engine restricts code permissions to execute only.<br /><li> Exception happens while executing JScript and dialog is going to be shown with error information. This is who pumps messages.<br /><li> Our managed hook is executed and attempts to use CallNextHookEx to pass data to other hooks.<br /><li> Code Access Security system demands UnmanagedCode permission.<br /><li> Due to restricted mode in which JScript executes, demand fails and SecurityException is rised.<br /><li> Exception causes corruption of some internal Visual Studio COM objects, which instantly leads to Access Violation. <br /></ol><br />Well, actually, this one was our fault. I added SecurityPermissionAttribute asserting UnmanagedCode permission to the hook procedure and ReSharper is shining like a diamond again. <br /><br /><span style="font-style:italic;">Case closed, lessons learned.</span>Ilya Ryzhenkovhttp://www.blogger.com/profile/14966746474791511643noreply@blogger.com3tag:blogger.com,1999:blog-4439386706617871322.post-81763479619561777722008-10-31T09:00:00.000+03:002008-10-31T09:00:00.481+03:00Wild World of Visual Studio -- Mysterious ComponentThis one was bugging us for a long time, until we got message from Jay (thanks!) who had similar problem and was willing to help. <br /><br /><span style="font-weight:bold;">Story 2 -- Mysterious Component</span><br /><br />The problem itself is mysterious. From time to time it happens that Visual Studio stops loading any add-ins. ReSharper is installed, but its menus are suddenly all gray and it is not listed in the "Tools \ Add-in manager" dialog. It happens after installing various products, it could be service pack, SQL server tools, Visual Studio components - anything! Some users install them and all works fine. Some users loose their favorite productivity tool. <br /><br />Logging, debugging, trying to reproduce for may be several years(!) led to no result. ReSharper was simply not loaded into the process, though all registration information appears to be in the right place. We checked encodings, verified files are not corrupted, verified registry access rights - all we can think of. As you can guess now, the reason was not anywhere near. <br /><br />After lots of email exchanges with Jay, including mini-dumps, Process Monitor traces, registry excerpts, configuration files and such we suddenly found ourselves staring at the right thing. It was msxml6.dll. Actually, it was the fact that there were no msxml6.dll in the call stack. Instead, there was msxml3.dll. <br /><br />We use .addin files to register our add-in in Visual Studio. It is XML file describing add-in, containing information about primary assembly, descriptions, load options and Visual Studio version compatibility information. The latter was that msxml3 was not able to process and thus Visual Studio refused add-in as non-compatible. In fact, msxml6 was there in System32, but it somehow happened to be not registered as COM object. Using regsvr32 on msxml6.dll repaired the system, resurrected ReSharper and enabled customers to enjoy our productivity add-in again. <br /><br /><span style="font-style:italic;">Case closed.</span>Ilya Ryzhenkovhttp://www.blogger.com/profile/14966746474791511643noreply@blogger.com5tag:blogger.com,1999:blog-4439386706617871322.post-25470698323461833622008-10-30T13:52:00.015+03:002008-10-30T16:16:23.610+03:00Wild World of Visual Studio -- Unfriendly PackageWhile developing "The Most Intelligent Add-In To Visual Studio" we often face issues that originates from the outside of our code. Being that Visual Studio itself, other packages and add-ins installed, OS components or other things added to the mix - it is always extremely hard to reproduce, debug and understand. Usually we have to perform post-mortem debugging, when all we have is mini-dump from the user experiencing the crash. And we are very happy when we have mini-dump! Often we have to resort to psychic debugging, speculating about what could have happened, trying this and that until we find the cause and issue the fix. <br /><br />I though I could share some stories of pure insanity we happened to participate in recently. May be another add-in developer is scratching his head in an attempt to understand the source of strange sounds from beneath the ground, and these stories will help. Or it may be just interesting reading for you. Or not :)<br /><br />The first one is the most recent one and is pretty simple. <br /><br /><span style="font-weight:bold;">Story 1 -- Unfriendly Package</span><br /><br />Our customers were complaining about Visual Studio crashing on start with ReSharper installed when running non-admin. Disabling ReSharper allows Visual Studio to load normally. When you see such behavior, you are absolutely sure ReSharper is guilty, aren't you? <br /><br />We've learned to be cautious in such cases. So I asked user (thanks Jon!) to capture mini-dump and send it to me for investigation. While downloading it, I was preparing myself to long hours of WinDbg magic, but !ClrStack revealed it in a second. SnippetDesigner was not able to access its files, since it placed it in privileged folder. It did so in the background thread and didn't catch exceptions. The result is CLR termination, which get Visual Studio to nowhere with itself. <br /><br />But wait! Why disabling ReSharper helped to avoid crash? Well, actually crash happens during SnippetDesigner package loading. Normally, it occurs when its window is opened (and it indeed crashes VS at this point without ReSharper). However, ReSharper uses Visual Studio API to get some configuration information, which can be extended with packages. So, by calling this API ReSharper caused those packages to load, essentially triggering the bug in SnippetDesigner on startup. <br /><br /><span style="font-style:italic;">Case closed, opened <a href="http://www.codeplex.com/SnippetDesigner/WorkItem/View.aspx?WorkItemId=531">another one</a>.</span>Ilya Ryzhenkovhttp://www.blogger.com/profile/14966746474791511643noreply@blogger.com0tag:blogger.com,1999:blog-4439386706617871322.post-83087913107156881222008-10-06T15:59:00.007+04:002008-10-06T16:38:37.254+04:00ReSharper Combos - Hiding DetailsToday my day started with the question from Oleg Stepanov, Project Manager of ReSharper. He asked about avoiding huge amount of manual code changes, and after short discussion we got it done with ReSharper. I was very excited! We were able to solve refactoring task in seconds, invent new refactoring combo, and ReSharper was so smart to handle it absolutely right. <strong>No manual code changes</strong> outside of the type being refactored. Here is simplified version of what we had, what we were to accomplish and how we did it. <br /><br /><div style="font-family: Courier New; font-size: 10pt; color: black; background: white;"><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">Person</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">string</span> <span style="color: #010001;">Name</span> { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }</pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">int</span> <span style="color: #010001;">Age</span> { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">PersonInformation</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">private</span> <span style="color: blue;">readonly</span> <span style="color: #2b91af;">Person</span> <span style="color: #010001;">myPerson</span>;</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: #010001;">PersonInformation</span>(<span style="color: #2b91af;">Person</span> <span style="color: #010001;">person</span>)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: #010001;">myPerson</span> = <span style="color: #010001;">person</span>;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: #2b91af;">Person</span> <span style="color: #010001;">Person</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">get</span> { <span style="color: blue;">return</span> <span style="color: #010001;">myPerson</span>; }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">internal</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">Processor</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">private</span> <span style="color: blue;">readonly</span> <span style="color: #2b91af;">PersonInformation</span> <span style="color: #010001;">myPersonInformation</span>;</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: #010001;">Processor</span>(<span style="color: #2b91af;">PersonInformation</span> <span style="color: #010001;">personInformation</span>)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: #010001;">myPersonInformation</span> = <span style="color: #010001;">personInformation</span>;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">int</span> <span style="color: #010001;">Process</span>()</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">switch</span> (<span style="color: #010001;">myPersonInformation</span>.<span style="color: #010001;">Person</span>.<span style="color: #010001;">Name</span>)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">case</span> <span style="color: #a31515;">"Mike"</span>:</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> 1;</pre><pre style="margin: 0px;"> <span style="color: blue;">case</span> <span style="color: #a31515;">"Sally"</span>:</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> <span style="color: #010001;">myPersonInformation</span>.<span style="color: #010001;">Person</span>.<span style="color: #010001;">Age</span> > 30 ? 2 : 3;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> <span style="color: #010001;">myPersonInformation</span>.<span style="color: #010001;">Person</span>.<span style="color: #010001;">Age</span> < 20 ? 0 : 1;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre></div><br />Consider PersonInformation class above. We wanted to decouple it from Person class and make it store Name and Age itself. However, we had a lot of usages like in Processor.Process, where Person property was being used to access Name and Age. How would we do it?<br /><br />First, we use Generate (Alt-Ins) and select Delegating Members to generate Name and Age properties in PersonInformation class:<br /><br /><div style="font-family: Courier New; font-size: 10pt; color: black; background: white;"><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">string</span> <span style="color: #010001;">Name</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">get</span> { <span style="color: blue;">return</span> <span style="color: #010001;">myPerson</span>.<span style="color: #010001;">Name</span>; }</pre><pre style="margin: 0px;"> <span style="color: blue;">set</span> { <span style="color: #010001;">myPerson</span>.<span style="color: #010001;">Name</span> = <span style="color: blue;">value</span>; }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">int</span> <span style="color: #010001;">Age</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">get</span> { <span style="color: blue;">return</span> <span style="color: #010001;">myPerson</span>.<span style="color: #010001;">Age</span>; }</pre><pre style="margin: 0px;"> <span style="color: blue;">set</span> { <span style="color: #010001;">myPerson</span>.<span style="color: #010001;">Age</span> = <span style="color: blue;">value</span>; }</pre><pre style="margin: 0px;"> }</pre></div><br />Then we change Person Property to return PersonInformation instead. Since there are all required properties already, usages are not broken. They are now routed through delegating members and use Name and Age properties of PersonInformation:<br /><br /><div style="font-family: Courier New; font-size: 10pt; color: black; background: white;"><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: #2b91af;">PersonInformation</span> <span style="color: #010001;">Person</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">get</span> { <span style="color: blue;">return</span> <span style="color: blue;">this</span>; }</pre><pre style="margin: 0px;"> }</pre></div><br />And here magic happens, we use Inline Property refactoring to get rid of the property!<br /><br /><div style="font-family: Courier New; font-size: 10pt; color: black; background: white;"><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">Person</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">string</span> <span style="color: #010001;">Name</span> { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }</pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">int</span> <span style="color: #010001;">Age</span> { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">PersonInformation</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">private</span> <span style="color: blue;">readonly</span> <span style="color: #2b91af;">Person</span> <span style="color: #010001;">myPerson</span>;</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: #010001;">PersonInformation</span>(<span style="color: #2b91af;">Person</span> <span style="color: #010001;">person</span>)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: #010001;">myPerson</span> = <span style="color: #010001;">person</span>;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">string</span> <span style="color: #010001;">Name</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">get</span> { <span style="color: blue;">return</span> <span style="color: #010001;">myPerson</span>.<span style="color: #010001;">Name</span>; }</pre><pre style="margin: 0px;"> <span style="color: blue;">set</span> { <span style="color: #010001;">myPerson</span>.<span style="color: #010001;">Name</span> = <span style="color: blue;">value</span>; }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">int</span> <span style="color: #010001;">Age</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">get</span> { <span style="color: blue;">return</span> <span style="color: #010001;">myPerson</span>.<span style="color: #010001;">Age</span>; }</pre><pre style="margin: 0px;"> <span style="color: blue;">set</span> { <span style="color: #010001;">myPerson</span>.<span style="color: #010001;">Age</span> = <span style="color: blue;">value</span>; }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">internal</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">Processor</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">private</span> <span style="color: blue;">readonly</span> <span style="color: #2b91af;">PersonInformation</span> <span style="color: #010001;">myPersonInformation</span>;</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: #010001;">Processor</span>(<span style="color: #2b91af;">PersonInformation</span> <span style="color: #010001;">personInformation</span>)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: #010001;">myPersonInformation</span> = <span style="color: #010001;">personInformation</span>;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">int</span> <span style="color: #010001;">Process</span>()</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">switch</span> (<span style="color: #010001;">myPersonInformation</span>.<span style="color: #010001;">Name</span>)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">case</span> <span style="color: #a31515;">"Mike"</span>:</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> 1;</pre><pre style="margin: 0px;"> <span style="color: blue;">case</span> <span style="color: #a31515;">"Sally"</span>:</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> <span style="color: #010001;">myPersonInformation</span>.<span style="color: #010001;">Age</span> > 30 ? 2 : 3;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> <span style="color: #010001;">myPersonInformation</span>.<span style="color: #010001;">Age</span> < 20 ? 0 : 1;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre></div><br />Look how Processor now uses Name and Age directly on PersonInformation class and has no idea about Person class used inside! Now the fact that PersonInformation uses Person is implementation detail and we can change it any way we like. <br /><br /><span style="font-style:italic;">Refactor With Pleasure!</span>Ilya Ryzhenkovhttp://www.blogger.com/profile/14966746474791511643noreply@blogger.com3tag:blogger.com,1999:blog-4439386706617871322.post-68401289242761812952008-10-03T10:55:00.011+04:002008-10-03T17:54:15.710+04:00ReSharper Guidelines -- First Time UsersHarry L. wrote in review of ReSharper on <a href="http://visualstudiogallery.com/ExtensionDetails.aspx?ExtensionID=ea4ac039-1b5c-4d11-804e-9bede2e63ecf&tab=review&sort=3">Visual Studio Gallery</a>:<br /><blockquote>... I have found that I used the features of Resharper almost without knowing it. What amazed me was how many features I use without going up a long learning curve... </blockquote><br />Indeed, most important ReSharper features can be instantly learned right from the code editor without reading any documentation. However, I thought that having some guidelines about where to look and how to improve own productivity would be nice anyway. So I'm going to write several posts about how to use ReSharper in a form of <strong>guidelines</strong>. <br /><br /><small><em>Shortcuts are given for Visual Studio keyboard scheme, but you can easily find shortcuts for your configuration in ReSharper menu.</em> </small><br /><br /><strong>First Time Users</strong> guidelines: <br /> <br /><ol><br /><li> <strong><span style="color:#006600;">DO</span></strong> open your real project in Visual Studio with ReSharper enabled. Playing with the productivity tool in a sandbox doesn't really give you understanding about its effect. It can take some time for ReSharper to analyze your solution for the first time, but it will be much faster during subsequent runs.<br /><br /><li> <strong><span style="color:#990000;">DO NOT</span></strong> run away from your Visual Studio when you first open your source code with ReSharper :) You will see colored identifiers, a lot of squiggles indicating warnings and suggestions, redundant code painted in gray -- your code most likely will be overhighlighted. You will clean it up pretty fast with ReSharper. You can switch <em>Color Identifiers</em> off if you wish (ReSharper / Options / Code Inspection / Settings).<br /><br /><li> <strong><span style="color:#006600;">DO</span></strong> configure your naming (ReSharper / Options / Languages / Common / Naming Style) and formatting preferences (ReSharper / Options / Languages / C# / Formatting Style). ReSharper uses these settings when guessing on identifiers, while updating the code and doing other automatic code generation and transformation for you. <br /><br /><li> <strong><span style="color:#006600;">DO</span></strong> learn 4 keyboard shortcuts to use in code editor:<br /><ul><br /><li> <strong>Alt-Enter</strong> - opens code transformation menu with <em>Quick Fixes</em> and <em>Context Actions</em>. Try it whenever you see light bulb to the left of your code, and see what you can do with it. <br /><li> <strong>Alt-`</strong> (Navigate from Here) to open menu with actions to navigate from currently selected symbol, like "Go to base", "Go to derived" and "Go to usages"<br /><li> <strong>Alt-Ins</strong> (Generate) -- generates type members, like properties, constructors, overrides and implementations, Equals, GetHashCode and ToString methods. <br /><li> <strong>Ctrl-Shift-R</strong> (Refactor This) -- opens menu with all refactorings available at current caret position (or current selection in any ReSharper tool window). <br /></ul><br /><li> <strong><span style="color:#990000;">DO NOT</span></strong> use Solution Explorer to find code, use "Go to Type" (Ctrl-T), "Go to File" (Ctrl-Shift-T), "Recent Files" (Ctrl-,) and other commands from ReSharper / Go To menu. This will help you navigate much faster.<br /></ol><br /><br />After you familiarize yourself with these basic actions, <a href="http://www.jetbrains.com/resharper/documentation/index.html">download</a> and print key map and start exploring other commands.Ilya Ryzhenkovhttp://www.blogger.com/profile/14966746474791511643noreply@blogger.com5tag:blogger.com,1999:blog-4439386706617871322.post-79358542019373147732008-08-13T17:56:00.000+04:002008-08-13T17:00:07.452+04:00ReSharper Combos -- Refactoring To ComponentsReSharper has a number of features which are powerful by themselves, but reveal even more coolness when combined with other features. It's like Kung-Fu, when master can outperform enemies by wisely combining basic movements and strikes.<br /><br />Let's take for example a task of converting existing system, where all types are instantiated explicitly, to some <em>component container</em> system. Without ReSharper, this task is <span style="color:#cc0000;">SCARY</span>! Just imagine, going through hundreds or even thousands of files, checking where particular component is used, where instance is created and how passed to clients and manually updating all that code. Days or weeks to complete? No, we aren't going to do this...<br /><br />With ReSharper the task is still not simple one, but it can be achieved in a reasonable amount of time. Here is simple example:<br /><br /><div style="font-family: Courier New; font-size: 10pt; color: black; background: white;"><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">TheManager</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">void</span> <span style="color: #010001;">Manage</span>(<span style="color: blue;">string</span> <span style="color: #010001;">text</span>) { }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">TheProcessor</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">private</span> <span style="color: blue;">readonly</span> <span style="color: #2b91af;">TheManager</span> <span style="color: #010001;">myManager</span>;</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: #010001;">TheProcessor</span>(<span style="color: #2b91af;">TheManager</span> <span style="color: #010001;">manager</span>)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: #010001;">myManager</span> = <span style="color: #010001;">manager</span>;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">void</span> <span style="color: #010001;">Process</span>(<span style="color: #2b91af;">IEnumerable</span><<span style="color: blue;">string</span>> <span style="color: #010001;">texts</span>)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">foreach</span> (<span style="color: blue;">var</span> <span style="color: #010001;">text</span> <span style="color: blue;">in</span> <span style="color: #010001;">texts</span>)</pre><pre style="margin: 0px;"> <span style="color: #010001;">myManager</span>.<span style="color: #010001;">Manage</span>(<span style="color: #010001;">text</span>);</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">internal</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">Program</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">void</span> <span style="color: #010001;">Main</span>(<span style="color: blue;">string</span>[] <span style="color: #010001;">args</span>)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">var</span> <span style="color: #010001;">processor</span> = <span style="color: blue;">new</span> <span style="color: #2b91af;">TheProcessor</span>(<span style="color: blue;">new</span> <span style="color: #2b91af;">TheManager</span>());</pre><pre style="margin: 0px;"> <span style="color: #010001;">processor</span>.<span style="color: #010001;">Process</span>(<span style="color: #010001;">args</span>);</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre></div><br /><br />Now let's make it utilize some fictional ComponentContainer:<br /><br />1. Create temporary static class ComponentFactory to put factory methods in <br />2. Execute <strong>Replace constructor with factory method</strong> refactoring against component constructor, specify ComponentFactory as containing type.<br />3. Use <strong>Extract Interface</strong> refactoring from the component implementation. <br />4. Utilize <strong>Use base type where possible</strong> refactoring, select extracted interface. This should update all usages from specific class to interface. <br />5. <strong>Find Usages</strong> of component and verify you don't have any references to the class except instantiation inside ComponentFactory. Having other references mean interface was not complete, or there are dependencies on component implementation. Refactor as needed.<br /><br />Now you should have something like this:<br /><br /><div style="font-family: Courier New; font-size: 10pt; color: black; background: white;"><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">ComponentFactory</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: #2b91af;">ITheManager</span> <span style="color: #010001;">CreateTheManager</span>()</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">return</span> <span style="color: blue;">new</span> <span style="color: #2b91af;">TheManager</span>();</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">interface</span> <span style="color: #2b91af;">ITheManager</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">void</span> <span style="color: #010001;">Manage</span>(<span style="color: blue;">string</span> <span style="color: #010001;">text</span>);</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">TheManager</span> : <span style="color: #2b91af;">ITheManager</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">void</span> <span style="color: #010001;">Manage</span>(<span style="color: blue;">string</span> <span style="color: #010001;">text</span>) { }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">TheProcessor</span> </pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">private</span> <span style="color: blue;">readonly</span> <span style="color: #2b91af;">ITheManager</span> <span style="color: #010001;">myManager</span>;</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: #010001;">TheProcessor</span>(<span style="color: #2b91af;">ITheManager</span> <span style="color: #010001;">manager</span>)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: #010001;">myManager</span> = <span style="color: #010001;">manager</span>;</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">void</span> <span style="color: #010001;">Process</span>(<span style="color: #2b91af;">IEnumerable</span><<span style="color: blue;">string</span>> <span style="color: #010001;">texts</span>)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">foreach</span> (<span style="color: blue;">var</span> <span style="color: #010001;">text</span> <span style="color: blue;">in</span> <span style="color: #010001;">texts</span>)</pre><pre style="margin: 0px;"> <span style="color: #010001;">myManager</span>.<span style="color: #010001;">Manage</span>(<span style="color: #010001;">text</span>);</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> </pre><pre style="margin: 0px;"> <span style="color: blue;">internal</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">Program</span></pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">void</span> <span style="color: #010001;">Main</span>(<span style="color: blue;">string</span>[] <span style="color: #010001;">args</span>)</pre><pre style="margin: 0px;"> {</pre><pre style="margin: 0px;"> <span style="color: blue;">var</span> <span style="color: #010001;">processor</span> = <span style="color: blue;">new</span> <span style="color: #2b91af;">TheProcessor</span>(<span style="color: #2b91af;">ComponentFactory</span>.<span style="color: #010001;">CreateTheManager</span>());</pre><pre style="margin: 0px;"> <span style="color: #010001;">processor</span>.<span style="color: #010001;">Process</span>(<span style="color: #010001;">args</span>);</pre><pre style="margin: 0px;"> }</pre><pre style="margin: 0px;"> }</pre></div><br /><br />Note, how TheProcessor now uses ITheManager interface instead of specific implementation. <br /><br />What you do next depends on what framework for components you are going to use. If you plan to use one of the Dependency Injection frameworks out there, you will continue with other components (TheProcessor in our example) and let framework inject ITheManager dependency into constructor. If you are going to use component querying system, you will update component constructor to use factory method instead of parameters, and use <strong>Safe Delete</strong> on parameters to remove them and update usages.<br /><br />After you finish with refactoring all component access to ComponentFactory static class, you can change the implementation of factory methods to query your component framework of choice. <br /><br />Finally, you are ready for the last strike to finish it off: use <strong>Inline Method</strong> refactoring to get rid of temporary factory methods and finish conversion of your code.Ilya Ryzhenkovhttp://www.blogger.com/profile/14966746474791511643noreply@blogger.com5tag:blogger.com,1999:blog-4439386706617871322.post-53439857193493158132008-07-29T20:34:00.007+04:002008-08-12T19:41:43.858+04:00What's Next? -- Life After ReleaseWe released ReSharper 4 in June and I didn't post since then. First, I was on vacation and it was great. Then, our team left the city to spend 4 full days discussing ReSharper future, inventing new features, building plans and coordinating efforts. Awesome experience, I must say. After that, we focused on preparing maintenance release 4.0.1 which will be out as soon as we verify it against recently released Visual Studio 2008 SP1. Now we are starting to work towards 4.5 release, which is tentatively planned to be released by the end of the year, or may be at the beginning of year 2009. So, what are we going to do?<br /><br /><em>Please note, that it is preliminary plan only and is subject to change at any time.</em><br /><br />1. More performance<br />2. Less memory usage<br /><br />Yes, we are going to spend about four months tackling performance and memory issues, optimizing various parts of our product and improving architecture to prepare for the next major step forward. <br /><br />In addition to the overall product quality improvement, we are going to improve some existing features, based on your feedback, and add some new. <br /><br />3. New refactorings are being developed, which will allow you to perform more intelligent solution-wide code transformation. We didn't finalize the list yet, but most likely they will be from "Inline" family. <br /><br />4. Enhanced setup for naming conventions which will be supported by all ReSharper features. We are not going to implement all functionality of the <a href="http://www.agentsmithplugin.com/">AgentSmith plugin</a>, but we want to stop naming issues experienced by some of ReSharper users once and for all.<br /><br />5. Visual Build - new feature to display build process inside Visual Studio in a better way. Think "Unit Test Session" style, but for building your solution. This feature will also lay the foundation for future features, like optimizing build procedure.<br /><br />6. Visual Basic 9 support. Our cross-language refactorings and editing experience enhancements will fully support VB9 constructs, like anonymous functions and XML literals. <br /><br />As usual, once we perform all potentially dangerous changes to our code base and stabilize the build, we will start publishing nightly builds for your Early Access Pleasure.<br /><br />PS: If you didn't express your opinion about ReSharper 4 on <a href="http://visualstudiogallery.com/ExtensionDetails.aspx?ExtensionID=ea4ac039-1b5c-4d11-804e-9bede2e63ecf">Visual Studio Gallery</a>, you can let other people know what do you think via rating and review functionality recently added to this site.Ilya Ryzhenkovhttp://www.blogger.com/profile/14966746474791511643noreply@blogger.com42tag:blogger.com,1999:blog-4439386706617871322.post-35214676293338470522008-06-09T20:18:00.006+04:002008-06-10T01:31:02.044+04:00ReSharper 4.0 Gone DiamondHere it is, <a href="http://www.jetbrains.com/resharper/">ReSharper 4.0</a>. After faceting our diamond, we are finally ready to release it!<br /><br />In this new release, <strong>C# 3.0</strong> is supported in all its power -- lambdas, extension methods, language integrated queries (aka LINQ), object and collection initializers, anonymous types, automatic properties and partial methods. Ah, of course implicitly typed locals ("vars") are there to argue for or against using them. I already wrote about some of the features, and you can find more information on the <a href="http://www.jetbrains.com/resharper/features/newfeatures.html">New Features</a> page. Here is small final touch about how deeeeep we dived into the language: try introducing parameter from expression which uses local variables and play with checkboxes for local variables. <br /><br />Except for new language support, we also improved our product in many other ways: <br /><ul><li>We added <strong>new </strong>powerful <strong>refactorings </strong>and greatly improved existing.</li><br /><li>We extended typing helpers with <strong>CamelCase completion </strong>and <strong>Complete Statement</strong>. Now you can achieve more in less time.</li><br /><li>We analysed many .NET Framework assemblies for you, and maked them up for you with CanBeNull/NotNull attributes. And ReSharper's value analysis raised to the next level.</li><br /><li>We tested it with numerious other addons, plugins, SDKs and packages. And <strong>improved </strong>ReSharper's <strong>integration </strong>into Visual Studio ecosystem by a wonderful degree.</li><br /><li>Of course we fixed a lot of problems and eliminated many performance bottlenecks.</li><br /></ul><br /><br />I can't really enumerate all the improvements in ReSharper 4.0 made during last year. It would take too much space on this blog. <a href="http://www.jetbrains.com/resharper/download/index.html">Try it yourself</a>! Feel the difference!<br /><br /><em>develop.With(pleasure => pleasure * 4.0);</em>Ilya Ryzhenkovhttp://www.blogger.com/profile/14966746474791511643noreply@blogger.com10tag:blogger.com,1999:blog-4439386706617871322.post-23454621182942749162008-06-03T16:32:00.003+04:002008-06-03T17:55:51.807+04:00ReSharper 4.0 Release CandidateAfter extensive testing and fixing problems in Beta we are ready to publish <a href="http://www.jetbrains.com/resharper/beta/beta.html">Release Candidate</a> build. Some critical fixes can still happen in this branch, but otherwise we are almost ready to release. <br /><br />If you are using any nightly build or beta, please upgrade to Release Candidate. If by chance you find a problem that prevents ReSharper 4 from being used on a regular basis, please tell us! You can submit request into our <a href="http://jetbrains.net/jira/browse/RSRP">issue tracking system</a>, and we will try hard to fix any critical problem, if we can reproduce it. So <strong>please, please, please</strong>, include as much information about your environment, projects and source files as you can. <br /><br />Thank you very much for participating in our Early Access Program!Ilya Ryzhenkovhttp://www.blogger.com/profile/14966746474791511643noreply@blogger.com16tag:blogger.com,1999:blog-4439386706617871322.post-12407252428490930012008-05-26T22:01:00.003+04:002008-05-26T22:12:40.008+04:00Functional Style -- Highlight Mutable VariablesOnce you go for lambdas, lazy computations and other functional techniques in programming, you may want your code to be mostly <a href="http://en.wikipedia.org/wiki/Immutable_object">immutable</a>. With ReSharper 4 we didn't do much about data analysis, like do not detect immutable objects or methods. However, one analysis is already available to you: <strong>highlight mutable local variables</strong>. Open <em>Tools</em> menu, select <em>Options</em>, browse for <em>Fonts and Colors</em> under <em>Environment</em> group. In the <em>Display items</em> find <strong>ReSharper Mutable Local Variable</strong> and change the appearance as you like. I use Bold font. ReSharper will now highlight every variable that changes its value after the value has been already used. <br /><br />Try it, and tell us what do you think!Ilya Ryzhenkovhttp://www.blogger.com/profile/14966746474791511643noreply@blogger.com9tag:blogger.com,1999:blog-4439386706617871322.post-81583247224539548072008-05-21T16:34:00.010+04:002008-05-21T19:20:16.925+04:00ReSharper 4 BetaDid you use one of the nightly builds we publish for several months already? If you thought it is dangerous for you to run early development bits, today we present you <a href="http://www.jetbrains.com/resharper/beta/beta.html"><strong>ReSharper 4 Beta</strong></a>, which we optimized, stabilized and verified to be of better quality than ordinary nightlies. It is not complete product yet, we have some more work to do in various areas of product, but otherwise this build is pretty stable and usable.<br /><br /><strong><span style="color:#990000;">C# 3.0</span></strong><br />This major language update was not an easy thing to support. It was tough to make it right, when tool knows the code inside out and understands every detail of what is written. There are many little things that you probably will not even notice, but which were well thought out and implemented to provide flawless code editing, navigating and refactoring experience. <br /><br />I'd like to highlight some features: global completion for extension methods, which inserts required namespace imports; optional parameter info in form of lambda, like "IEnumerable<string> => string" instead of Func<IEnumerable<string>,string>; refactorings specific to new language features, like creating named type from anonymous one or converting static method to extension method and updating usages. <br /><br /><strong><span style="color:#990000;">.NET Framework Annotations</span></strong><br />Since version 2.5 we have "Null Reference Analysis", which is capable to warn developer about potential NullReferenceException in the code. To aid this analysis, developers can annotate methods with NotNull or CanBeNull attributes, which ReSharper then uses to initialize variable states. That's cool enough by itself, but there are thousands of methods you can't annotate in source: the .NET Framework assemblies. We took up a challenge and implemented the way to annotate libraries with external annotations. And we made second step, too. We annotated most of .NET Framework (56 assemblies!), so that you can get potential NullReferenceException warning on the code like (SomeStruct)Marshal.PtrToStructure(...);<br /><br /><strong><span style="color:#990000;">Completion-on-steroids</span></strong><br />That's something I like most. No, wait, I love new refactorings, recent edits window, to-do browser understanding of NotImplementedException, and all <a href="http://www.jetbrains.com/resharper/beta/beta_newfeatures.html">other features</a> mentioned on the official site.<br /><br />Two things: "CamelHumps Completion" and "Complete Statement" bring my coding speed to a new level. I don't know what it would be called in Jedi hierarchy, but it seems to me that I can create code with <strike>lightning</strike> teleportation speed. <br /><pre>if(CVM.I.SV(SCV.FU <em><Ctrl-Shift-Enter></em></pre>When I hit keys like above, it is completed into:<br /><pre>if (CodeViewManager.Instance.SupportsView(StandardCodeViews.FindUsages))<br />{<br />}</pre>And caret is inside braces for me to type in the body of the "if" statement.<br /><br /><strong><span style="color:#990000;">ASP.NET speed-up</span></strong><br />The last, but not least thing I'd like to mention is our raid against ASP.NET problems. It is something that had speed and memory problems through all versions of ReSharper, and we finally managed to identify them, and fix. Now, if you develop ASP.NET web sites, go try ReSharper 4 Beta. <br /><br /><strong><span style="color:#990000;">Download</span></strong><br />In this release we bring you the single installer for both Visual Studio 2005 and 2008, as well as all editions we have. <a href="http://www.jetbrains.com/resharper/beta/beta.html">Download</a>, install, select "Free Evaluation", choose edition - and you are ready to be productive.Ilya Ryzhenkovhttp://www.blogger.com/profile/14966746474791511643noreply@blogger.com3tag:blogger.com,1999:blog-4439386706617871322.post-27331625768093759592008-04-08T13:53:00.004+04:002008-04-08T18:36:03.564+04:00Extending the Extension -- ReSharper Plug-InsReSharper, the ultimate productivity tool for Visual Studio, is not just pre-packaged set of features. ReSharper provides rich platform for intelligent extensions, which can read and modify code and provide even more productivity features to you. I thought I would compile list of known public plugins. <br /><br /><strong><a href="http://www.jetbrains.net/confluence/display/ReSharper/PowerToys+Pack+3.0+User+Guide">ReSharper PowerToys</a></strong> - cyclomatic complexity analysis, explore type interface, find text, generate ToString, csUnit support. <em>Open Source</em>.<br /><br /><strong><a href="http://www.safedevelop.com/">RGreatEx</a></strong> - resource refactoring and string manipulation. <em>Commercial</em>.<br /><br /><strong><a href="http://code.google.com/p/mbunit-resharper/">MbUnit</a></strong> - support for MbUnit tests in ReSharper Unit Testing subsystem. <em>Open Source</em><br /><br /><strong><a href="<br />http://www.codeplex.com/xunit/Wiki/View.aspx?title=HowToUseResharper&referringTitle=Home">xUnit</a></strong> - support for xUnit tests in ReSharper Unit Testing subsystem. <em>Open Source</em><br /><br /><strong><a href="http://exceptionz.wordpress.com/2007/04/20/resharper-unittestsupport-add-in-for-nspecify/">NSpecify</a></strong> - support for NSpecify in ReSharper Unit Testing subsystem. <em>Open Source</em><br /><br /><strong><a href="http://www.agentsmithplugin.com/">Agent Smith</a></strong> - naming convention validation, spell checking, xml-comments validation, smart paste. <em>Open Source</em><br /><br /><strong><a href="http://code.google.com/p/agentjohnsonplugin/">Agent Johnson</a></strong> - documents exceptions, batch-annotate with NotNull/CanBeNull, favorite files. <em>Open Source</em><br /><br /><strong><a href="http://scb.udsu.ru/~achmed/arp/trac/wiki">ARP</a></strong> - log4net and NHibernate support. <em>Open Source</em><br /><br /><strong><a href="http://www.lieser-online.de/blog/?p=78">Stefan Lieser’s NHibernate plugin</a></strong> - NHibernate support. <em>Free</em><br /><br /><strong><a href="http://code.google.com/p/scoutplugin/">Scout</a></strong> - navigate to .NET Framework Reference Source. <em>Open Source</em><br /><br /><br />If you know any other public plugins to ReSharper, let us know!Ilya Ryzhenkovhttp://www.blogger.com/profile/14966746474791511643noreply@blogger.com5tag:blogger.com,1999:blog-4439386706617871322.post-59258649772553268622008-04-02T16:06:00.002+04:002008-04-02T16:10:54.507+04:00We Read You, Anonymous9 minutes ago I've received the following from anonymous user of our uninstall feedback form:<br /><blockquote><br />I am uninstalling ReSharper because my licencse is only for C# :)<br />Reinstall is waiting for me, so i can't lose my time typing some unuseful text that won't be read anyway.<br /><br />Have a good time, JetBrains Server! <br /></blockquote><br /><br />Thank you, Anonymous, I will pass this to our administrators so they can decide which server to route information to :)Ilya Ryzhenkovhttp://www.blogger.com/profile/14966746474791511643noreply@blogger.com2tag:blogger.com,1999:blog-4439386706617871322.post-54840774756538162782008-03-24T16:26:00.003+03:002008-03-24T16:31:05.664+03:00MbUnit for ReSharper 4<a href="http://der-albert.com/">Albert Weinert</a> ported MbUnit plugin to ReSharper 4 API, so you can try it with latest ReSharper 4 <a href="http://www.jetbrains.net/confluence/display/ReSharper/ReSharper+4.0+Nightly+Builds">nightly builds</a>. <a href="http://der-albert.com/archive/2008/03/24/mbunit-plugin-for-r-4.0-available.aspx">Read more</a> and download Beta 7.Ilya Ryzhenkovhttp://www.blogger.com/profile/14966746474791511643noreply@blogger.com0tag:blogger.com,1999:blog-4439386706617871322.post-37245704509695665342008-03-04T12:58:00.009+03:002008-03-04T14:41:39.729+03:00Varification -- Using Implicitly Typed LocalsWith the <a href="http://resharper.blogspot.com/2008/02/resharper-4-nightly-builds-are-you-geek.html">ReSharper 4 nightly builds</a> available, some people are complaining about numerious suggestions to convert explicit type to "var" keyword. Of course, you can hide this suggestion by using Options / Code Inspection / Inspection Severity, or by using Alt-Enter and selecting "Change severity" option. But what's the deal with implicitly typed locals, anyway? <strong>Using var keyword can significantly improve your code</strong>, not just save you some typing. However, it may require discipline to apply good practices when using implicitly typed variables. Here is my list:<br /><br /><ul><br /><li><strong>It is required to express variables of anonymous type</strong>. This is pretty obvious - you cannot declare local variable of anonymous type without using var. <br /></li><br /><li><strong>It induces better naming for local variables</strong>. When you read local variable declaration with explicit type, you have more information at that moment and something like "IUnitTestElement current" makes sense. However, when this local variable is used later, you read "current" which takes some time to figure out the meaning. Using "var currentElement" makes it easier to read at any place. <br /></li><br /><li><strong>It induces better API</strong>. When you let compiler deduce type from method return type or property type, you have to have good types in the first place. When you don't have explicit type in the initialization expression, you have to have best names for members. <br /></li><br /><li><strong>It induces variable initialization</strong>. It is generally a good practice to initialize variable in the declaration, and compiler needs initializer to infer type for local variable declared with "var" keyword.<br /></li><br /><li><strong>It removes code noise</strong>. There are a lot of cases, when implicitly typed local will reduce amount of text developer needs to read, or rather skip. Declaring local variable from new object expression or cast expression requires specifying type twice, if we don't use "var". With generics it can lead to a lot of otherwise redundant code. Another example would be iteration variable in foreach over Dictionary<TKey,TValue>. <br /></li><br /><li><strong>It doesn't require using directive</strong>. With var, you don't have explicit reference to type, as compiler infers type for you, so you don't need to import namespace when you need a temporary variable.<br /></li><br /></ul><br /><br />To summarize the list above, by actively using var keyword and refactoring your code as needed you <strong>improve the way your code speaks for itself</strong>.<br /><br /><em>PS: Visit <a href="http://visualstudiogallery.com/ExtensionDetails.aspx?ExtensionId=ea4ac039-1b5c-4d11-804e-9bede2e63ecf" onclick="javascript:urchinTracker('/outgoing/vsgallery');" >ReSharper at Visual Studio Gallery</a>!</em>Ilya Ryzhenkovhttp://www.blogger.com/profile/14966746474791511643noreply@blogger.com52tag:blogger.com,1999:blog-4439386706617871322.post-59874185229438830382008-02-20T21:00:00.002+03:002008-02-20T21:06:14.568+03:00Visual Studio 2005 and ReSharper 4 Nightly BuildsReSharper 4 should work with Visual Studio 2005, and it will support C# 2.0 language features. If you happen to participate in our early access program, and you are using Visual Studio 2005, please note that you have to have <strong>.NET Framework 3.5</strong> installed.<br /><br />Also, we would be happy if you were reporting any features that belong to C# 3.0 but appear in Visual Studio 2005, like suggestions for lambdas or var. Please read information about our <a href="http://www.jetbrains.net/confluence/display/ReSharper/ReSharper+Issue+Tracker">issue tracker</a> beforehand. <br /><br />Thank you.Ilya Ryzhenkovhttp://www.blogger.com/profile/14966746474791511643noreply@blogger.com8tag:blogger.com,1999:blog-4439386706617871322.post-58661014357203208512008-02-18T18:49:00.004+03:002008-02-18T19:30:17.094+03:00Better Development Tools -- Building TogetherDear early adopters!<br /><br />We thank you kindly for your participation in ReSharper 4 early access program. It is going to be wonderful release for everyone, because of you. This time we receive the best response ever, and we are so excited about it! <br /><br />Many brave developers, who are trying ReSharper 4 early builds with Visual Studio 2008, registered in our <a href="http://www.jetbrains.net/confluence/display/ReSharper/ReSharper+Issue+Tracker">issue tracker</a> and provided us with detailed, specific and very important information. This is really great, because we were able to reproduce many issues that were lurking around our code base for some time now. It is very important that you registered and provide us with non-anonymous feedback: bidirectional communication is at least 16 times more effective than one way exception submitting. One sample solution which manifests the problem is 256 times better than 1024 exceptions without a comment. And it is invaluable when you submit instructions to reproduce the problem (well, at least var value = int.MaxValue). <br /><br />Thank you very much, we really appreciate your effort! With that kind of feedback we receive today, I believe we can build the best release of ReSharper, ever. Everybody wants better tools, right? ;)<br /><br />Sincerely Yours, Ilya.Ilya Ryzhenkovhttp://www.blogger.com/profile/14966746474791511643noreply@blogger.com5