Did you know… Remove unused using statements? – #240

This was tip #17 in my TechEd VS 2008 IDE Tips and Tricks Talk

In C#, there’s the option to remove any of your unused using statements.  This is especially helpful if you’re reusing some sort of template over and over again.  Instead of having to comment out each line, compile, see whether the compile was successful, then either remove or uncomment the line, you can bring up the editor context menu (just right click in the editor), and choose Organize Usings – Remove Unused Usings.  This will do all the hard work for you.

RemoveUnusedUsings

Technorati Tags: VS2008Tip

Did you know… You can set conditional breakpoints? – #239

This was tip #16 for my TechEd VS IDE Tips and Tricks talk.

I believe this has been around since 2005, but maybe the white ‘+’ is new for 2008?

When you only want to break under certain conditions, you can right-click on a breakpoint red circle (or go to the Breakpoints Window and bring up the context menu on a given breakpoint) and select Condition to bring up the dialog box for conditional breakpoints. 

Conditional Breakpoints on Context Menu

You’re given two options: break only when the specified expression is true or break only when the specified value has changed.  For this example, since I’m in a for loop, i’ll break when the value of i > 5.

breakpoint condition message box

You’ll notice that the breakpoint circle now has a red plus on it to indicate it is conditional.

conditional breakpoint icon

Technorati Tags: VS2005Tip,VS2008Tip

Did you know… You can use data tips to edit a variable’s content- #238

This was tip #19 in my TechEd VS 2008 IDE Tips and Tricks talk.

Whenever you are debugging and want to change the contents of a variable, you can drag and drop the variable into the Watch Window.  But, you can also use data tips to change the variable without leaving the editor.

Hover over a variable when you have hit a breakpoint.  You’ll notice a glorified tool tip appear.  This is actually a “data tip”.  You can click on the value of the variable to go into an edit mode.  Change the contents of the variable and press Enter to commit. 

Data Tip for the variable 'i'

If you have the Autos window open, you’ll notice the color change, implying the commit was successful.

Autos window shows change in red

Technorati Tags: VS2005Tip,VS2008Tip

21 signs a geek girl is into you

This cracked me up this morning. 

http://on365.co.uk/data-centre-content/

My personal favorites (because i’ve been known to do this) are

  • She stops blogging in front of the TV and talks to you.
  • The first time you used the Command Prompt in front of her, she screamed in excitement.
  • She devotes an entire blog entry to you
  • She invites you to a romantic night at her place that involves popcorn and Tron.
  • She leaves you a love post – its written entirely in Visual Basic.

I better stop here.  =D

A few more i would add are

  • She offers to play the “i don’t know how computers work” part at the computer store when buying your next computer
  • She tells you the next time she sees you, “When i was debugging that array out of bounds exception due to my off-by-one error in that for loop, I decided to pause for a second to think about how much fun i have being with you.”  (there’s a larger joke behind this one that involves air force fighter pilots, don’t ask)

Enjoy

Did you know… You can use Tracepoints to log “printf” or “console.writeline” info without editing your code? – #237

This was tip #15 in my TechEd 2008 VS IDE Tips and Tricks talk.

This is a new feature for VS2008.

On a given line of code where you want to log the value of a variable, you could do the old fashion way of doing a Console.Writeline() or a PrintF().  But in VS 2008, there’s a new feature called tracepoints.

Just right-click, select breakpoints, but instead of Insert Breakpoint, select Insert Tracepoint.

Insert Tracepoints from Context Menu

This will bring up the Tracepoint dialog, where VS gives you some helpful defaults.  But for this example, the really helpful default is in the descriptive text for logging the contents of a variable.

Tracepoints dialog

You’ll notice that the editor shows a diamond instead of a circle.

Tracepoints indicated by a diamond

And the tracepoints are logged in the Output Window’s Debug Pane

Debug Window Output Pane logs tracepoints

Technorati Tags: VS2008Tip

Did you know… VS has a file window layout mode that you can customize? – #236

This is a part of tip #12 of my TechEd 2008 IDE tips and tricks talk.

Visual Studio comes with 4 window layouts: Design, Debug, Full Screen Mode, and File mode.  My guess is that file mode is the least used, since you can only enter it by opening a file from the command line.

FileWindowLayout

This will open the Visual Studio Environment in the “file” window layout.  You’ll note in the below image that there are no tool windows showing and the text editor toolbar is showing.  This is the default in the General Development Settings.

FileWindowLayout1

You can make any customizations here and they’ll persist across window layout states (meaning if you open a project, all the tool windows will pop back – because you’re now in design mode).  Your customizations will be persisted across Visual Studio sessions.  Whenever you shut down the shell, these customizations are saved to disk.  They are also saved as a part of your .vssettings file (Tools – Import / Export settings).

