Tag Archives: ReSharper

ReSharper and Express.js Workshop at GOTO Aarhus

This October, we will be holding a ReSharper hands-on workshop as part of the GOTO Aarhus conference, organized by our partners Trifork.

  

The workshop is focused for developers that are already familiar with ReSharper. We will take a look at how to use ReSharper effectively to its full potential, covering some of the less known features as well as understanding how to customize things to suit different needs. But we won’t stop there. A good portion of the workshop will be dedicated to extending ReSharper by writing your own plug-ins. You’ll see how to leverage our platform to have deep insight into code, gain access to analysis and refactoring calls and easily extend your favorite tool with custom functionality.

 

In addition to this workshop, I’ll also be offering another workshop on Web Development with Express.js, a Sinatra-inspired web framework for node.js. You’ll not only learn about Express.js and node.js, but also how to effectively use WebStorm, our JavaScript and HTML IDE.

  

The conference itself is one of the largest in Denmark and hosts a variety of tracks ranging from specific technology and languages, to process and human interactions, providing a rich and excellent choice of topics.

For more information about the workshops:

 

Registration and Promotional Discount

In collaboration with Trifork, we are offering a 100 Euros discount off of the registration price. When registering for the conference enter the promotional code jetbrains2012. The workshops are limited in seats, so do sign up if you’re interested in attending. To Register click here.

 

 

Note: You do not need to attend the conference to sign up to the workshops.

 

Hope to see you there!

 

                

      fdfdd

Switzerland Visit

 

This summer we will be visiting two User Groups in Switzerland to talk about some of our tools among other things.

The events are organized in collaboration with the local User Groups of Berne and Lucerne:

 

If you’d like to attend the event, I’d recommend you sign up as places are limited.

Berne

Date: Tuesday 3rd July – 6 to 9 pm

Topics:

     ReSharper Tips’n’ Tricks

     Real World MVC

 

Registration, Location and more info: User Group Web Site

Lucerne

Date: Wednesday 4th July – 6 to 8:30 pm

Topics:

     ALM with JetBrains Tools (covering TeamCity, YouTrack et al.)

     Real World MVC

 

Registration, Location and more info: User Group Web Site

 

 

All registrations are handled directly by the user groups. Please contact them (via their web site) if you have any issues.

 

 

Hope to see you there!

Providing Intellisense, Navigation and more for Custom Helpers in ASP.NET MVC

 

You probably are aware by now that as of ReSharper 5 we added first-class support for ASP.NET MVC. This included among many things, the ability to provide Intellisense, Create from usage and Navigation to built-in methods such as Controller.View or Html.ActionLink:

 

Navigation

Ctrl+Left Mouse Click or F12 will navigate to the corresponding View

 

image 

 

or to the Action and/or Controller

 

image

Intellisense and Create From Usage

Ability to have Intellisense when providing Actions/Controllers

 

image

 

as well as the possibility of creating from usage

image

 

However, what happens when you want to use a custom function, for instance, a better ActionLink or your own View method? Did you know that you can still get all these goodies? All you need to do is use some Annotations.

Using JetBrains.Annotations

ReSharper uses annotations via the form of .NET attributes to figure out what an ASP.NET MVC View, Action or Controller is. As such, all we need to do for our custom method and extensions to leverage this, is tell ReSharper what parameter corresponds to what.

 

Referencing the annotations

To use ReSharper annotations, we have mainly two options (with a third one hopefully coming soon):

1. We can include the library JetBrains.Annotations.dll in our project and reference it.

2. We can copy the annotations and include it as source in our project

[3. We can use nuget install-package JetBrains.Annotations] Coming soon!

 

The first option is pretty simple. The DLL is located in the ReSharper installation bin folder. For the second option, we open up ReSharper | Options and select Code Annotations entry

 

image

 

select the Copy default implementation to clipboard button and paste into an empty file.

 

Annotating custom methods

