Author Archive

ReSharper 8 EAP Build: JIT Edition

Thursday, May 30th, 2013

Well it’s here. With only one day left for the previous EAP to expire, we’ve managed to get a new EAP build. All is fine. Download the latest EAP now. Let’s see what’s in store in this build.

Move Instance Method Refactoring

This frequently requested refactoring allows moving instance methods from one class to another. Take the sample class below:

Before applying Move Instance Method refactoring

We can see that the Print method uses an instance field. Invoking an Move Instance Method refactoring on this method results in ReSharper prompting us for the destination class we want to move the method to. However, in addition to moving the method, it also wraps the field, in this case with a property, and passes in the current class as an argument to the method, resulting in

After applying Move Instance Method refactoring

Note that when it comes to choosing destination classes, this refactoring only offers those that are members of the original class. It’s also worth pointing out that Move Instance Method currently only supports C# but we’re working to ensure VB.NET support in subsequent builds.

Inspecting XAML Grids

We’ve added several new code inspections and quick-fixes related to the usage of grids in XAML markup. Although present in one of the previous EAP’s we’ve now polished it up for the current release and ready to talk about it some more.

With ReSharper 8, there’s no way you can declare a control that sits in a non-existent grid row or column and get away with it:

ReSharper detects a usage of an undefined row

What we have here is a parent grid with two defined rows and a nested grid referencing a grid row that doesn’t exist. In addition to helping you actually spot the problem, ReSharper 8 includes a quick-fix that will insert all the missing row definitions if that’s the way you want to sort out the issue:

Quick-fix to add missing row definitions

It adds the missing definitions without moving the caret around, and you stay exactly where you had been before the fix was applied. If you’re working with a complex layout and you stand at a grid row property that’s several screens away from row definitions, that saves you quite a bit of navigating through your code.

There’s also a new inspection that fires up whenever a control within a grid doesn’t specify a row or column number, and suggests a fix. Note that this inspection isn’t fired for the first control in a grid since developers often deliberately leave columns and rows for the first controls unspecified.

Quick-fix to add a missing grid row property value

We’re not only adding code inspections and corresponding quick-fixes but standalone context actions as well. Specifically, there are new context actions to add or remove a row or column definition before or after the current definition, as well as one to remove the current row or column definition.

ReSharper can help if you want to add or remove a column definition

XAML Refactorings

We have added a whole bunch of refactoring and enhancements for XAML, including Extract Style Refactoring, collapsing empty tags, code cleanup, styling daemons, and more. We’ll be covering these in more detail in a separate blog post.

UI Enhancements, Bug Fixes and More

Some touch-ups have been applied to the ReSharper UI where most of the older controls are now replaced with WPF ones. We’ve also fixed numerous bug reported since the previous EAP (thanks everyone for these reports and keep them coming). Additionally, two somewhat annoying bugs have also been fixed with this release, related to MSBuild. The first one is Conditional References with MSBuild and the second has to do with ResolveAssemblyReferencesDependsOn build task.

We hope you enjoy this latest release of ReSharper 8 EAP and as always, welcome bug reports and feedback. Download the latest EAP now.

ReSharper on the Server: Detecting Code Issues in the build

Wednesday, October 10th, 2012

Did you know that you can run ReSharper Code Inspections on the server using TeamCity? In fact, we added support for this functionality in TeamCity just over a year ago but it seems that the feature is not widely known, specially by ReSharper users.

The setup itself is extremely simple, and we’re going to walk through it, and additionally add some more goodies in the mix.

Activating .NET Inspections in TeamCity

Adding ReSharper inspections to the build process is merely adding the Build Step named Inspections (.NET). The only parameter required is the Visual Studio Solution file

insepctionsrunner

 

If we do not specify a Custom settings profile path, TeamCity takes the default ReSharper settings for code inspections. However, we can configure these to match our own/teams criteria. This is done via Options | Inspection Severity. We can change a specific setting severity, for instance, that of using String.IsNullOrEmpty

 

