Blog - Title

Visual Studio 2013 Current Status

  • The Ultimate Visual Studio Tips and Tricks Blog

    Regular Expression Engines: DFA and NFA Are Your Friends


    Today is episode 8 of my continuing series on regular expressions.  In this one, we tackle regex engines and what they mean to you.  Wheeeeeeeee!


  • The Ultimate Visual Studio Tips and Tricks Blog

    Visual Studio 11 Developer Preview: Code Clone Detection (aka Code Clone Analysis)


    [NOTE: This post has been depricated, you can find the updated post here:]



    Versions: Visual Studio 11 Developer Preview


    Make sure to get your copy of the new book from Sara and me:

    Coding Faster: Getting More Productive with Microsoft Visual Studio




    Note: As always with pre-release software, some of the features may not make it into the final version or may change significantly before RTM. Also, although I will only show features that are publicly available, I may be using a slightly older or newer version of the build than you are so there may be slight differences in the feature set I show and the feature set you currently have.




    In my travels across the country, with my fellow Evangelist, Clint Edmonson, talking about Visual Studio we often come across great stories to tell. One of our favorite true stories is of a customer that had a web application running very slow. We ran code metrics against it and, sure enough, the Page_Load event had 9,000 lines of code in it. Naturally we were curious so we opened it up to see that it was basically the same if statement copied over and over. Apparently they needed to find out who was coming into the website in order to show customized content and the solution they came up with was this massive set of statements.


    For better or worse we have all had code that gets copied throughout our solutions. Until now there was no tool to tell us there were copies and, instead, we had to rely on other metrics such as lines of code to hopefully reveal any code smells. Now, however, we have the new Code Clone Detection (aka Code Clone Analysis) feature.


    According to the documentation:

    Code clones are separate fragments of code that are very similar. They are a common phenomenon in an application that has been under development for some time. Clones make it hard to change your application because you have to find and update more than one fragment. Visual Studio can help you find code clones so that you can refactor them.”



    Specific Clones

    You can find clones of specific code by selecting the segment you are interested in:



    Then Right-click on the selection and choose Find Matching Clones in Solution from the context menu:



    Visual Studio will search for code clones and produce the result in the new Code Clone Search Results window:



    The original line of code is put in a group on its own and then all the matches are put into a different group. You can expand the groups to see the specific locations of the matches:





    Solution Clones

    Besides looking for specific clones you can also just look for code clones for the entire solution. This will search the entire solution for duplicate code and display the results. To use this feature go to Analyze | Analyze Solution for Code Clones:



    This creates a result set for the entire solution:



    By default it groups and sorts the results by the strength of the match. Exact matches come first then those matches that may be close but not exact come next. As you can see the other terms used are Strong, Medium, and Weak in this example.




    Reviewing Matches

    Once you have the result set, there are a couple of ways you can compare them against each other.


    Comparison Tools

    Although I don’t show it here, if you have a comparison tool configured you can Right-click on any two items and select Compare from the shortcut menu. You would know if you have this feature available by going to Tools | Options | Source Control | Team Foundation Server and click on Configure User Tools.



    Manual Comparison

    If you don’t have a comparison tool you can do manual comparisons between two entries in the list. If the clones are in different files then you can just double-click each one and file tabs will be available for you to look at for comparison:




    When it comes to comparisons in the same file I’ve only found one good way to accomplish this so far. Granted, I have just started playing with this feature so there might be something coming or something I missed that makes this easier. Here is a series of steps to compare two items in the same file.


    First, find the first entry you want to look at and double-click on it to open a file tab and highlight the code segment:



    Now make a copy of the current code window by going to Window | New Window:



    Next, go to the second entry you are interested in and double-click it. The result should be one code segment on each tab so you can compare the two:



    You can do this for as many entries in the list as you like. Just repeat these steps for each entry you want to compare.




    What Is Found

    You are probably curious as to what is found by this tool. The heuristics for finding clones will find duplicates even if the following changes have happened:

    · Renamed identifiers.

    · Insert and delete statements added.

    · Rearranged statements.




    What Is Not Found

    There are some rules for what is not found as well. I have taken this list from the documentation pretty much verbatim.

    · Type declarations are not compared. For example, if you have two classes with very similar sets of field declarations, they will not be reported as clones. Only statements in methods and property definitions are compared.

    · Analyze Solution for Code Clones will not find clones that are less than 10 statements long. However, you can apply Find matching clones in solution to shorter fragments.

    · Fragments with more than 40% changed tokens.

    · If a project contains a .codeclonesettings file, code elements that are defined in that project will not be searched if they are named in the Exclusions section of the .codeclonesettings file.

    · Some kinds of generated code are excluded:

    · *.designer.cs, *.designer.vb

    · InitializeComponent methods

    · However, this does not automatically apply to all generated code. For example, if you use text templates, you might want to exclude the generated files by naming them in a .codeclonesettings file.




    Code Clone Settings and Exclusions

    A settings file is available to configure this feature at the project level. I tried to use it at the solution level but it didn’t work so this is definitely a per-project activity. Currently we have only announced the ability to do exclusions in the file but there will most likely be other elements that are added later on. The file is just XML with a .CODECLONESETTINGS extension. The only requirement for use is that the file exists in the top level directory of the project.


    The base elements consist of a CodeCloneSettings element with an Exclusions child:



    Within the Exclusions element you can have the following children:


    This element is used to indicate files that should be excluded from analysis. Path names can be absolute or relative and you can use wildcards as well. So, for example, to ignore all the C# text template files that have been put in their own directory (called MyTextTemplates) you might have the following:




    <Namespace>, <Type>, and <FunctionName>

    You can also exclude namespaces, types, and functions. Just like files these items can use absolute names or names with wildcards in them. Here is an example of what it might look like:



    Example Scenario

    In the Tailspin Toys sample that I have there is some generated code in the TailSpin.SimpleSqlRepository project that is the bulk of the duplications:



    Code clone analysis doesn’t automatically know to ignore text templates so I have created an XML file called TailSpinRepository.codeclonesettings and inserted an entry like this:



    Now if I run clone analysis here is the result:



    As you can see the results are significantly less than the first time the analysis ran. It’s common to create several exclusions in different projects to weed out noise in the analysis results.





    Code Clone Detection is a great new tool to add to your arsenal for improving code quality. Combined with Code Analysis and Code Metrics, this will help quickly find potential issues.

  • The Ultimate Visual Studio Tips and Tricks Blog

    Surround with a Code Snippet (C# Only)


    Keyboard:  CTRL + K, CTRL + S
    Menu:  Edit | IntelliSense | Surround With
    Command:  Edit.SurroundWith
    Versions:  2008,2010
    Published:  4/21/2010
    Code:  vstipEdit0052



    This is one that even people who know about snippets tend to forget.  You can actually put a snippet AROUND existing code.  Assuming you have some code selected:



    Just press CTRL + K, CTRL + S:



    Then type the statement you want to surround the code with.  In this case, I’ll use an “if” statement:



    Hit your TAB key once and you get your result:



    Now you can put in your condition and any additional logic you want.  Pretty cool stuff!

  • The Ultimate Visual Studio Tips and Tricks Blog

    Chaotic Moon’s Board of Awesomeness: Kinect Is Your Friend




    What's red, goes 32MPH, and is controlled by a wave of your hand? 


    It's the Chaotic Moon Labs "Board of Awesomeness"!!


    My good friend, Phil Wheat, works over there and he has been working on this most excellent device.  If you've been following CES, you've probably seen their Kinect controlled, powered longboard all over the place but some things you might not know about it is that it's all programmed in C# on Visual Studio 2010


    The board is made up of a number of hardware components, but the main parts are the Kinect Beta 2 SDK and a Phidgets analog out board.  Visual Studio was the key to tying these systems together and making the project take weeks, not months to put together.  Even more awesome, is that with the Visual Studio debugger and refactoring tools, as tests showed improvements that could be made - changes could be made in the field, on the fly and tested without having to go back into the lab to rework the code.


  • The Ultimate Visual Studio Tips and Tricks Blog

    Visual Studio 11 Beta arrives on February 29, 2012



    In case you haven’t heard, Visual Studio 11 Beta will be available on the 29th.  I’ll post more information once it pops but wanted to get everyone pointed to a few resources to tide you over Smile

    The Road to Visual Studio 11 Beta and .NET Framework 4.5 Beta


    Sneak Preview of Visual Studio 11 and .NET Framework 4.5 Beta


    Coming Soon: Team Foundation Server Express


    Introducing the New Developer Experience – Part 1


    Link to learn more about Visual Studio 11 Beta

    Visual Studio 11 Home Page

    Link to learn more about Visual Studio 11 Beta

    What's New in Visual Studio 11

    Link to learn more about Visual Studio 11 Beta Go Live

    Visual Studio 11 Beta Go Live

  • The Ultimate Visual Studio Tips and Tricks Blog

    Visual Studio 11 Beta is Here!!




    If you haven’t heard yet, yesterday we shipped the latest installment of our IDE.


    I’ve updated the navigation links to point to the latest release but I’ll summarize here for folks.


    If you just want the bit for Visual Studio, you can get them here:


    I suggest a more full experience when playing with the new products.  The good news is Brian Keller has updated his famous virtual machine and demos to the latest release which gives you a nice environment to experiment:


    So what now?  Well I’ll be posting articles on what’s new/changed in this release and how you can leverage it.  Also, let me know what YOU think about this release. 


    I’ll preempt the coming posts with the obvious statement about the color and iconography changes.  I know for many people the initial reaction, like mine, will be to  reject it.  However, I’m reminded of the function bar in Office when it was first introduced and felt the same way about it.  Now I can’t live without it.  So my ask is this:  If your initial reaction to the IDE change is to reject it then, like me, give it three months of playing around in it.   If you still don’t like it then at least you gave it a fair shake.  That my .02 on the subject so far…

  • The Ultimate Visual Studio Tips and Tricks Blog

    Windows 8 Consumer Preview: The Ultimate Link List




    Some folks had mentioned that I forgot to talk about the Windows 8 Consumer Preview that launched at the same time as VS11.  So, for your enjoyment, I present the uber list of links for doing Windows 8 stuff Smile



    Developer downloads




    Windows 8 Consumer Preview Download

    Windows 8 Consumer Preview download (web installer or ISO’s), videos, and FAQ’s.

    Developer downloads for Metro style apps

    Visual Studio 11 Express and the Windows 8 SDK + all the extra tools and SDK’s for Metro style app development.

    Design assets for Metro style apps

    100+ Photoshop files with common controls, shell components, tiles, icons, animation clips, color wheel references, and more.



    Metro style app developer content




    Windows Dev Center home

    Links to Metro style app, Desktop app, Hardware, and IE development.

    Metro style app development home

    Links to key resources for designing, developing, and selling Metro style apps.

    Product guide for developers

    Windows 8 Consumer Preview Product Guide for Developers.

    Official documentation

    Comprehensive docs, articles, quickstarts, roadmaps, tutorials, checklists, developer agreements, and whitepapers covering all aspects of app design, development, and selling:

    · Getting started

    · Planning apps

    · Designing UX for apps

    · Developing apps

    · Packaging apps

    · Debugging and testing apps

    · Selling apps

    · API reference

    · Concepts and architecture

    · Language reference

    · End-to-end apps

    Design resources

    Design principles, UX design patterns, detailed UX guidelines, downloadable design assets, assessing usability.

    Selling apps in the  Windows Store

    Windows Store, developer agreements, and checklists to prepare.

    Developer downloads for Metro style apps

    Visual Studio Express and the Windows 8 SDK + extra tools and SDK’s for Metro style app development.

    Metro style app samples

    Over 200 official samples from Microsoft are available in multiple programming languages. You can copy code inline, upload new code, rate, and leave comments.

    Developer forums

    Developer forums for Metro style apps covering designing, developing, and selling apps.

    Blogs for developers

    Blog Name



    Building Windows 8 blog (B8)

    An inside look at how, what, and why different features of Windows 8 are being built. This blog is written by Windows President Steven Sinofsky together with members of the Windows engineering team.

    Windows Store blog for developers

    All about doing business in the Windows Store. Members of the engineering team who’ve built the Windows Store write posts along with Antoine Leblond, Vice President of Windows Web Services.

    Windows 8 app developer blog (D8)

    Explores best practices for coding and designing Metro style apps.  It is written by the team of developers who are building Windows 8.

    IE blog

    Windows Internet Explorer Engineering Team Blog.

    Inside Windows Live blog

    The engineering behind Hotmail, Messenger, SkyDrive, and Windows Live.

    Visual Studio Blog

    The official source of product insight from the Visual Studio Team.

    The Windows Blog

    Consumer and general interest topics.


    Social channels for developers



    Facebook (developer)

    Twitter (Building Windows 8)

    Twitter (Windows Dev Center)


    Channel 9



    Desktop app developer/partner content




    Desktop app certification requirements

    Certification requirements for Windows 8 desktop apps.

    Desktop App Certification Kit

    The Windows 8 SDK includes the Windows App Certification Kit to test desktop apps and get them ready for certification.

    Compatibility Cookbook

    Tips and fixes for common issues with desktop apps for the Windows 8 Consumer Preview and software for Windows Server 8 Beta.

    Compatibility Center

    Compatibility of desktop apps and devices with Windows 8.



    Hardware developer/partner content




    Hardware Certification Requirements

    Windows 8 Hardware Certification Requirements and Policies

    Hardware tools and certification kit

    Windows Consumer Preview Kits and Tools for hardware development

    Driver development documentation

    Developing, testing, and deploying drivers

    Hardware and driver community resources

    Forums, blogs, and newsletters for the hardware and driver developer community.

    Compatibility Center

    Compatibility of desktop apps and devices with Windows 8.

  • The Ultimate Visual Studio Tips and Tricks Blog

    Branching and Merging Deck Available



    Main Branch



    For those that don’t know yet, I’ve switched roles in Microsoft and am now more focused on Visual Studio as well as Team Foundation Server features.  I recently had a customer want an overview of branching and merging based on the ALM Rangers’ guidance found here:



    I created a deck to present and am making it available as part of the launching my new section on the right-hand navigation for TFS.  To get my deck you can just click on the new area in the right-hand navigation off my main blog page or you can go here:

  • The Ultimate Visual Studio Tips and Tricks Blog

    Visual Studio 11 Roadshow Materials






    We are almost done with our Visual Studio 11 Roadshow so I wanted to make the mats available for folks that wanted them. 


    SQL Server Data Tools (SSDT)

    You can get general info about SSDT here:


    My good friend Erik Leaseburg has some great slides that he presented on SSDT at one of the gigs here:  (look for the ppt entitled Database Development with SQL Server Data Tools)


    You can find my content on here: (look under Visual Studio 11)

  • The Ultimate Visual Studio Tips and Tricks Blog

    Entity Framework 4.1: Expert’s Cookbook





    I recently had the pleasure of reading a great book and wanted to share.  Entity Framework 4.1:  Expert’s Cookbook gives insight into reliable usage of EF in real-world environments.  Here is a blurb from Amazon on the book:


    This book takes a step-by-step problem solving approach that leads you through a problem and explains each step in detail to accomplish the goal. This books gives you concrete code examples as well as detailed information on the decisions involved. This book is for intermediate to advanced .NET developers who have used LINQ to SQL or Entity Framework in some form but want to have more control over the implementation.


    You can get your hands on the book by going here:


    Hope you enjoy it as much as I did Smile

Page 130 of 135 (1,345 items) «128129130131132»