Once we’ve completed this step, all we need to do is annotate our parameters with the correct attributes. We’re interested in 3 different attributes in particular:

 

  • AspMvcView which indicates the parameter is a View
  • AspMvcAction which indicates the parameter is an Action
  • AspMvcController which indicates the parameter is a Controller

 

Here is the header corresponding to a base controller with a custom method named ExtendedView

 

image

 

and here’s the header for a custom ActionLink

image 

 

(the body of both methods are omitted and are not necessary to demonstrate the functionality)

 

As soon as we do this, ReSharper picks up these methods and offers us the same functionality that is provided for the methods that ship out of the box:

 

image

 

Notice how we still get Navigation (the underlining), Intellisense and Create from usage in our TheOnlyActionLink custom method. Its much the same for the ExtendedView method

 

image

 

That’s all there is to it.

Australia: First Contact

 

image

 

We have a lot of users in Australia, yet we’ve never managed to get out over there for a conference. That’s about to change. Next week, myself and Sergey Coox (ReSharper Project Manager) will be heading to the Gold Coast for TechEd Australia. We are sponsoring the event as well as having a booth present. It is going to be a great opportunity to see and talk first-hand to our users and also a personal chance to get to see (albeit very little) of Australia. We will ship a few hundred “I see dead code” T-Shirts also, so make sure to stop by the booth to pick yours up.

ReSharper Tips and Tricks Demo

We’ve managed to secure one whole hour at the Create Demo Booth that will be in the exhibit area to hold a ReSharper Tips and Tricks session, similar to those that have taken place at other conferences. This will take place on Thursday 1st of September 1 pm – 2 pm. It will be somewhere in the Exhibitor area. Pass by the booth during the week for more details.

YouTrackSharp and YouTrackForReSharper on JetBrains GitHub

Just a quick note to say that I’ve transferred the YouTrackSharp project from my own account over to the JetBrains account on github. I’ve also pushed the initial spike of YouTrackForReSharper which is a plug-in for ReSharper to talk to YouTrack. We’re looking for contributors for this project, so if you’re up to it, fork away!

File Header Macros in ReSharper 6

Sometime ago I wrote about Automating File Header Information, showing how to insert license information and other data in project files. One of the shortcomings ReSharper had however was the inability to support macros. Something as simple as inserting the current year or filename required the support of StyleCopy for ReSharper. ReSharper 6 now support macros allowing file headers to contain varying information:

SNAGHTML13afe47c

For instance, in the previous license header, the Copyright years are fixed to 2010 – 2011. It also has no information relevant to the actual project. We could of course hardcode the name of the project in there but since this setting is not solution-specific, it would be of little use. Other data such a filenames however would be impossible to do.

With ReSharper 6 we simply remove the hardcoded values and replace them with macros. We can either type them in or click on the corresponding macro, which will insert it at current cursor position:

image

With this change in place, next time we run a code-cleanup and have the Update File Header option activated, we will get up to date and project/file specific header information inserted. Next feature request: Custom Macros!

ReSharper 6 is Released!

We are extremely happy to announce the release of the new ReSharper: please download ReSharper 6 right now.

With this new release, we have gone way and beyond merely providing new features. We have added support for not one but three new languages: JavaScript, CSS and HTML, plus ASP.NET MVC 3 Razor view engine, making ReSharper 6 and Visual Studio one of the best environments today for developing web applications. In addition we also have implemented code analysis for Visual Basic .NET.

The features however aren’t limited to just new language support. Earlier in the year, we announced our new decompiler, which is built in to the core of ReSharper 6, providing integrated decompiling inside Visual Studio. Built on the philosophy of external sources, ReSharper 6 facilitates navigation of source code, whether it belongs to our solution, the .NET framework or any third party library. We also announced the availability of a new free standalone decompiler tool, which is currently in Early Access Program.

