02 July 2007

Of Tools and Languages

People often discuss tools for languages, often discuss languages, but rarely discuss languages for tools. If you haven't checked the NBL - The Next Big Language - go read it. Until, of course, you don't care about new languages. Here is small quotation:

Most programmers don't realize how often they need to deal with code that processes code. It's an important case that comes up in many, many everyday situations, but we don't have particularly good tools for dealing with it, because the syntax itself prevents it from being easy.


Being tool developer myself, I must say that it is often extremely hard to make desired feature. Not that it is hard to implement the feature, but rather understand how it should work in a particular language and how to "fix" the language. Few examples to illustrate the problem:

Braces in C#
C# block delimiters are braces, symbols "{" and "}", and they are used everywhere, and thus has context-dependent semantics. For a class body they surround methods and properties; for a method they designate start and end of implementation code; inside method they are used for conditional and loop blocks. The problem is that they can easily become unmatched, and thus closing braces change their meaning. The one which was at the method end suddenly becomes closing brace for the loop, method borrows its closing brace from class and all the code looks broken. ReSharper's code analysis goes crazy and highlights the rest of the file in red.

Note, that we don't have such problem in Visual Basic .NET, because we have different "braces" for different constructs and we can detect unmatched "brace" early. However, VB.NET has own problems...

Name suggesting in VB.NET
ReSharper always had name suggesting feature for C# - when you have name of the type in the editor plus space and hit Control+Space you're presented with generated names for local variable or field:



Those names are generated from type name to the left. Note the order - type name first, than declaring symbol name. In VB.NET the order is the opposite. You first give name to the declaring symbol and then specify what type is it.

ReSharper can't help you find the type for the specified name, it would be too slow. We have to invert the order, and we do so by providing "dim" Live Template:



We have similar problem in C# with interface implementation, actually.

So what?
No modern software development process can exist without tools. Continous integration and version control, refactoring and code editing, error detection and code analysis - all these require tools. If the language doesn't support tools, tools cannot support language very well. It requires significant effort to develop tools for unfriendly language and thus less tools appear on the market. At times tool vendors attempt to "fix" language editing expirience with techniques that are not natural to the language itself, because at some moment they need information not typed in yet. In order to get maximum information about developer's intention, we create special features for each intention (like "surround with") instead of understanding what is being typed; just because language forces us to do so.

That said, if you are creating your own language, or even the Next Big Language, be sure to consider tools as a major thing influencing language design.

29 June 2007

ReSharper Critical Update 3.0.1 is Out

As you've probably noticed, we had some nasty bugs which prevented some people from enjoying great new features of ReSharper 3.0. We addressed most of the critical issues in about a week and here is the result: ReSharper 3.0.1 which you can get on the official download page.

If you had problems with ASP.NET user controls, To-do Explorer, Unit Testing or any of these bugs -- you may want to give another try with ReSharper 3.0.1

25 June 2007

ReSharper Curious Facts - Unit Testing

ReSharper 3.0 was released after passing 8518 tests. It took the total of 1 hour 46 minutes to compile, run all tests, prepare help, build installation packages for all three editions, package sources and binaries for archiving -- all without user interaction, automatically by TeamCity.

21 June 2007

ReSharper 3.0 Live!

ReSharper 3.0 is released!

ReSharper Curious Facts - Ancient Request

Oldest request fixed in ReSharper 3.0 is number 2235, the one about intellisense in app.config files, originally filed on May 06, 2004. Interesting, it was me who submitted it when I was not working at JetBrains but already loved ReSharper and used it in my daily work.

19 June 2007

ReSharper 3.0 for C# Developer

While I have a few spare minutes before reviewing another document being built for web site, marketing and such, I'd like to share brief list of new features in ReSharper 3.0 that will help C# developers to be even more productive. This list is not complete and doesn't go into details about ASP.NET support or XML and XAML features. Instead, these are core C# language productivity boosters that can be used immediately in any C# project.

Go to Symbol -- navigate to any type, field, method, property or event by its name. Of course, camels are here with their humps ready to save you some typing.

Go to next or previous error -- skip warnings and suggestions and put caret immediately on the red code.

Automatic type member layout -- sort and group fields, constructors, properties, inner types, members implementing interface and other members when your reformat code. You can specify custom code layouting patterns in options dialog.

Smart Completion -- smart-complete type arguments and type parameters, infer types and suggest applicable symbols. Also, a nice little helper to give the name to unnamed exception in catch block when smart-completing in place where Exception is expected.

Advanced type choosing -- in refactorings and other places where you have to enter type name ReSharper now provides experience similar to Go to Type.

Find symbols referenced in type or method -- useful for getting big picture about what is using inside a type or method, and drill-down to details in familiar Find Usages style.

Find dependent code -- an advanced version of former Find Module Usages command, which is capable of searching code depending on specific project throughout the solution. If you need to find how particular assembly reference is used (or not used), invoke it on reference in Solution Explorer.

Filter found usages of attributes -- attributes has two distinct categories of places where they are used. One is where they are applied to an entity and the other is where they are analysed via GetCustomAttributes() methods. If you work with attributes a lot, you will find new filter in Find Usages saving you a lot of browsing time.

Highlight usages of expression -- select expression and see where the same expression is used in a method or in a file.

Improved Type Hiearchy -- member preview pane for selected type and two new view modes for deep hierarchies. One mode shows instantiatable types of the hierarchy as roots and their bases as subnodes. The other shows leaf interfaces - those that have only classes as derived types.

