Tech Tock

Time is of the essence.

3 New Favorite Techniques in Visual Studio

Here’s 3 techniques in Visual Studio that have lately become favorites of mine.

Breakpoint Output Logging

In my previous post on output logging with breakpoints, my colleague Ken Overton, pointed out the existence of something that used to be called “TracePoints”.  I went looking for these mythical beasts and was pleasantly surprised to find the “When Hit” option for breakpoints.  It’s available in the breakpoint right click menu.

image

You can output text and variable values when the breakpoint is hit instead of stopping:

image

The logging will show in the Output Window.  On the downside, it slows down program execution speed, seemingly more than conditional and regular breakpoints.

Object ID

My colleague Andrei Kashcha, master extraordinaire of debugging techniques, shared this with me and I’m starting to use it regularly.  When you make an “object id” for a  class instance, its a globally available reference to that instance for debug inspection and can be used to breakpoint in a single instance or verify which instance you are looking at.

To “Make Object ID”, just select that in the watch window context menu for an initialized variable.

image

That instance can now be referenced globally as 1#:

image

And to breakpoint in just that instance, set a conditional breakpoint with the condition “this == 1#”:

image

ReSharper Class List Navigator

I see a lot of people using this, but its recently become my goto navigation method.  For those of us ReSharper fans (with standard R# key mappings), just press ctl-t and up pops a handy class navigator that supports filtered search with partial class name and Pascal Cased abbreviations such as AVLCN for AVeryLongClassName.

image

July 11, 2011 Posted by | Uncategorized | , , , , , | Leave a comment

I Missed You Resharper

Just spent a week without resharper while starting up a new project.  Here’s the features I used in the first half hour and why I was going crazy without it:

  • create & init Prop/Field from ctor
  • rename var to naming conventions
  • move class to file of proper name
  • lookup/add namespace
  • create backing field for Auto Property
  • create method from inference
  • create field
  • Alt-Up/Down — go to next block
  • add close quote/curly brace, etc.
  • remove unused using directives
  • jump to active file in solution explorer
  • to public for class declaration
  • xunit test runner

The best thing about ReSharper is that most of what I use it for is available via the Alt-Enter quick menu.  Not many hotkeys to learn.

 

October 9, 2010 Posted by | Uncategorized | , | 2 Comments

Cool Resharper Feature

image

This funny blank message magically appeared in my Visual Studio, but using the Next Tip button did tell me about some pretty cool features.

May 4, 2010 Posted by | Uncategorized | , | Leave a comment

ReSharper Withdrawal

ReSharper (R#) is a Swiss Army Knife utility.  It’s an add-in for Visual Studio and it works so seamlessly with the environment, I’m usually not sure if I’m using a ReSharper feature or a Visual Studio feature.  I’ve only been using it a few weeks and I wouldn’t want to work without it.  I know I’ve barely scratched the surface of its features.

My ReSharper license expired and here’s what I missed in the couple hours I was Resharperless:

  • Quick delete for sections.
  • Auto naming variables similar to their types with proper casing.
  • Auto generation of case statement labels.
  • Remote editing

Remote editing:  fixing a problem identified in one section of code by modifying another section of code.  For example, as below, when referencing a private enum throws an accessibility warning, you can use the left hand light bulb to correct the problem where it is noted without going directly to the class itself.  This is more useful when the class is in another file and needs a signature or accessibility change.

image

More great things about Resharper

  • Auto adds using namespace statements.
  • Auto adds framework references to your project (e.g. WindowsBase)
  • Unit test runner – so it replaces TestDriven.Net (sorry TDN, I liked you too)
  • Coding hints.  It will offer suggestions on code refactoring
  • Move class to its own file.  If you make a class anywhere, you can have R# move it to its own properly named file with one click.  You can also have R# rename the file you’re working on when you rename the class with a convenient click.
  • Hot key to create a delegate

Bad things about ReSharper

These are pretty easy to ignore.

  • Suppress inspection with comment allows you to stop it from warning you about specific lines of code, but only at the expense of ugly comments in your code
  • It keeps offering to convert my Linq queries into Method chains which are usually pretty ugly.

Worst Thing About ReSharper

It’s so good with delegates that its stopping me from learning the proper syntax.

Oh well, I think it’s HL Mencken who said:

Progress consists of increasing the number of things we can do without thinking.

Unfortunately, I can’t find the quote, so maybe I’m wrong.  Does anybody know the source of that quote?  If not, then you can quote me on it.  🙂

November 20, 2009 Posted by | Uncategorized | , , , , , | Leave a comment