Blog Archive

Labels

Showing posts with label visual studio. Show all posts
Showing posts with label visual studio. Show all posts

Friday, September 15

Visual Studio Macro

Never thought I'd be posting VB to my blog, but here's a little Visual Studio macro to switch between a Class file and it's associated TestFixture. The macro assumes a ClassNameFixture naming convention. Also sorry if my VB sucks, it literally took me 3 minutes plus asking a coworker to figure out how test for null.

Enjoy:

Imports System
Imports System.IO
Imports EnvDTE
Imports EnvDTE80
Imports System.Diagnostics

Public Module TestFixtures

    Public Sub SwitchBetweenClassAndFixture()
        Dim active As Document, filename As String, extension As String
        Const fixtureSuffix = "Fixture"

        active = DTE.ActiveDocument
        If Not active Is Nothing Then
            filename = Path.GetFileNameWithoutExtension(active.Name)
            extension = Path.GetExtension(active.Name)
            If filename.EndsWith(fixtureSuffix) Then
                DTE.ExecuteCommand("Edit.OpenFile", filename.Substring(0, filename.Length - fixtureSuffix.Length) + extension)
            Else
                DTE.ExecuteCommand("Edit.OpenFile", filename + fixtureSuffix + extension)
            End If
        End If
    End Sub

End Module

Thursday, June 29

Best Visual Studio Help Option

Best Visual Studio Help option I've unchecked, today: Tools > Options > General: Reuse topic window. Now hitting F1 in Visual studio is a lot more like my web browsing experience (external links open a new tab within Firefox). Ctrl-F4 or middle-click the tab to close it.

Update: to be clear, I'm talking about Help/Documentation Viewer/what used to be called MSDN; not actually Visual Studio itself.