Friday, December 26, 2008

And so it begins

Resharper 4.5 nightly builds have started:

http://www.jetbrains.net/confluence/display/ReSharper/ReSharper+4.5+Nightly+Builds

Eugene Pasynkov wrote:

"Please note, that they could be instable or not work at all. We don't plan
stable EAP builds in near future. We have to do a lot before we begin
stabilization
phase. However, we use current development builds all the time, so any
critical
problem will most likely be fixed within a day or two. After all, we are
going to open public builds because YOU asked for it :)"

Tuesday, December 2, 2008

Thanks

I just want to thank dmitrinesteruk for providing a lot of feedback on Agent Johnson.

I am still amazed that people actually test or use Agent Johnson!

Resharper 4.1 and 4.5

Ilya on Resharper 4.1 and 4.5:

"4.1 receives only critical hotfixes, mostly when VS crashes or otherwise completely fails to work. We are actively working on 4.5 and going to open EAP pretty soon. Stay tuned."

Monday, November 10, 2008

StyleCop for Resharper

The new version of the StyleCop for Resharper is a real treat. It fixes two of my main gripes with the previous plugin - you can now set inspection severity for each violation and it includes fixes for some of the common violations.

Thursday, November 6, 2008

Resharper 4.1. PowerToys

Good news.

The PowerToys for Resharper 4.1 has been released.

The PowerToys plugins are installed in C:\Program Files\JetBrains\ReSharper\v4.1\Bin\Plugins\ and the source in C:\Program Files\JetBrains\ReSharper\v4.1\vs9.0\PowerToys\.

Monday, November 3, 2008

Dead forums

Wow - the Resharper forums are as dead as I have ever seen them.

One of my co-workers went to the PDC and talked to JetBrains at their booth, but I don't know what they talked about unfortunately.

Tuesday, October 21, 2008

Clone Detective

Clone Detective is a plugin for Visual Studio - not Resharper - that searches for duplicate source code in a solution.

From the website:
"Clone Detective is a Visual Studio integration that allows you to analyze C# projects for source code that is duplicated somewhere else. Having duplicates can easily lead to inconsistencies and often is an indicator for poorly factored code."

It is pretty similar to an idea I had for Agent Johnson, but this one actually works. I played around with it, and while I had some difficult getting it to find my files, it seems to find work.

Resharper nightly builds

It looks like Resharper nightly builds are up and running again after a long hiatus.

I haven't installed it, but it seems to be mostly fixes and no new features.

I wonder if they are using TeamCity now.

Monday, October 20, 2008

StyleCop Plugin for Resharper

The StyleCop plugin has been added to the list of plugins for Resharper on JetBrains homepage.

Wednesday, October 8, 2008

Neovolve plugin

While researching ICodeCleanupModule I found the Neovolve plugin by Rory Primrose.

From the description:
"...This formatting function allows for type declarations to be formatted between their alias type and their CLR type. For example, depending of the format settings defined in a code cleanup profile, bool can be converted to Boolean or Boolean converted to bool."

Sounds cool.

SharpProbe

Just stumbled across SharpProbe which is apparently a plugin to help write plugins.

I have no idea of how it works.

Tuesday, October 7, 2008

Agent Smith 1.3.2

Just saw that Agent Smith 1.3.2 is out.

Resharper 4.5

Ilya on Resharper 4.5:

"4.5 build is not stable and is being under continious refactoring. We don't have specific date set for opening public nightly builds yet. I'm pretty sure it will not be public in October, though."

Agent Johnson 1.5.0

Just uploaded version 1.5.0.

And documented some of the new stuff.

I am always hesitant to upload new stuff as I always know that there are things that could be better. But sometimes you have to let it go and see what happens.

BlinkCode

BlinkCode is a large set of Resharper Live templates. They were made for Resharper 3.1, but it looks like they still work for 4.1.

Sort Switch Cases

I have implemented a small context action that sorts the cases of a switch statement. This is only applicable if the type of the switch statement is a string, enum or integer.

And I may have forgotten to blog about the convert abstract to "normal" class refactoring. This refactoring removes the abstract modifier from the class and converts all abstract methods to virtual.

.Net Code Inspection 1.5

SafeDevelop released 1.5 of the .NET Code Inspection plugin.

Great stuff, if you ask me.

Friday, October 3, 2008

Make Abstract Context Action

Ole asked me to do context actions that make a method abstract or virtual.

It turned out that Resharper already had a context action for making an abstract method virtual, but not the other way around.

So I have implemented the "Make abstract" context action for methods and properties.

I have also fixed some bugs in Smart Generate and Check Assignment To String.

Wednesday, October 1, 2008

StyleCop

