суббота, 24 декабря 2011 г.

Optimizing assembly references with ReSharper 6.1


Today I'm going to talk about new features of ReSharper 6.1th version, which allow you to easily manage your existing assembly references, see referenced assemblies usages, and remove unused references.

Three new features are coming along with a new 6.1 version of ReSharper:

1. Optimize References

Optimize References is a main feature for analyzing your referenced assemblies. This feature can be called on a single project and displays this module's unused and used assembly references. It does not require your project to be compiled, so you can call it even if your project is currently broken.

One of the coolest things about this feature is that it allows you to see usages of a concrete referenced assembly, namespace or type, filter them by their kind, group them and navigate from them directly to your source code. On the screenshot below is illustrated why exactly my project references System.Drawing.dll and what types of that assembly are used and where.

Different icons mean different usage kinds like read, write, attribute, invocation and other kinds of usages familiar to you from ReSharper's navigation features. However, one kind of usages is unique for Optimize References. This kind of usage is called 'compiler related usage' and indicates implicit (non-direct) assembly reference usages required for compiler.
The simplest case is the case when related usages are caused by a type's hierarchy. That is, if you use a type, then you have to reference all assemblies containing this type's supertypes. Unfortunately, this is just one example of many other much more complicated ones... :)

Besides just observing, you can delete unused assembly references directly from this tool window. You just need two buttons to remove all unused references or just selected.

Note that this feature will also delete all redundant C#, VB.NET or XAML namespace import directives, which reference namespaces from the removed referenced assemblies.

2. Remove Unused References refactoring

This refactoring quickly detects unused assembly references without displaying their usages. It works faster than Optimize References. It is very useful if you do not want to analyze usages but just want to quickly clean up your project references.

'Analye Used References...' button will open Optimize References tool window.

3. Safe delete on assembly references refactoring
That is, now you can press Alt+Del on the selected assembly references from Solution Explorer. They will be either silently removed, or you will get a window indicating that some of the selected references are used.

These three features introduced in ReSharper 6.1 will definitely help you to manage your references. By the way, if you want to observe code referenced in the scope, other than project (for example, folder or method's body), you can use ReSharper's 'Find Symbols External To Scope' and 'Find Dependent Code' features.

понедельник, 30 мая 2011 г.

New 'Go To ...' features in ReSharper 6 and dotPeek

Hi all!

If you are familiar with R# then you probably use its powerful navigation features - sophisticated context navigation (just look at 'Navigate To' dialog) and powerful 'Go To ...' navigation. All these features make you almost forget about Solution Explorer, allowing to instantly move through your solution.
Today I'm writing about the new concept of 'Go To ...' navigation in R# 6, that will make your navigation even more precise and powerful.
To be simple, in R# 6 you can type multiple words in 'Go To ...' dialogs.  In different dialogs semantics of words is different, but the main idea remains the same : now you can search something inside something inside something and so on.

Let's start with 'Go To Symbol' dialog. In this dialog words correspond with entities in your code model: namespaces, type elements (classes, structs, delegates) and type members. The words you type in a dialog match all of these entities in hierarchical order (from left to right).

You can search type members even inside namespace without typing an extra word for a type element. For example, this might be very useful in case you have a huge hierachy with a lot of clients overriding  method with the same name.

Advanced users maybe know that in 5.1 version they could use a whitespace for 'tail matching'. Since in R#6 whitespace has other semantics, you can use '\' symbol for tail matching.

Another productivity hint that for me personally saves a lot of time:  often you want to navigate to a type's member, but you don't know the exact method's of file's name in that class. The common behaviour in R# 5.1 would be: Go to type -> Navigate to your type -> Go to File Member -> Navigate to your member. In R# 6, since you have combos, you can  just type your type's name and add a whitespace after. You will get all type members without first navigating to a type.

Combos work for external sources as well, and you can use absolutely the same features in dotPeek - new .net Decompiler from JetBrains.

'Go To Type' dialog uses the same idea, but without navigating to your type members, words correspond to namespaces and type elements.
Both in 'Go To Symbol' and 'Go To Symbol' you can use either ' ' or '.' as a delimiter. This means that these dialogs will find results by FQN.

'Go To File' dialog searches through your project model, allowing you to find files, projects and all kinds of folders inside each other. You can use ' ' or slashes ('\', '/') as a delimiters.

All of these features improve global 'Go To ...' navigation and make it even more powerful than before.
Stay tuned!

среда, 4 мая 2011 г.


Hi all!
My name is Kirill, I am working in JetBrains company in ReSharper team as a software developer. Mostly here I will try to post something about our great products but will write some stuff about zombies as well:)
Hope this will be interesting!