inspectionsresharper

 

and save the settings to the Team Shared file. This then saves the settings in a file named {Solution}.sln.DotSettings which is normally checked in to source control so that it automatically applies to other team members when the solution is opened in Visual Studio. We can use this same settings file to indicate custom inspection settings for TeamCity

 

settings

 

Analyzing results

When the build step runs, TeamCity generates a navigable report for us to analyze inspection results

 

image

 

We can navigate through the inspections for the entire project or a specific namespace. Inspections are grouped by Category, Issue Type and the corresponding files on the right pane. We can even navigate to the actual file by clicking on the line number. For this though, we need to have Visual Studio and the TeamCity plugin for Visual Studio installed (if you do not, clicking on the link will prompt you with a dialog box to download and install the plugin).

 

The checkbox Inspections with new problems only is used to highlight only new issues since the last build run. The numbers in bracket (+1 –1) are the variance since the last run.

Taking action based on inspection severity

One of the main benefits of adding inspections on the server-side is to put some level of code quality in place, whereby we can have the build process take action based on a series of conditions. For instance, we might like to have a build fail if too many warnings or errors are detected. 

 

Under Build Failure Conditions in the Project Configuration window, we can add a new Build failure condition:

 

 

buildfailureinspections

 

We select Fail build on metric change and then indicate whether we want a build to fail based on warnings or errors. In our case we’re going to select errors and have it fail if it is more than one.

 

image

 

It should be apparent that if we want inspections to have an impact on the status of our build, that is, have a build fail, we can only do so based on Warnings or Errors. Therefore, Hints and Suggestions cannot be used. As such, when configuring inspections severity in ReSharper, we should take this into account.

 

If we now run our build again, it should fail as the number of errors are greater than one. Below is the output of the same input and inspections, but one run with the Build failure condition and the other without it.

 

buildoutput

 

Checking for copy/paste code

Although strictly speaking, this isn’t related to ReSharper, but since we’re talking about code quality in the build process, it makes sense to also mention that TeamCity can check for code duplication.

Much like before, activating code duplication is simply a matter of adding a new build step, namely Duplicates finder (.NET). We can indicate the folders to ignore, whether we want to take into account namespaces, type names, as well as a few other options.

 

builddupeconfig

The output is a nicely formatted navigable screen which allows us to go through the different files and see a side-by-side comparison of what TeamCity has detected as duplication (resized below for space limitations)

image

And as expected, we can also fail the build if we have too many code duplicates

buildfailuredupe

Summary

It is refreshingly simple to add code quality detection features to the build process and have a build fail if something that shouldn’t be in production code slips through. The next step would be to provide Custom Patterns, which currently are not supported. If you feel this is a feature you’d like, let us know, and as always, any and all feedback is welcome.

dotCover 2.1: What’s inside

Monday, September 17th, 2012

As you might already know, last week we released an update to dotCover. This minor version includes a series of bug fixes and improvements as well as a couple of important features worth noting in details.

Visual Studio 2012 Integration

dotCover 2.1 now integrates fully within Visual Studio 2012, either as a standalone product using its own Test Runner, or integrating tightly with ReSharper.

dotcover_vs2012_integration

In addition, it also comes with support for both Light and Dark theming, as well the ability to choose the icon set we want to use.

dotcover_vs2012_theming_support

We’ve also added support to help with people with color-blindness.

Windows App Store Application Supportdotcover_windows_store_applications_support

dotCover now allows the coverage of standalone Windows App Store applications, formerly known as Metro Applications.  This support is possible to the underlying engine that dotCover is built in, which is the same profiling engine that dotTrace Performance uses.

We have many more features planned for the next upcoming version of dotCover so stay tuned. And as always, please provide us with any feedback.

You can download the latest version which integrates with ReSharper 7.0.1 from here.

ReSharper 7: Summary of Main Features

Thursday, September 13th, 2012