ReSharper 6 also provides a wealth of rich features for all language lovers. From new in-place refactorings, to enhancements in navigation and unit testing, new code transformations, code inspections for C#, improved XAML support, ReSharper 6 provides something for everyone.

If you prefer watching over reading about the new features, here’s a fresh screencast for you.

Also, we have previously blogged about some of the new features of ReSharper 6, and we’ll be keep doing that after release.

We have also opened our Early Access Program for dotCover 1.1.1 and dotTrace Performance 4.5.1 which are compatible with ReSharper 6.

We truly hope you enjoy this new release and know that we have already started working on the next version. As always, we’d love to hear your feedback.

Preventing Items from being analyzed in ReSharper

With the imminent release of ReSharper 6, and support for JavaScript as well as CSS, we’ve had a few people ask us how to prevent ReSharper 6 from detecting issues in certain files that are not supported, for instance .less. Although many operations are available for these types of files, including “Move To Folder” (and consequent reference updates), analysis is not currently available.

Eliminating Items from Analysis

ReSharper allows us to completely exclude specific files and folders from Analysis. Currently, it does not support file masks, so we cannot tell it to ignore all *.less files. What we can do however is place all files of a certain type into a folder and add that folder to be excluded. To do this, we first move the specific files by using the “Move To Folder” refactoring and create a new folder called less for instance (which can be created using the same dialogue box).

In order to now exclude this folder, we need to go to ReSharper | Options | Code Inspection |Settings

SNAGHTML2c0fc9

and click on the Edit Items to Skip button.  This now provides us the ability to add specific files and/or folders to list of items to skip.

SNAGHTML2d02ce

We then click on Add Folder and select the newly created folder (less).  Once we do that, all analysis on the skipped items will stop. Obviously this is available for any kind of file so you can add anything there.

Note: You can also add/remove files and folders quickly by pressing the shortcut key Ctrl+Shift+Alt+8.

In the case of CSS/.less, if you still see squiggles under certain elements, that is Visual Studio error highlighting, not ReSharper. You can turn that off using Tools | Options | Text Editor | CSS | Miscellaneous.

Generated Code

Below the previous menu option, there is another entry Generated Code:

image

How is this different from the above? The entries on this page, which do allow masks (as well as regions), do get analyzed, yet no hints, warnings, suggestions or quick fixes are offered since it does not make much sense. However, and this is important, files still do get analysed to provide error information and completion. This is what makes Generated Code different from Items to Skip.

Note: In ReSharper 6 and below, Generated File Masks and Generated Code Regions are GLOBAL and not Solution based. However, they can only be edited when a solution is open. This will be solved in a future release along with other improvements in the area of settings across solutions/projects.

ReSharper 6 enhances the JavaScript experience

We already mentioned some of the benefits that ReSharper brings to the table when it comes to JavaScript development previously. In this post we are going to have a more in-depth look at some of the features.

Pimping jQuery

In addition to support for JavaScript, ReSharper 6 also provides certain functionality specific to jQuery.

Code Completion for Selectors

When working with jQuery selectors we often need to lookup certain DOM elements or CSS classes in order to operate with them. This can result in a back-and-forth between the code we are working on and looking up of a specific element. ReSharper 6 facilitates these cumbersome operations by providing code completion for selectors:

image

This completion is invoked by typing # between the quotes, where as if we were to type ., we’d get:

image

This completion is available anywhere we a selector is required.  Of course if we merely want to select a specific type of element, we also have completion:

image

Extending jQuery extensions

One of the benefits of jQuery is the ease by which we can extend it to add our own functions and methods. ReSharper enhances this experience by providing completion also for custom extensions. For instance, if we were to write a new extension:

image

we now have myFoo available as a method of jQuery:

image

Much in the same way, if we want to extend an object:

image

we have:

image

Importing File References

Out of the box, Visual Studio requires a special comment to be added to script files to provide support for IntelliSense:

image