Moving things around -- no need to copy/paste code in order to move statement few lines below, move out of "if" statement or push into "for" loop. Much like manual member reordering, which of course still works. Can reorder enum members, though it is not always safe - know what you are doing. Reorders parameters though not changing call sites - thus not a refactoring. Works in XML to reorder nodes too.

Generating equality -- when generating Equals & GetHashCode, you can now optionally generate equality and inequality operators, implement strongly typed IEquatable interface.

Improved Stack Trace Explorer -- now highlights types, methods and source code paths, deals better with broken stacktraces, works for localized stacktraces. Also doesn't show "paste" dialog - less one key to hit.

Generate from Solution Explorer -- hit Alt-Ins while you are on the folder, file or project in solution explorer and bring instant New File From Template menu. Combine with new Locate in Solution Explorer action to find your currently open file in Solution.

Unit Test Explorer -- browse all unit tests in solution, form arbitrary set of tests, multiple sessions with different sets (with simultaneous run!), better output presentation, and the foundation for more features in future versions.

To-do Explorer -- keeps an up-to-date list of comments matching specified patterns for the whole solution, like "TODO:", "BUG:" , "To John:", "Don't forget to remove it before release!" and so on. Processes comments in C#, VB.NET, XML, XAML and ASP.NET pages (both HTML and code).

XML support -- enables almost all editor enhancement in XML files, like expand/shrink selection, highlight and navigate to matching tag, move tags, split and join, replace tags and attributes. Provides type completion and can automatically insert assembly qualification to avoid annoying typing in files like app.config.

Custom string.Format methods -- tell ReSharper about your own format-like methods and get full featured analysis, context actions and quick fixes for them.

New code inspections -- more checks for redundancy, useful suggestions and warnings. Supports #pragma directives and project settings to suppress warnings.

New quick fixes and context actions -- less manual typing, more focus on your primary task. New quick fixes provide alternative ways to fix errors, remove redundancies and deal with type parameters and constaints. New context actions give you more power for ad-hoc code transformations.

So, these are highlights. Complete list will be available short after ReSharper 3.0 is released - either on official site or here, in my blog. There are many subtle changes and nice little additions that make up the product. I don't know some of them myself! But I strongly feel that ReSharper 3.0 is another step up to the ideal development environment.

Develop with pleasure!

ReSharper 3.0 Release Candidate 2

I'd like to give our big THANKS to those brave people who tried out Beta, Beta2 or Release Candidate, provided invaluable feedback and revealed blocking problems in the upcoming ReSharper 3.0. We really appreciate your effort and doing our best to fix bugs and problems breaking your productivity and flow.

We have a new RC2 build published for you. I ask you to download and try the build.

17 June 2007

ReSharper 3.0 Release Candidate

We are getting really close to ReSharper 3.0 release so we have a Release Candidate build published for you. It has LOTS of improvements over Beta2 particularly in language-specific editions. I recommend everyone to download the build. This might well be your last chance before relase to make sure it works perfectly for you.

Consequently, I will have more time for blogging next week, so if you have some particular topic in mind you would like me to write about -- drop me a comment.

16 June 2007

ReSharper 3.0 - Coming Soon

It's been quite a while since I wrote about ReSharper features, but there was a reason -- we are building final bits of ReSharper 3.0. We passed not-so-good Beta milestone, a much better Beta2 update and currently working on last changes for Release Candidate. If you didn't yet try ReSharper 3.0 pre-release builds -- download almost-release-quality Nightly Builds now and tell us what do you think!

Note: ReSharper 3.0 Visual Basic .NET edition has known problems with ASP.NET.

23 May 2007

Jedi Way - Coding in Reverse

It looks like "ReSharper Jedi" term is beginning to spread! So here is ReSharper Jedi Code, converted from original Jedi Code:

ReSharper Jedi are the guardians of quality and productivity in the .NET world.
ReSharper Jedi use their powers to improve and advance source code, never to degrade.
ReSharper Jedi respect all developers, in any language, with any tools.
ReSharper Jedi serve others rather than ruling over them, for the good of the .NET world.
ReSharper Jedi seek to improve themselves through knowledge and training.


So what would be the major skill ReSharper Jedi should master? I think it is Coding in Reverse. This technique is widely used in test-driven development, I believe. However, it is so effective that every developer should master this skill regardless of programming style. Main principle could be described as follows:

Use Before Declare.


1. Learn to like red code.
2. Always begin with expressing your goal.
3. Deredify your code.

There is one thing to dislike, though. Automatic completion as you type doesn't work well when there are undefined symbols. However it seems to be more about lack of support in tools than fundamental limitation of the technique.

Let's see how does it work.

Code in red indicates unresolved symbols which are just not there yet. At this point I can easily continue writing code for Main method and change my mind any time.


I've expressed my goal pretty well. See how I changed CommandLineParameter to ICommandLineParameter, when I decided that interface would be better. Also, I was able to use "foreach" Live Template to iterate over collection of undefined type.

Okay, now I have to deredify my code and create some methods and types. Where is my light saber bulb and powerful quick-fixes?


Now we need to fill methods with real code, and I will show how to use the Force by implementing ParseCommandLine. We again begin with typing our goal:


Several keystrokes, quick fixes, live templates, some typing and we get to another point:


I use the Force and create class which not only contains required constructor, but also implements interface!


I leave it as an exercise to finish the sample code for anyone who want to practice this technique. Implement ProcessParameter by using some ICommandLineParameter members before declaring them, then quick-fix your way into declaring them, then use Jedi skills and implement members on the SimpleParameter.

Have fun and may the Force be with you!

Note: Some or all of the features mentioned in this article may be available only in latest EAP versions of ReSharper.