Blog - Title

Visual Studio 2013 Current Status

  • The Ultimate Visual Studio Tips and Tricks Blog

    TODO Comments in the Task List

    • 21 Comments

    Versions:  2008,2010
    Published:  6/7/2010
    Code:  vstipTool0029

     

    Ever been writing some code and you want to leave a reminder to yourself to do something on a particular line or area?  Did you know about the "to do" comment feature?  It seriously rocks if you have never used it AND, because it goes in the source code, everyone can have access to the information when you do you check-in!

     

    So here's how it works:  In VB you just put any comment in that begins with the letters "todo" (case doesn't matter):

    image

     

    In C#, it's pretty much the same thing (again, case doesn't matter):

    image

     

    C++ requires that the “TODO” be in upper-case or it will not show up in the Task List:

    clip_image002 

     

     

    In C++ for VS2010 you have to explicitly turn this feature on.  Go to Tools | Options | Text Editor | C/C++ | Formatting | Miscellaneous and change Enumerate Comment Tasks to true:

    clip_image004 

     

     

    Regardless which language you use the result is a nice entry in your Task List:

    clip_image006 

     

    NOTE:  In order to see these items, you have to click the drop-down list in the Task List and choose Comments as shown here.

  • The Ultimate Visual Studio Tips and Tricks Blog

    Visual Studio 2012 New Features: Improving User Stories and Requirements with PowerPoint Storyboarding

    • 2 Comments

    For Visual Studio Premium and Ultimate users there is a great new add-in for PowerPoint that can really help you called the PowerPoint Storyboarding add-in.  Using this feature you can quickly draft an interface design and get stakeholder feedback.  Plus, since it’s PowerPoint, even stakeholders can change elements easily to show you what they really want.  Let me show you how this works.

     

    Getting Started

    To get started just go to the Microsoft Visual Studio 2012 program folder and select PowerPoint Storyboarding:

    PowerPoint Storyboarding

     

    This will open up PowerPoint, give you a blank slide, and take you to the Storyboarding tab:

    image

     

    It will also show the storyboard shapes to the right which are searchable via the search box (CTRL + G):

    image

     

    (NOTE:  You can download more shapes by going to http://visualstudiogallery.msdn.microsoft.com/site/search?f%5B0%5D.Type=RootCategory&f%5B0%5D.Value=StoryboardShapes&f%5B0%5D.Text=Storyboard%20Shapes)

     

    From here you typically start with a background from the storyboard shapes:

    image

     

    For this example, I am developing a SharePoint solution so want a SharePoint background:

    image

     

    I can edit existing elements and/or add new storyboard shapes:

    image

     

    I can right-click on any item and add hyperlinks that the user can click on to take them to another “screen” (slide) for more interaction:

    image

     

    If you find yourself using a customized set of shapes frequently just select the shapes and add them to your storyboard shapes:

    image

    image

     

    One of the coolest features is the ability to quickly update your custom shapes while you are working on them as well as export them for other team members to use:

    image

     

    As you gain experience with the tool, here is an example of what you can accomplish:

    image

     

    If you are using Team Foundation Server (you ARE using TFS aren’t you?) then you can also link your storyboard to one or more requirements/user stories with the Storyboard Links button:

    image

     

    The only caveat is you have to store the ppt file in a location that is accessible to others or it will give you this message:

    image

     

    I prefer to use the project portal created by TFS to store my storyboards personally.  Once you have saved the file to a shared location then you can link it to work items.  When you first open the Linked Work Items dialog it will show the collection you are connected to in the title bar:

    image

     

    You can click Link To to link items in the current collection and/or Connect to go to another collection and then run queries for the items you are interested in selecting:

    image

     

    From now on you can see the work items that are associated with with the storyboard and be able to trace the work you are doing back to some requirement/user story/task/etc…

     

    There you have it!  Give the new storyboarding features a try yourself.  If you want to see the docs on this feature, I would check out these two links:

    http://msdn.microsoft.com/en-us/library/hh409276(VS.110).aspx

    http://msdn.microsoft.com/en-us/library/hh301773(VS.110).aspx

    Normally our documentation is *cough* less than optimal but the two items above are actually pretty good.

  • The Ultimate Visual Studio Tips and Tricks Blog

    GREP and SED with PowerShell

    • 10 Comments

     

    So...I like GREP and SED from my old UNIX days and am VERY happy to see that PowerShell can do the same type of functionality with a lot more power in most cases.  I though some of you might like some really simple examples of how to take a text file and do GREP-ish and SED-ish actions.

     

    GREP-ish

    cat somefile.txt | where { $_ -match "expression"}

     

    The command above will search each line of "somefile.txt" to see if it contains the regular expression "expression" and return the entire line if there is a match.

     

     

     

    SED-ish

     

    cat somefile.txt | %{$_ -replace "expression","replace"}

     

    The command above will search each line of "somefile.txt" for the regular expression "expression" and replace it with the string "replace".

     

     

     

    EXAMPLE:

    ==============DATA.TXT==============

    Mary had a little lamb,

    It's fleece was white as snow,

    But the lamb made Mary mad,

    So she ate it.

    =================================

     

    GREP-ish

    cat DATA.TXT | where { $_ -match "Mary"}

     

    returns the following:

    Mary had a little lamb,

    But the lamb made Mary mad,

     

     

    SED-ish

    cat DATA.TXT | % { $_ -replace "Mary","Susan" }

     

    returns the following:

    Susan had a little lamb,

    It's fleece was white as snow,

    But the lamb made Susan mad,

    So she ate it.

     

    ================ Edit 7/14 ==================== 

    A question came up the the other day about putting these results into another text file.  Using redirection this is quite easy.  Here is how it is done:

     

    cat DATA.TXT | % { $_ -replace "Mary","Susan" } > newfile.txt

     

    ============================================

    enjoy :)

     

  • The Ultimate Visual Studio Tips and Tricks Blog

    Visual Studio 2012 New Features: Solution Explorer

    • 11 Comments

    I love the title of this one because I’m sure someone will read this and wonder why I think Solution Explorer is a “new” feature.  I mean, haven’t we had this sucker for a billion years?  Aren’t there cave drawings in France about this feature?  So why is it “new”?  Let me show you!

     

    Search Solution Explorer (CTRL + ;)

    First and foremost, you can now search Solution Explorer!  I’ve been wanting a feature like this since before Solution Explorer was even invented back in my VB 3 days (about 19 years ago).  Here is what things looked like back then:

    image

     

    And from then until Visual Studio 2010 we STILL couldn’t search items:

    image

     

    But now you can!  Just type in any search term into the Search Solution Explorer textbox:

    image

     

    And it will find anything that contains the search term in it:

    image

     

    You can filter the search to choose how broad the search goes by clicking on the drop down arrow to the far right of the Search Solution Explorer textbox:

    (NOTE: searching within file contents doesn’t mean what you think it means.  See the section “More Than Physical” for information)

    image

     

    One other cool feature is you can have Solution Explorer only show you the currently open files by clicking the drop down button just to the right of the Home button:

    image

     

     

    More Than Physical

    In the past, Solution Explorer was relegated to only showing physical elements or those things that help contain / organize those elements (i.e. solution folders).  That’s out the window, too.  Now the experience doesn’t stop at the physical level but extends to logical elements as well:

    image

     

    Which makes searching even more awesome:

    image

     

    If you are using the Preview Tab then clicking on any item in Solution Explorer will go to the file and highlight code if applicable BUT you can’t double click the logical item to open the file for some reason and instead have to double click the filename to open it.

     

     

    Navigation

    Navigation is much improved as well. 

     

    Browser-Like Movement

    After a doing a search, like the one shown above, you can click the Home button:

    image

     

    And Solution Explorer will go back to “normal”:

    image

     

    Clicking the Back button:

    image

     

    Takes me back to the search I just did:

    image

     

    Here is the weird part:  If I reuse the search box and type another search right away it doesn’t remember the previous search I did and I can’t go back; BUT if I click Home between searches then it remembers all my old searches.  I’ve tested this up to 12 entries and it works fine as long as you remember to click Home between searches.

     

    Sync with Active Document

    Occasionally you may be looking at a file but Solution Explorer isn’t on that file.  When this happens a button appears that allows you to sync Solution Explorer with the document you are currently in so you can see where it is in the project structure.

    image

     

    Right Click Experience

    The right click experience is, to say the least, incredible!  Depending on what you select the context menu changes appropriately.  So if I right click a code file this is what I get:

    image

     

    But if I right click a class this is what I get:

    image

     

    And this is the context menu for a method:

    image

     

    Each option changes the view in Solution Explorer to better examine relationships.  The bottom line:  make sure to check out your context menus to change the elements you are viewing in Solution Explorer.

     

     

    New Solution Explorer View

    There used to be a button for creating a new instance of Solution Explorer which was excellent for multi-monitor viewing of code:

    image

     

    The button is gone now (which is a mistake in my opinion) and you can no longer get an entire copy of Solution Explorer in a new window BUT you can get a copy of any project or file in a new Solution Explorer window which is what I have done in the example above.  Just right click any project/file and choose New Solution Explorer View:

    image

     

     

    Team Foundation Server

    If you are using TFS then you can filter Solution Explorer to show you files with Pending Changes:

    image

     

    And there you have it!  As you can see there are quite a few changes in the new, improved Solution Explorer so go explore!

  • The Ultimate Visual Studio Tips and Tricks Blog

    Code Metrics – Maintainability Index

    • 0 Comments

    SKU: Premium, Ultimate

    Versions: 2008, 2010

    Code: vstipTool0134

     

    At long last it is time to look at the final metric from the code metrics (see vstipTool0129, “Code Metrics - Calculating Metrics”): maintainability index. As with the other metrics it is best to start with some definitions. First, from the MSDN main documentation:

    “[Maintainability Index c]alculates an index value between 0 and 100 that represents the relative ease of maintaining the code. A high value means better maintainability. Color coded ratings can be used to quickly identify trouble spots in your code. A green rating is between 20 and 100 and indicates that the code has good maintainability. A yellow rating is between 10 and 19 and indicates that the code is moderately maintainable. A red rating is a rating between 0 and 9 and indicates low maintainability.”

    http://msdn.microsoft.com/en-us/library/bb385914.aspx

    (emphasis added)

     

    Unlike other metrics, there is virtually no ambiguity to reading this value. David Kean on the code analysis team blog provides a view into the values, icons, and colors you could see:

    image

    http://blogs.msdn.com/b/codeanalysis/archive/2007/10/03/new-for-visual-studio-2008-code-metrics.aspx

     

     

    Using this information you can easily see areas of code that may need attention. But what does this look like when you actually use it? I took some sample code and created extreme conditions to show how this looks in actual use. If we just look at maintainability index everything looks fine:

    image

     

    Be careful! This is not the whole picture. Maintainability index is actually a calculation using three metrics. Two of the metrics used are lines of code (see vstipTool0130, “Code Metrics - Lines of Code”) and cyclomatic complexity (see vstipTool0131, “Code Metrics - Cyclomatic Complexity”). Without looking at these you will miss something. Let’s add them to our code metrics:

    image

     

    We have a problem. The lines of code don’t’ really seem excessive but the cyclomatic complexity is very, very high and that is a red flag. We need to dig into the hierarchy to see what is going on. I’ll go two levels down:

    image

     

    Now we see a major problem. Just looking at the maintainability index alone wouldn’t have revealed the issue at a high level but paying attention to the cyclomatic complexity definitely revealed a code smell (http://en.wikipedia.org/wiki/Code_smell) that needed further investigation. At this point we would take action to correct for high cyclomatic complexity.

    The moral of this story is to pay attention to your metrics. At this point you should be well armed to use maintainability index for your code. If you want to get into the details then read on…

     

     

    Digging Deeper

    When dealing with metrics the details can be important. It’s good to see how they are calculated. Fortunately, the Code Analysis Team blog has provided the calculation used for maintainability index:

    Maintainability Index = MAX(0,(171 - 5.2 * log(Halstead Volume) - 0.23 * (Cyclomatic Complexity) - 16.2 * log(Lines of Code))*100 / 171)

    http://blogs.msdn.com/b/codeanalysis/archive/2007/11/20/maintainability-index-range-and-meaning.aspx

     

    This is just one of many ways to calculate maintainability index (http://www.virtualmachinery.com/sidebar4.htm) and there are calculation variants that take into account additional items such as comments. I’ve already covered lines of code (see vstipTool0130, “Code Metrics - Lines of Code”) and cyclomatic complexity (see vstipTool0131, “Code Metrics - Cyclomatic Complexity”). Halstead Volume, on the other hand, is new to our discussions.

     

    The Halstead metrics where created in 1977 by Maurice Halstead to create empirical methods to measure software development efforts. He sought to identify and measure software properties as well as show relationships between them. (http://en.wikipedia.org/wiki/Halstead_complexity_measures) You can find a great description of how to calculate Halstead metrics at http://www.virtualmachinery.com/sidebar2.htm.

     

    Halstead Volume can be defined as “[…] the size of the implementation of an algorithm. The computation […] is based on the number of operations performed and operands handled in the algorithm. Therefore [it] is less sensitive to code layout than the lines-of-code measures.”

    http://www.verifysoft.com/en_halstead_metrics.html

     

     

    Code Analysis

    When using code analysis, the Extended Design Guideline rule set contains a maintainability area:

    image

     

    Inside the maintainability area is a rule for maintainability index:

    image

     

    This rule is triggered when the maintainability index is low. You can learn more about the rule here:

    http://msdn.microsoft.com/en-us/library/bb386043.aspx

    Unfortunately, the documentation doesn’t talk about the thresholds set for this rule but I ran my own experiments and found that at 19 or below this rule will issue a warning by default.

  • The Ultimate Visual Studio Tips and Tricks Blog

    Cut or Delete the Current Line

    • 9 Comments

    Keyboard:  CTRL + L (cut text); SHIFT + DEL(cut text and carriage return); CTRL + X(cut text and carriage return); CTRL + SHIFT + L (delete)
    Command:  Edit.LineCut; Edit.Cut; Edit.Cut; Edit.LineDelete
    Versions:  2008,2010
    Published:  4/4/2010
    Code:  vstipEdit0038

     

    You can quickly and easily do a cut operation by doing the following:

    1. Place your cursor on any line:
      image
    2. Do one of the following commands:
      1. CTRL + L to cut the text only
      2. SHIFT + DEL or CTRL + X to cut the line and the carriage return at the end of the line

    If you want to DELETE the line instead you can use CTRL + SHIFT + L

  • The Ultimate Visual Studio Tips and Tricks Blog

    Visual Studio 2013 Preview: CodeLens aka Code Information Indicators

    • 31 Comments

    [Updated: 7/12/2013: Thanks to John Gardner for the updated info.]

     

    There is only one way to describe this next feature: IT ROCKS!

     

    To use this feature you will need Visual Studio 2013 Preview and Team Foundation Server 2013 Preview as some information comes from TFS.

     

     

    Presenting the Problem

    For me, this is the signature feature in Visual Studio 2013. It’s well thought out and solves multiple issues we face as developers. But what IS it exactly? The best way to demonstrate it is to remind you what life was like before we had it. Here is a method (from the TailSpin toys sample code) the way we have seen it in the past:

    5-16-2012 6-04-11 PM

     

    What if I need to find all the references to this method? I can press SHIFT+F12 and get results in the Find Symbol Results window:

    5-16-2012 6-09-48 PM

     

    How about the tests associated with this method? I’d either dig through the references above or dig into the Test Explorer window and see what I can find. But what if I want to know who last changed this method? How about the number of times this code has changed? Now I have to dig into other windows to locate the data. In short, I can get all the information I need but have to go to several different places to get it.

     

     

    Solving the Problem

    The Visual Studio team has come up with an elegant solution to the problem: show information about the code WITH the code. It’s a great addition to the development experience. Originally called Code Information Indicators, the marketing folks have now dubbed this CodeLens.

     

    Turning It On

    CodeLens is on by default but I want to point out the information you can choose to view. Go to Tools | Options | Text Editor | All Languages | Code Information Indicators:

    5-16-2012 6-29-59 PM

    (NOTE: a faster way to get here is to press CTRL+Q for QuickLaunch and type the word “information” into the search area then select the Code Information Indicators entry)

     

    I’ll show these in the order you will most likely see them when you begin using this feature.

     

     

     

    Show References

    5-16-2012 6-38-10 PM

    The first indicator you will typically notice is the references. This is just like using Find All References but instead of presenting the information in another window a summary of references is shown with the code. With any of the CodeLens indicators you can access the details in a couple of ways.

     

     

    Mouse Access

    You can click on any indicator to see the results:

    5-16-2012 6-56-14 PM

     

    Also there is a scroll bar (if needed) to allow moving through multiple entries:

    5-16-2012 6-57-02 PM

     

     

    Keyboard Access

    If you don’t want to take your hands off the keyboard, you can simply hold down your ALT key on your keyboard and each indicator will show a number above it:

    5-16-2012 7-02-04 PM

     

    Pressing ALT + [indicator number] will show the information within. In this example, ALT+2 will open the references. These numbers are static so you can always depend on them. Regardless of where you are, ALT+2 will always show the references.

     

     

     

    Show Tested By

    With any method we often want to know what tests are associated with it. The Show Tested By option will show what tests are associated with your code and an overall status indicator:

    5-16-2012 7-35-20 PM

     

    As you can see in this example, the tests haven’t been run yet as shown by the icon to the left of the test summary. If I click on the Show Tested By section or press ALT+3:

    5-16-2012 7-42-07 PM

     

    Then I get the information window:

    5-16-2012 7-49-55 PM

     

    Notice we can run the currently selected test or run all tests. To access the Run All or Run links with just your keyboard just use your TAB key. If you want to examine an individual test method you can press Enter (or Double Click) any entry in the information window and the editor will show the test method details:

    5-16-2012 8-02-04 PM

     

    Let’s jump back to our original code. Looking at the Show Tested By indicator we can see that if all the tests have passed this is the result:

    5-16-2012 8-06-05 PM

     

    If any tests fail, then we will see something like this:

    5-16-2012 8-10-03 PM

     

    You can see any tests that failed by opening the Show Tested By area:

    5-16-2012 8-11-33 PM

     

     

     

    Show Test Status

    Now let’s discuss the Show Test Status indicator. Normally, when we look at a test method this is what we see:

    5-16-2012 8-22-36 PM

     

    However, once we run our tests, it would be nice to see the status of the run with the test method itself. This is where Show Test Status comes in. By turning this on we can see the status of the last run represented as an icon (to the left of the references information):

    5-16-2012 8-27-31 PM

     

    If you want to see the latest test result, you can Click the icon or press ALT+1:

    5-16-2012 8-29-33 PM

     

    And see the test result window:

    5-16-2012 8-34-24 PM

     

     

     

    Show Authors and Show Changes

    The Show Authors and Show Changes options actually show the same information but filter it in two ways. Both are updated when you Get Latest from source control. Show Authors will show the name of the last person to make a change plus a count of any other unique individuals who have worked with the same code:

    5-16-2012 9-04-43 PM

     

    Whereas Show Changes will show the total number of changes in the code’s history:

    5-16-2012 9-14-16 PM

     

    Selecting either of these by using your mouse or by pressing ALT+4 and ALT+5 respectively:

    5-16-2012 9-17-18 PM

     

    Opening either one of these indicators will reveal the following:

    5-16-2012 9-19-59 PM

     

    This is where things get interesting. You can Right Click any entry in this window to be presented with three options that we will examine in detail:

    5-16-2012 9-24-40 PM

     

     

    View Diff Of Changeset[Number]

    This will show the difference between the selected changeset and the one prior for comparison:

    5-16-2012 9-29-10 PM

     

     

    Changeset Details

    This choice will show the details of the changeset in Team Explorer:

    5-16-2012 9-30-39 PM

     

     

    Send Email To [Author]

    Pretty self-explanatory, this option will open up your default email program and allow you to begin crafting an email to the author of the changeset with a link to remind the author of the code changed:

    5-16-2012 9-34-22 PM 

     

     

     

    Miscellaneous

    In this section I’ll show some additional items that may be of interest to you as you discover more about CodeLens.

     

    Navigating Between Information Windows

    Once you have opened any information window:

    5-16-2012 12-04-12 PM

     

    You can use RIGHT ARROW or LEFT ARROW to move between the other information windows.

    (NOTE: The team that works on this let me know that the official keyboard shortcut for moving between these windows is ALT+RIGHT ARROW and ALT+LEFT ARROW. Be aware that just plain ARROW keys may stop working in future iterations of the build and you will need to use the official keys to move between windows here.)

     

     

    Skipping Lines

    I began this article saying that this feature is well thought out. Nothing emphasizes my point more than the way the indicator are treated in the editor. Rather than being intrusive and even throwing off your line counts by treating the indicators as a line of code the indicators are simply decorations added in the editor and are not counted as an actual line:

    5-16-2012 10-14-49 PM

     

    The concept of being non-intrusive is so ingrained into this feature that even the cursor will skip over it when you are using your keyboard to move between lines in the editor.

     

     

    Changing Indicator Fonts and Colors

    If you want to modify the font and/or color of the indicators you can go to Tools | Options | Environment | Fonts and Colors then select Show Settings For the Code Information Indicators:

    5-16-2012 9-54-27 PM

     

    Experiment with these to find settings that are appealing to you.

     

     

    Turning It Off

    If, for some reason, you don’t like this feature then you can always turn it off by going to Tools | Options | Text Editor | All Languages | Code Information Indicators and disable the feature.

     

     

     

    Finally

    CodeLens is truly an epic addition to the Visual Studio world. I am a huge fan of this feature. Try it yourself and tell me what you think! :)

  • The Ultimate Visual Studio Tips and Tricks Blog

    How to Turn Off Automatic IntelliSense

    • 5 Comments

    Menu:  Tools -> Options -> Text Editor -> All Languages [or specific language] -> General -> Statement completion
    Versions:  2008,2010
    Published:  5/1/2010
    Code:  vstipEdit0054

     

    image

    So maybe IntelliSense isn't for everyone.  It can sometimes annoy people when it automatically pops up.  You can disable automatic IntelliSense and still have it come up anytime you want with CTRL + J.

  • The Ultimate Visual Studio Tips and Tricks Blog

    World of Warcraft Install on Vista

    • 82 Comments

    Okay, so I bit the bullet and installed WOW on Vista last night.  I am going to install the patches tonight and see how it works.  If anyone has had issues, lemme know.  BTW, feel free to catch up with me on Eredar (70 NE Priest -- SQLVarChar).  I don't play as often as I used to but still try to get in  a couple of instance runs on weekends.

    Z

  • The Ultimate Visual Studio Tips and Tricks Blog

    AJAX fun with the dreaded 'sys is undefined' error

    • 28 Comments

    If you have started to play with AJAX then you have most likely come across the dreaded 'sys is undefined' error.  I found numerous articles on how to get this working but the best ones all point to making sure you have the correct entries in your web.config.   So to summarize what I have read:

    1)  Go to C:\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\{your version of AJAX}

    2)  Open the sample web.config file and make sure you have the same entries in your web.config

    3)  If you don't then copy and paste is your friend :)

    4)  See if the app works now

     Here are a couple of articles to assist if you are still having issues:

    Chris Riccio's blog   http://weblogs.asp.net/chrisri/archive/2007/02/02/demystifying-sys-is-undefined.aspx

    Lorin Thwaits's blog  http://geekswithblogs.net/lorint/archive/2007/03/28/110161.aspx

     

Page 2 of 135 (1,345 items) 12345»