Well, I may not like StyleCop, but my company is definitely moving in that direction. So Ole and I are working with StyleCop this week.

I am pretty amazed that Resharper can be configured to support 99% of StyleCop without requiring plugins or patches. That says something about the flexibility of Resharper.

There are 2 issues that we cannot get to work:

1) Inserting the required File Header comment at the top of the file. If you set up a File Header in Resharper and run Reformat Code, it will simply overwrites the file header each time. The work-around is to have a Live Template to insert the File Header and not have Resharper update it when reformatting code.

2) Blank line between get and set accessors in a property. You have to do this manually. To me this is just a stupid rule in StyleCop, but I have to live with it.

I'll post our Code Style and Type Member Layout as soon as it is done.

Sunday, September 28, 2008

New Features

I had a lot of fun this weekend.

Added a context action to negate the condition of an 'if' statement. This does not keep the semantics of the statement, but just applies a 'not' operation to the expression.

Added a context action and a live template macro to pull the parameters of the containing method to the caret position. This is useful when you have to pass a set of parameters on to another method.

Added a Implement ICloneable refactoring.

Added a Implement proxy class refactoring.

Added using() statements to the scope analysis in Smart Generate.

Considered adding a Implement IEnumerable refactoring, but as far as I can see, it wouldn't be very helpful, as most of the code could not be auto generated.

Considered how Document Exceptions could be extended to allow more than one description per exception. In the MSDN documentation, descriptions are separated by and "-- or --" text. But I'll have to think some more about this.

An usual amount of work for a weekend.

Tip

To convert from an IClassDeclaration to an IClass, do this:


IClass cls = classDeclaration.DeclaredElement as IClass;


And as always remember to null check afterwards.

Saturday, September 27, 2008

Tip

To get the IElement at the current caret position, do this:


IElement element = TextControlToPsi.GetElementFromCaretPosition(solution, textControl);


The TextControlToPsi class is located in the JetBrains.Resharper.IDECore assembly.

Thursday, September 25, 2008

StyleCop Plugin for Resharper

I do not really like StyleCop, but I like that there is a plugin for Resharper to use it.

StyleCop Plugin for Resharper

ReSharper Plugins

Here is a nice overview by Rob Smyth for those who want to learn the arcane art of ReSharper plugin development:

ReSharper Plugin

Using Smart Generate

I am just amazed at how well Smart Generate works.

Here is an example:

Whenever I write use a string, that is visible to the user, I need to run it through a Translate.Text method, e.g:


output.Write(Translate.Text("Visible output"));


However writing the call the Translate.Text is tedious, so I want to put that in Smart Generate.

First I write the statement with out the Translate.Text call.


output.Write("Visible output");


I place the caret on top of the string literal, and press Shift+Enter, which brings up the Smart Generate menu.

From the menu I select "Create Live Template" and then "Surround String Expression".

ReSharpers Live Template Editor opens and I name the Live Template "Translate string". The code of the Live template is:


Translate.Text($SELECTION$)


Save the Live Template and return to original code.

Press Shift+Enter to show the Smart Generate menu and select "Translate string".

And bingo, I have:


output.Write(Translate.Text("Visible output"));


Never have to write another call to Translate.Text manually again.

Big smile!

Saturday, September 20, 2008

Tip

Here is how to create an IDeclaredType instance from a string:

string typeName = "System.ISerializable";

IDeclarationsCache cache = PsiManager.GetInstance(solution).
GetDeclarationsCache(DeclarationsCacheScope.SolutionScope(solution, true), true);

ITypeElement typeElement = cache.GetTypeElementByCLRName(typeName);

IDeclaredType declaredType = TypeFactory.CreateType(typeElement);

New Features

Implemented "Implement IDisposable" refactoring.

Implemented "Implement ISerializable" refactoring.
It does not handle superclasses that already implement ISerializable, which it probably should.

Not sure if these are refactorings or generators.

Anyway this will bump the next version number to 1.5.

New Installer, a Fix and an Idea

Changed the installer from the Visual Studio Installer to WiX. Shamelessly ripped it from Agent Smith.

Added a Value Analysis check to Assignment Check Smart Generate. Pretty difficult as I needed to temporarily insert an if statement at the caret to get an IReferenceExpression, run Value Analysis, and then cancel insertion. Worried about performance.

Considered how to detect code similarites to highlight common code blocks. Common code blocks could be extracted into methods which would increase maintainablility.

Each important element of a code block; statement, invocation, assignment etc. could be represented as an integer. A code block would then be a list of integers. I could then use Levenshtein distance to compute the difference between two code blocks. If the distance is small, the code blocks are similar.

It is a nice idea, but probably not workable in real life.