Extending Visual Studio 2010
By Tim Anderson
A new version of Microsoft Visual Studio brings a new crop of add-ons. Tim Anderson surveys the most useful and unusual.
HardCopy Issue: 50 | Found In: Development | Published: 01/11/2010 | Last Revision: 22/02/2011
Microsoft’s Visual Studio is one tool Windows developers can hardly do without, covering as it does application development from device to desktop to Web and cloud, and programming languages including C++ for native code, C#, F# and Visual Basic for .NET, and JavaScript for browser development. Visual Studio 2010 also comes with application lifecycle management tools for testing, version control, bug-tracking and more, based on the repository and developer collaboration platform Team Foundation Server.
That might sound comprehensive, but there are still plenty of areas that Visual Studio does not cover, or which can be enhanced. Visual Studio is not only an IDE but also a tools platform that third parties can extend. Since developers spend so much time in the product, add-ons that save time or improve code quality can soon pay back their cost.
Add-on tools are not limited to coding utilities. Three years ago, Microsoft removed license restrictions that required Visual Studio extensions to target Windows, so third-party tools that allow developers to target Linux and the Mac are now permissible, along with non-Microsoft platforms like Adobe Flash. Other tools address areas that Visual Studio on its own does not cover, such as programming the GPU (Graphic Processing Unit) to achieve remarkable performance boosts in general applications.
Another interesting area is programming languages. For example, if you want to work in Visual Studio but code in Embarcadero’s Delphi language, you can do so by purchasing Prism.
Free tools
Some excellent tools for Visual Studio 2010 are free to download. Microsoft Productivity Power Tools, for example, have a range of extras including an enhanced solution explorer, quick access to tasks, auto brace completion, HTML code pasting (for when you are posting code into a Web forum), customisations for document tabs in the IDE and more.
The H3Viewer is a replacement help viewer for Visual Studio 2010, and restores the index of contents which disappeared in this release. It also works faster than the official viewer, and has rave reviews from developers who have switched. You can find these and others in the MSDN Visual Studio Gallery.
Beyond Windows
Amethyst from SapphireSteel software lets you code in Visual Studio while targeting Adobe’s cross-platform Flash runtime. It uses the Flex language, as used by Adobe’s own Flash Builder, and includes a visual designer. You can also design an application in the Flash (rather than Flash Builder) IDE and debug the ActionScript code in Amethyst. There is a free personal edition, or get the Professional version to use all the features. Amethyst is a promising product: though it is relatively new and we did encounter some teething troubles, the support was responsive and helpful.
Novell’s Mono Tools lets you code for Windows, Linux and the Mac in Visual Studio.
Novell’s Mono Tools lets you use Visual Studio 2010 for building Mono applications. Mono is an open-source implementation of .NET that runs on Linux and the Mac. Compatibility is greatly improved over early versions, and it is now feasible to create true cross-platform code, provided you avoid obvious problems like platform invocation of native Windows APIs. Mono Tools will analyse your project for compatibility issues, and then lets you build, run and debug in Mono from within Visual Studio.
Novell and the Mono team also plan to extend MonoTouch, which compiles .NET applications into native code apps for the iPhone and iPad, so that you will be able to develop for these devices using Mono Tools for Visual Studio. You will still need a Mac for builds, code signing and testing.
Alternative languages
Ruby in Steel, also from SapphireSteel, lets you code in the Ruby language and includes a visual designer for Rails, the popular Web application and object-relational mapping framework. Ruby in Steel makes Visual Studio an IDE for either standard Ruby or JRuby (running on the Java Virtual Machine); not for IronRuby which runs on .NET.
Delphi Prism brings the Delphi language to Visual Studio and .NET
Delphi Prism XE from Embarcadero integrates Delphi language programming into Visual Studio 2010. Unlike early versions of Delphi for .NET, which used a ported version of Delphi’s VCL (Visual Component Library), Prism uses the standard .NET Framework, giving full access to all .NET features including newer frameworks such as ASP.NET MVC and Silverlight. Prism also goes beyond Microsoft .NET, with support for Mono applications that run outside Windows. Prism project types include Cocoa for the Mac and Gtk# for Linux. Prism Enterprise Edition supports DataSnap clients for multi-tier applications using Embarcadero’s architecture. All editions come with InterBase 2009 Developer Edition.
Protecting and or Decompiling
PreEmptive Solutions Dotfuscator is already familiar to Visual Studio developers because the Community Edition comes with it. It is an important add-on, because unless you obfuscate your .NET code, you are essentially deploying source code to your customers. The problem is that .NET assemblies can easily be decompiled back into C# by products such as Redgate .NET Reflector, described below.
The commercial edition of Dotfuscator goes much further than the free one, adding many more types of obfuscation, full integration with Visual Studio and the MSBuild tool, additional application types including Silverlight, and optimisation through the removal of unused code.
Dotfuscator also goes beyond obfuscation. Tamper detection protects against cracked versions of your software being deployed. Shelf life gives applications an expiry date, with the ability to run custom actions on expiration. Runtime intelligence lets you analyse how your application is being used, by receiving usage data from users. The Community Edition does include some of these features, but in more limited form.
Redgate .NET Reflector is a remarkable utility that is able to decompile .NET assemblies into C# or Visual Basic code. It comes standalone or as an add-in for Visual Studio. The add-in lets you debug into libraries for which you do not have the source code. This can be a life-saver in cases where the source has been lost or was never available. Reflector is less useful if the assembly has been obfuscated.
Finding memory leaks
Although automatic memory management is a feature of .NET, it is still possible to have memory leaks in .NET applications. Typically these occur when references to an object are kept for longer than intended, which is an easy mistake to make – so much so that memory leaks have sometimes been found in Microsoft’s official framework libraries.
A memory profiler is near-essential for tracking down this kind of bug. Generally, you snapshot memory usage two or more times as the application runs, and then compare the differences that so you can see what memory was allocated and released between two snapshots. There is a basic memory profiler built into Visual Studio 2010, but third-party tools come with additional features.
Redgate ANTS Memory Profiler integrates with Visual Studio 2010 so you can kick off profiles within the IDE. You can snapshot memory usage, compare snapshots, and view class references and an object retention graph to trace why objects that should have been disposed are still in memory. You can also attach to a running process. The Profiler supports .NET 1.1 to 4.0, and Silverlight 4.
Scitech .NET Memory Profiler also integrates into Visual Studio 2010. This is a long-established .NET memory profiler, though much enhanced since the earliest versions. It works well for tracing memory leaks and also has a .NET API so you can snapshot memory automatically and add memory assertions to your code. The Professional version has added features including the ability to attach to a running application and to track unmanaged resources.
JetBRAINS dotTrace is another tool for tracking down memory leaks. The current version is 3.5, with 4.0 to follow shortly. Then of course there are the tools built in to Intel Parallel Studio, and Micro Focus DevPartner Studio, described below.
Profiling and debugging
NA performance profiler analyses your application to identify bottlenecks and help you decide which parts are worth optimising. Performance gains can be dramatic, with an immediate benefit to productivity. Error finding tools can save hours or days of time tracking down subtle bugs or problems buried deep in a library. Code quality tools reduce errors by enforcing or encouraging high standards as you and your team write code.
JetBRAINS dotTrace 4 is a performance profiler for .NET applications. It is designed to scale to huge applications, capturing snapshots of up to several hundred gigabytes at an acceptable speed. It supports three profiling modes: tracing logs the execution time of each function as it is called; sampling is an alternative which gives less information but is more usable thanks to running up to 30 times faster; line-by-line profiling times every statement in your code, allowing you to drill down on performance-critical code in detail.
JetBRAINS dotCover is a tool for discovering what percentage of your code is covered by tests. It supports multiple unit test frameworks, integrates with ReSharper’s unit testing tools (see below), and works with .NET Framework applications including Silverlight.
Intel Parallel Studio 2011 is a suite of tools for writing and debugging concurrent applications in Visual C/C++. The new 2011 edition is the first to integrate with Visual Studio 2010, and also contains the first version of a new tool, Parallel Advisor.
Parallel Advisor helps you work out how to improve an existing application by introducing parallelism. The tool analyses performance to see where there are time-consuming loops that might benefit. Then it adds annotations to propose parallel tasks, checks predicted performance, reviews correctness, and finally adds actual parallel code.
There are three other tools: Parallel Composer provides the Intel C++ Compiler, thousands of optimised functions called Performance Primitives, and Building Block templates and libraries for parallel coding; Parallel Inspector is a profiling tool focused on finding typical threading and memory errors associated with parallel coding, though it will also find memory errors in single-threaded applications; Parallel Amplifier is a performance profiler which measures multi-core usage as well as other performance issues like which functions take most time and where there are performance-killing locks and waits.
Micro Focus DevPartner Studio is a comprehensive code quality tool which integrates into both Visual Studio 2010 and Team System. Static code analysis enforces best practice coding, with both predefined and customisable rule sets. Code complexity detection identifies code liable to be buggy or unmaintainable. A security scanner reviews ASP.NET applications for possible security issues.
Errors and memory leaks in C/C++ code can be discovered through the latest version of the tool previously known as BoundsChecker which is excellent for finding pointer errors and uninitialised memory and overruns. There is also a performance profiler for .NET applications, a .NET memory profiler, multi-tier performance analysis and built-in code-quality reporting. Finally, DevPartner Studio integrates with Team System work items for sharing tasks and diagnostic data.
Targetting the GPU
Analysing code that is running on a GPU using NVIDIA Parallel Nsight.
NVIDIA Parallel Nsight is a tool for both graphical and general programming that targets the GPU. GPU programming is a hot area because of the amazing performance gains it can yield. The key reason is that GPUs have many more cores than CPUs, sometimes in the hundreds. If you can parallelise slow-running processes and run them on the GPU, the increase in speed can be huge. On the other hand, GPU programming is challenging, both because of the inherent difficulty in concurrent programming, and because the GPU has its own RAM which is isolated from main memory.
Parallel Nsight lets you debug applications using either CUDA, NVidia’s hardware extensions and software library for general programming on the GPU; or DirectCompute, which is part of Microsoft DirectX and also aimed at general GPU programming. Parallel NSight has a debugger that lets you view GPU threads and memory using standard Visual Studio tools, and an analyser (in the professional version only) that profiles your GPU code. If you are doing GPU programming on NVIDIA hardware, Parallel Nsight is invaluable.
Micro Focus Silk4Net is a tool for functional and regression testing which plugs into Visual Studio 2010. Silk4Net includes an Action Recorder for creating tests, or you can create test scripts in C# or Visual Basic where there is no graphical user interface to record from. For Web applications, Silk4Net test scripts allow for asynchronous behaviour, which is now commonplace thanks to AJAX, and does not require manual wait statements.
You can also run unattended tests for long-running testing, with Silk4Net able to restart an application after a crash and continue running tests. Silk4Net supports both local and remote testing, and integrates with another Micro Focus product, SilkCentral Test Manager, for test management and issue tracking.
Productivity tools
Visual Assist X from Whole Tomato software has over 50 productivity features. These include refactorings, code suggestions as you type, enhanced syntax highlighting, Visual Assist Outline for code navigation, code spell check which finds errors and inconsistencies, and enhanced IntelliSense.
Telerik JustCode aims to blend unobtrusively into your coding thanks to a fast core engine that took over four years to create. This is a substantial add-in that speeds productivity though code analysis, navigation and formatting, as well as though generation of stub code, refactorings, code templates, advanced code highlighting, and more. There is a Unit Test Runner that works with Microsoft’s test framework as well as NUnit, xUnit and MbUnit. Another highlight is strong support for JavaScript, with refactorings, code analysis and quick fixes available.
JetBRAINS ReSharper 5 brings a wide range of coding assistance to Visual Studio developers. It is the closest thing to having the popular IntelliJ IDEA, a smart Java IDE from the same company, available for .NET as a Visual Studio add-on. The latest version adds specific features for ASP.NET and ASP.NET MVC to its existing general coding support.
ReSharper includes a large number of refactorings, well beyond what comes with Visual Studio by default, and most of which work with Visual Basic as well as C#. ReSharper also goes beyond refactoring. Code generation features and extended code completion saves typing and reduces errors. Continuous code quality analysis applies over 900 inspections as you type, with suggestions and hints. Numerous navigation shortcuts speed searching your code. Unit testing is supported, using either Microsoft Test or NUnit, with quick test run icons in the code editor, a unit test explorer and a unit test session window.
DevExpress CodeRush is another well-known coding assistance tool. A distinctive feature is a set of visualisation tools which use colour highlighting, icons, and even tiny animations to enable quick recognition of how your code is structured. Selection tools speed the task of manipulating code selections, including selection embedding with lets you add code such as a try...catch block around a selection, and you can even define your own embeddings. A smart clipboard intuitively adapts what you paste to the surrounding code.
The CodeRush unit test runner integrates quick test running and the outcome of tests into the editor, with support for Microsoft Test, NUnit, MbUnit and xUnit. CodeRush code templates expand code from short abbreviations. DevExpress Refactor! Pro shares keystrokes where possible with CodeRush. With over 150 refactorings, DevExpress claims to have more than any other tool.