Technorati Tags: VS2005Tip,VS2008Tip

Did you know… You can set a breakpoint on a function from the Find Combo Box? – #235

Today’s tip was a part of tip #8 from my TechEd 2008 IDE Tips and Tricks talk on using Visual Studio Commands from the command window and the find combo box.

In the standard command bar, you’ll see the Find Combo Box right next to Find in Files.  You can obviously type in a function name and hit enter to search, but where’s the fun in that?

Foo method in find combo box

Type in the name of the method, as i have above, and hit F9.  You’ll notice the breakpoint is set at function foo.

Breakpoint set at method foo

Why did this happen?

F9 is bound to a command called Debug.ToggleBreakpoint.  If there’s text in the find combo box and you run a VS command from within the find combo box, VS will use that text as the command parameter.  In the case of F9, VS toggled a breakpoint at the specified function, hence setting a breakpoint at foo().

Technorati Tags: VS2005Tip,VS2008Tip

Did you know… You can insert a snippet via “tab tab” – #234

This was tip #7 from my TechEd 2008 VS IDE Tips and Tricks.  A few months ago, I had dinner with Alan Stevens, Chris Woodruff, and a few others who were creating one of the Microsoft certification exams.  One of the developers said, “hey sara, you need to blog about Snippet Tab Tab.”  I was blown away.  i had tested this feature inside and out, and never had heard of “tab tab.”  It turns out that it is just the sequence of keystrokes you use to insert a snippet, but i never even thought to refer to it as the “tab tab” feature.

I’m not a C# developer.  I spent the majority of my time writing code in VB during my software testing days.  Whenever I need to use C#, i heavily rely upon code snippets, since i don’t recall the syntax off the top of my head.

When in the appropriate place in the editor, you can type in the keyboard shortcut of a snippet, like “for”

SnippetTabTab1

In this state, you can simply press tab twice to insert the snippet, or stated more market-ing-ly (if that’s a word), “tab tab.” 

Why twice?  Press it once to auto-complete statement completion.  If you just type ‘f’ for “for”, and the “for” is highlighted, you can just press tab once to complete the word for.  Press it twice to generate the snippet, since the cursor will be at the end of the word “for” in the editor.

SnippetTabTab2

And the moral of the story is “<snippet> tab tab.”

Technorati Tags: VS2005Tip,VS2008Tip

Did you know… How to increase your Visual Studio environment fonts for presentations? – #233

Thanks to everyone who attended my talks on Friday.  Wow.  What a great turnout and response!  I really appreciate the kind words.  Charlie Calvert and I worked so hard this past month to get the talk ready.  I’m so happy to see it was well-received.

For this week, i’m going to write-up tips from the talk that weren’t already covered in the Tip of the Day series.

For TechEd 2008, the speakers were given the following fonts and colors suggestions.  If you are doing any upcoming presentations, i highly recommend using these settings.

Go to Tools – Options – Environment – Fonts and Colors, and under the Show Settings For combo box, make the following changes:

Text Editor: Arial 14

Editor Tooltip: Calibri 14

[All Text Tool Windows]: Tahoma 13

[Watch, Locals, and Autos Tool Windows]: Tahoma 13

Environment Font: Calibri 14 – Note: this is a new VS2008 Feature.  You can now customize everything else in the shell that isn’t covered by a specific setting.

FontAndColorsPresentations

Technorati Tags: VS2005Tip,VS2008Tip

Did you know… What settings are contained in the “New Project Dialog Preferred Language” category? – #232

Oh boy… i’m doing 2 talks at TechEd today!  One is the big Visual Studio 2008 IDE Tips and Tricks talk (repeat from Charlie’s talk on Tuesday), and the VS Tip of the Day.  Hope i’m doing well out there.  =D  All i can say is that as soon as TechEd is over, i’m going to sleep for a week!

If you go to Tools – Import / Export Settings – Export Settings (i’m choosing export settings because it is faster to get to in the UI), you’ll see the list of categories that are contained in a .vssettings file – your development environment settings file, or profile =D

The first one i want to discuss is the New Project Dialog Preferred Language category.

New Project Dialog Preferred Language category

As noted in the description, it organizes the New Project Dialog folders based on the preferred language.  If C# is preferred, then all the C# projects are listed at the top of the list, and all the others are collected towards the bottom. 

The General Development Settings uses the defaults that we’ve been used to since the 2002 days, as shown below.

New Project Dialog in General Development Settings

Now, let’s see the dialog using the Visual C# Development Settings.  (i’m choosing C# today because i’ve been working non-stop with Charlie Calvert to put together this TechEd talk.)

New Project Dialog using the C# Environment Settings

Technorati Tags: VS2005Tip,VS2008Tip