It’s been over one and a half months since the release of ReSharper 7, and in that timeframe we’ve already rolled out a minor update fix (7.0.1). Microsoft, on its part, has yesterday officially launched Visual Studio 2012 which ReSharper 7 has been firmly supporting from the very start.

We’ve been posting on some of the new features that are included in ReSharper 7, so we thought it’s about time to do a summary post for your convenience. This list is by no means all-inclusive and there are still other interesting areas we’re going to be writing about.

In addition, we’ve worked hard with the plug-in developers to ensure that the majority of extensions for ReSharper would be available for version 7 for it’s release. You can find a complete list of compatible plug-ins for ReSharper 7.

Finally, we also held a Webinar on ReSharper 7 which was recorded and posted on JetBrains TV among other insightful videos.

JavaScript improvements in ReSharper 7

Friday, August 24th, 2012

ReSharper 7 greatly enhances JavaScript support by adding more analysis, quick fixes, code completion, as well as support for Jasmine and PhantomJS unit test runners.

Code Analysis and Context Actions

One of the biggest issues when writing JavaScript code, or any kind of dynamic code in general, is the potential mistakes that can lead to runtime errors. Not having a compiler as a safety net to detect some problems has it’s downside.

With ReSharper 7, we have placed a lot of effort in trying to analyze code and offer a series of context actions, be it quick fixes or refactoring. In fact, we added 30+ new context actions in ReSharper 7

Converting numbers to different formats

image

You can now convert back and forth from decimal to hexadecimal, to octal, all with a single Alt+Enter action.

Dealing with Conditionals

From simple if inversions of conditionals

image

to converting if conditionals to ternary and back

image

image

as well as the ability of merging multiple if statements or separating them out

image

image

All in all, we’ve added quite a lot of context actions to deal with conditionals.

Accessor Properties

ReSharper 7 also adds support for the new property accessors in EcmaScript 5

image

when selecting to wrap get-accessor gives way to

image

Alternatively, if selecting the first option, we’d get

image

defineProperty support

We also now support defineProperty in multiple ways

image

resulting in

image

Much more

These are just some of the context actions out of the 30+ that we have added, including tiny but small annoyances such as using double quotes when single is required

image

making JavaScript a bit easier to work with and help in learning.

Code Completion

In terms of Code Completion, we have added support for event handlers under WinJS/WinRT (see below), as well as some nice little additions available globally

image

Once again, we also provide support for new methods defined in ECMAScript 5

image

WinJS

With Visual Studio 2012 allows us to create Windows 8 Metro applications using C# and XAML, as well as JavaScript and HTML. ReSharper 7 also provides support for JavaScript for Metro applications. Once again, we have covered this previously.

Here is a sample of Code Completion with addEventListener/removeEventListener:

image

Unit Testing Enhancements

We’ve also added support for Jasmine and PhantomJS test driver in ReSharper 7, which we’ve already covered in this post.

Invisible but important features

Internally, Visual Studio 2011 provides 5 JavaScript files that are implicitly referenced in every JS file in a project. They contain DOM definitions, standard JS objects and other important information. It aids in producing code completion and tooltips. In Visual Studio 2012, Microsoft allows developers to configure these files via options and surfaces an API. ReSharper uses this API to get information from these files, making the code completion / navigation flexible.

We’ve also drastically improved performance of JavaScript. In general, now working with script files should be a much faster experience.

JSLint for ReSharper

Last but not last, for those of you that like JSLint, know that although we do not ship support for JSLint out of the box, there is already a plug-in available from the community. Lars-Erik has written JSLint for ReSharper and it’s already available for ReSharper 7.0.

As always, we appreciate the feedback.

Welcome our new Company Blog

Tuesday, August 21st, 2012

Hello everyone,