With ReSharper this is not required. If however, it is included, ReSharper will then limit the scope of Intellisense to the reference added. This reference can be provided by directly typing it in, in which case ReSharper offer completion:

image

as well as providing quick-fixes when errors are detected in paths:

image

Creating from Usage

Similar to C# and VB.NET, we can now also create JavaScript code based on usage. For instance, let’s say we write some code that calls a specific function named getInterval that does not yet exist. ReSharper prompts us to create a local function:

image

generating the code for us, providing us the same ability we have in C# to iterate through parameter names etc. The same applies to variables:

image

as it does to creating parameters and properties; once again, making the whole development experience a bit smoother.

Last but not least, ReSharper also provides the ability to create jQuery extension methods from usage:

image

Refactoring

Certain refactoring operations are now available in JavaScript. Firstly, in combination with Create from Usage, we can now easily add an extra parameter to a function call and have ReSharper offer to create it for us:

image

Introduce Variable is another refactoring option available:

image

And last but not least, Renaming:

image

ReSharper is smart enough to handle the scope of the renaming outside of the current local scope, prompting you always with the option to fine-tune certain renaming’s.

Code Clean-up and Rearranging.

In a previous blog post we mentioned briefly the code formatting options for JavaScript. These have now been extended and better organized. We can fine tune Lines Breaks, Braces Layout as well as Space via ReSharper | Options | JavaScript | Formatting Style. Below are the options for the newly added Spaces:

image

Running code-cleanup on JavaScript files is of course now also possible:

image

Also, out of the box, we provide certain filters, both in clean-up and analysis, such as those with min.* extensions. These can be changed in the options dialog, albeit it’s not highly recommended.

image

Rearranging Code

You can now rearrange code which includes moving parameters around, moving members up/down as well as arguments and object literals and arrays. All this is done using the same key combination as used in C# and VB.NET (Ctrl+Alt+Shift + Cursor Keys).

Code Inspections

JavaScript is a dynamic language. It has great advantages but can prove to be not the easiest language to work with, specially for novices. We’ve tried to ease some of that pain by providing code inspections, where possible. Among the many code inspections that currently are available are:

Syntax errors

image

Unused symbols

image

Dead code

image

Duplicate switch statements

image

Misuse of “this”

image

Accessing undefined global symbols

image

And this is just a few of the over 25 inspections that ReSharper supports along with their corresponding quick fixes. We believe that this will help remove some of the issues encountered at runtime, specially by newcomers.

Miscellaneous

Some of the other features provided for JavaScript are:

  • Configurable Naming Conventions: Much like C# and VB.NET you can define your own naming conventions.

image

  • Comments: Ability to comment and uncomment blocks of code as well as support for XML Documents.
  • Context Actions Settings: You can fine-tune which of context actions you want enabled.

image

  • Live Templates:  Support for Live Templates
  • Navigation and Find Usages: Navigation support as well as Find Usages for JavaScript members, some of which was already covered in a previous post.
  • Coding Assistance: Also covered in previous post.

All in all, we hope that some of these features allow JavaScript to become a language to that easier to learn, use and enjoyable.

ReSharper 6 is currently in EAP. Download it today and start playing with it. We’d love to hear your feedback.

Webinar: Working with TeamCity, YouTrack and an OSS Stack

On Tuesday, 5th April 2011, I’ll be giving a webinar (in Spanish) on how to setup an environment with TeamCity, YouTrack and your favorite OSS tools and frameworks.

Things we’ll see:

  • TeamCity: Overview and benefits
  • YouTrack: Mouseless Web Issue Tracking
  • Introduction to Distributed Version Control Systems and benefits over Centralized
  • Creating Continuous Integration Processes with TeamCity and OSS stacks
  • Integration with Visual Studio and other IDE’s

The webinar will be roughly 2 hours and it will be mostly demo-centric.

It is a completely free event. If you’d like to attend, please register here