As you know, we’re a company of software products. Our .NET Tools are part of the 14 plus tools that we currently have. But a company isn’t just what we develop. It is also who we are, what we’re passionate about, what inspires us, and what we believe in. We decided to share these essential parts of our world called JetBrains with you – in the JetBrains Company Blog. In fact, it has been in the works for quite some time and is finally coming to life.

Check in often to get to know us better – the people, the events, the hobbies, the beliefs, the anecdotes and the pure facts – everything behind the tools that we make for you.

Don’t miss our interview with John Lindquist, already published on the blog.

Stay tuned for more news and keep developing with pleasure!

dotTrace SDK: An API for Your Performance Needs!

Thursday, August 9th, 2012

As of version 5 of dotTrace Performance we started shipping as part of the package, an SDK which allowed us to programmatically make use of dotTrace Performance engine. We are excited to announce that we are now offering this as its own standalone product, with its own installer, and available for free. Download it here.

Making performance snapshots child’s play

Performance issues generally are a pain. They usually only appear in production and are hard to pinpoint and even worse to reproduce. When performance issues arise, the first step is to run analysis on the application to try and find the bottlenecks, and this isn’t always easy in production. To begin with, we need to interact with the machine where the application is running. With dotTrace Performance we’ve made this somewhat easier by allowing remote profiling. Secondly however, we need to have some knowledge to collect this information, in other words, know how to work with dotTrace Performance. This usually means a member of the support team or developer. Not the customer.

Wouldn’t it be great however if this weren’t necessary? Imagine if we could just instruct the program to profile itself. Well that is what the SDK is bringing to the table, and more!

Scenarios

Let’s take a look at some of the scenarios that the SDK enables.

Self-Profiling

As mentioned previously, one of the great advantages of the SDK is to allow an application to profile itself and gather performance metrics. In ReSharper 7 we are already making use of this functionality. When you install ReSharper, you will notice a new menu entry under Help menu:

ReSharperHelpMenu

When we execute this option, the dotTrace performance engine kicks in and attaches itself to the running process. It then starts to gather information about everything that is going on in the application. Once enough information has been gathered, it creates a snapshot file that can be analyzed by dotTrace Performance and more importantly, it can be detached from the process. As we know, running an application under a profiler has a performance penalty so it is fundamental to only do it for the minimum time required.

By default, when invoking this functionality, the dotTrace Controller pops up:

dotTraceController

However, this functionality can be customized to one’s own needs, so we can in fact have something that blends in more with our application and we also have access to events that allow us to intercept the snapshot and do what we want with it.

Application-Centric Profiling: Profiler API

When analyzing performance snapshots, we usually focus on our own application code and ignore system code such as the BCL calls or libraries and frameworks that we cannot necessarily do anything about. With some applications this is easy to accomplish as dotTrace Performance grays out irrelevant code and allows us to focus on our own. However with certain types of applications, it’s not always straightforward as it’s hard to often distinguish entry points from the users perspective.

The SDK now allows us to indicate where we want to focus our performance analysis by allowing us to define entry points. For instance, in an ASP.NET WebForm application, we can add the following code to the Application_Start event:

CodeSnippet

This means that if we’re running under dotTrace Performance (in other words profiling the application), to start monitoring our code. We can then indicate where we want to stop monitoring also:

CodeSnippet

and thus allowing the focus to stay within the bounds of the code we are interested in. Notice how we do not have to make explicit calls to the profiler. We just indicate when we want to start and when we want to finish.

By doing this, we can now activate the Use Profiler API checkbox in dotTrace Performance

dotTraceConfig

and thus removing all irrelevant infrastructure code that we are not interested in from the analysis.

On-Demand Profiling

Although not a scenario as such, the ability to pause and resume performance, gives us the ability to provide on-demand profiling in our applications. We can have SDK calls in the code and activate them on demand.

Getting Started: Show me the code

Once we download and install the SDK, the application folder where it is installed contains 4 folders:

Folders

The Doc contains the documentation for the API classes which we’ll examine briefly in a moment. The Lib folder is the two assemblies that are referenced in applications that use the SDK. An important folder is the Redist. This contains a redistributable copy of the dotTrace Performance engine which should be shipped with your application if you’re using the Self-Attach functionality. Finally Samples provides two documented samples of how to work with the SDK in the scenarios depicted previously. One of them is the VSTool Visual Studio self-profiling add-in and the other is an ASP.NET WebForms application.

The SDK itself has a small surface area, with only a few classes. Namely the important ones include:

  • ProfilingControl: Class to control the starting, stopping, pausing, attaching and detaching of the profiler to the application. We need this class in order to use the Use Profiler API option in dotTrace. An example usage of this is the ASP.NET WebForms sample that ships with the SDK.
  • SelfAttach: Class to allow self-profiling. Covered in the VS add-on sample that ships with the SDK.

When using the SelfAttach class, we can indicate how we want the behavior to be once a snapshot has been taken. We can opt on opening the snapshot file, saving it or have it processed by a third party assembly. Each of these options have their own settings and are defined by different classes:

  • OpenProfilingConfig: Open the snapshot once completed
  • SaveProfilingConfig: Save the snapshot once completed
  • ProcessSnapshotProfilingConfig: Process the snapshot once completed

We pass as constructor to argument to SelfAttach an instance of one of these classes. The VSTool demo shows example usages of all three.

An important option among the configuration classes is the ProfilerControlKind property which indicates how the profiling process is controller. The default option (as described above in the Self-Profiling) is to use the dotTrace Controller window. Alternatives are None or using the API.

Summary

This is the first big release of the SDK and based on the feedback we receive we want to improve it and make it more versatile, so we appreciate any and all comments. As mentioned the SDK is freely available. You do not need to own a license of dotTrace Performance to distribute it. You do however of course need dotTrace to analyze the results. The point is though to make it simple and cheap for you to include this functionality inside your applications

You can download the SDK from here.

Enjoy and please give us any feedback.

dotTrace Performance 5.2 released!

Tuesday, July 31st, 2012

dotTrace 5.2 Performance has just been released and ready for you to download now! This is a minor release update that includes close to a dozen bug fixes, and it also lays some ground-work for some exciting features in upcoming releases.

.NET 4.5 and Windows 8 Support

image

dotTrace 5.2 Performance provides support for .NET 4.5 applications. As such we can now profile any managed application targeting the newest version of the Microsoft platform. Currently there is no integration with Visual Studio 2012 but we will be adding support for that in an upcoming release. It is possible however to use dotTrace Performance standalone to profile .NET 4.5 applications. dotTrace Performance works perfectly under Windows 8.

Classroom and Academic Licenses

We are also pleased to announce that dotTrace Performance now joins the ranks of our other tools by offering Classroom and Academic licenses. If you are a School, University, College or Trainer, you can apply for a classroom license for dotTrace performance.

Upcoming support for Metro and Visual Studio 2012

Among some other important updates, next release will include support for both Metro style application as well tight integration with Visual Studio 2012, as well as continuous enhancements to the profiling SDK which is coming soon.

ReSharper 7 Webinar

Monday, July 30th, 2012

Have you downloaded ReSharper 7 yet? Do you want to know what new functionality it offers you? Join us for the Webinar we’ll be holding on Tuesday, August 7th at 4 pm CET (Central European Time) where we’ll be covering some of the new and exciting features in this release.

Registration is open but limited in space, so please sign up quickly if you plan to attend. To sign up click here on the registration link. Come ready with your Questions. We’ll have Answers.

Hope to see you on Tuesday!

How Exactly ReSharper 7 Supports Visual Studio 2012

Wednesday, July 18th, 2012

One of the larger efforts in ReSharper 7 was support for Visual Studio 2012, in terms of integration, enhancements of the Visual Studio experience, as well as new technologies such as WinRT. In this post we’re going to go over some of these.

Theming Support

Visual Studio 2012 provides support for theming, and ships with default Light and Dark themes. We have added support for this by updating all our menus, icons etc. to make sure it looks pleasant on both light and dark themes.

Visual Studio also introduced monochrome icons. We received a lot of feedback from our users asking us to not follow the same style and convert all our icons to monochrome. At the same time we also had other users saying that the color icons do not comply with the new VS look. With taste being so subjective, we decided to leave it up to you, the user, to decide what you would like your icons to look like.

Icon style settings

You can now choose how application icons appear such as those on refactoring menus, toolbar windows, etc. as well as source code symbol icons such as types, properties, etc. All of these are configurable via ReSharper | Options | General. In fact we’ve even given our own icons a face lift!

Asynchronous Solution Loading

Microsoft added support for Asynchronous Solution Loading in Visual Studio 2012, allowing projects to be loaded asynchronously when opening up a solution, which in turn helps us continue our work without having to wait for the entire operation to complete.

In ReSharper 7.0, despite some serious challenges that we faced with ASL and the API surface exposed, we have managed to provide 100% support for this feature, incrementing the startup time drastically, allowing you to benefit from ASL and all the ReSharper goodness.

Just so you get an idea of the performance gain, the same solution, consistent of 300+ projects, opened in Visual Studio 2010 using ReSharper 6 takes 5 minutes 12 seconds. In Visual Studio 2012 using ReSharper 7, it takes 1 minute 17 seconds!

Quick Launch

With Visual Studio 2012, if you are not sure under what menu a certain action is located or how it is exactly named, you can use the Quick Launch options (Ctrl+Shift+Q) to find it. As a plug-in to Visual Studio, we had to facilitate providers for this quick launch in order for our actions to also be available. As such, typing something along the lines of Go To should display all the ReSharper | Go To options.

ReSharper commands in Quick Launch menu

In a way, this is also a discoverability enhancer: If you want to discover things ReSharper offers you, just type ReSharper.

Preview Tab

Visual Studio 2012 introduces what’s called the Preview Tab, which is a tab that opens on the far right side of the editor window when browsing a file. As soon as you start editing, it will then become a “normal” tab, placed alongside the rest of the open files, starting from the left side. If you’ve not seen this before, try it: navigate through the Solution Explorer and see how files magically appear and disappear in a tab on the right. As soon as you edit, they’ll move to the left:

Preview tab

ReSharper supports this functionality via any of its navigation features, including Go To Type, Member, File, Declaration as well as through Find Usages and other tool windows that deal with files.

Solution Explorer Awareness

In the Solution Explorer, you can now expand a file and get access to its members. We provide context sensitive menus on these items so you can invoke ReSharper actions such as refactoring, find usages, etc. directly from them using the context menu or any of the refactoring shortcuts:

ReSharper commands in Solution Explorer

Architecture Explorer

In the Ultimate Edition of Visual Studio 2012, the Architecture Explorer allows a project view allowing drill-in to namespaces, types and members. Once again we provide context sensitive support here with options such as Navigate To and Refactor This:

ReSharper commands in Architecture Explorer

Dependency Graph

As well as supporting the Architecture Explorer in Ultimate Edition, we also provide access to functionality in the Dependency Graph, again allowing for refactoring, navigation and other goodies:

ReSharper commands in Dependency Graph

New Frameworks

Windows development has taken a new turn with Visual Studio 2012. With the appearance of WinRT, developers now can target Windows 8 with Metro style applications. ReSharper 7.0 adds support for framework references, compilation targets for C# projects and as well as JavaScript WinRT projects. We’ll cover these in more detail in another post. Suffice to say however that we are there, providing you with access to the latest technologies.

We hope that some of these features make your coding experience more pleasurable in Visual Studio 2012. Since ReSharper support for the new Microsoft IDE is pretty wide and stable, we’re committed to sim-ship ReSharper 7 with Visual Studio 2012 RTM.

Stay tuned for more detailed information about framework support and other new features in ReSharper 7.