Visual Studio Tips and Tricks – Checking code dependencies visually


    VisualStudioLogoEver had to make changes to someone else’s code or figure out what might be impacted by a change to a class? You will love the ability to visualize the structure of the code.

    FYI – this feature is only available in Visual Studio Ultimate. If you are a student and you have access to DreamSpark Premium you can get Visual Studio Ultimate for free! If you are in a technical program and don’t have DreamSpark Premium, talk to your professor about getting all the students in your program the best development software for free!

    • Ever had to fix a bug in someone else’s code?
    • Ever had to make changes to code you wrote a year ago but haven’t touched in months so you don’t really remember how you set up all the classes?
    • Ever tried to explain how code you wrote is structured to another developer or a professor?
    • Ever had to figure out what to retest or what might be impacted by a code change?

    If you answered yes to any of these questions, you will appreciate the ability to show code dependencies visually. This feature requires Visual Studio Ultimate, but it’s incredibly easy to use!

    1. Open your project in Visual Studio 2012 ultimate.

    2. From the menu select Architecture | Generate Dependency Graph | For Solution

    You will see the dlls that make up your solution. I’ve created a dating service Windows Phone app that doesn’t call any external dlls so at first it looks pretty unimpressive.


    3. Expand the dll that contains your code and you can drill down to see a dependency graph that shows each of your classes.


    So instead of reading through all that code to try and figure out how you structure your classes, you’ve got a quick and easy way to visualize it right at your fingertips! This also helps when you are about to make a change to one of the classes and aren’t sure what code might be affected by your change.

    If you have any tricks for checking code dependencies or navigating through code, please share! I’ll keep all the VIsual Studio tips and tricks I share here!

  • Go DevMENTAL

    New toys! The Surface 2 and Surface Pro 2 – seriously productive and fun tablets!


    Surface 2The next evolution of the Surface tablets, see what’s new and improved!

    To pre-order or find more information check out the official Surface site or read the announcement on the Surface blog.



    Surface 2

    Let’s start with the highlights of the Surface 2 – this is the evolution of the Surface RT.


    • Thinner and Lighter less than 9 mm thick and under 1.5 lbs
    • The built in kickstand has two positions, this may not sound like a big deal, but for those of us who use the Surface RT regularly this is very good news. The built in kickstand on the original Surface RT was very useful, but there were times I wanted a steeper angle. Hopefully this means my friend Rogan doesn’t have to use a box to raise the angle on his Surface anymore.
    • Longer battery life (10 hours), personally I found the battery life of the original Surface RT was good enough for me and I spend a lot of time on long flights. But, I will never complain about having longer battery life and 10 hours will get me through an entire season of Game of Thrones next time I am on the road.
    • Stiffer Backlit keyboard. The keyboard is stiffer making it more effective when you have the Surface on your lap. Some of the new keyboards are also backlit. This may not seem like a big deal, but I do find that there are times when I am working on my Surface in a low lighting situation (planes with lights dimmed, hotel rooms with lousy lighting) so I was happy to hear about this feature.
    • USB 3.0 – faster file transfers!
    • Widescreen HD display – I do watch a lot of movies and TV on my RT. There’s even an HD video out port so I can connect it to a big screen.
    • Outlook 2013 RT and Office 2013 RT – Not only do we get Office 2013 RT with the Surface, so you can work in Word, Excel, and PowerPoint, we also get Outlook 2013 RT which provides an improved email experience over the original Surface RT.
    • 1 year of unlimited free voice calling landlines and free Skype Wi-Fi at hotspots with purchase ( there are some limitations on numbers you can call, but this will save me money when I am calling home, or my kids steal my RT to skype their friends)
    • 200 GB extra SkyDrive storage with purchase (that's a lot of photos to share with your family)

    Surface Pro 2

    Now let’s take a look at the Surface Pro 2 that evolved from the Surface Pro and runs the full Windows 8.1 operating system

    Don’t forget as a student you can use DreamSpark to load your Surface Pro with tools like Visual Studio professional for free too!


    • Faster – the Surface Pro 2 runs on an intel 5i processor.
    • Longer battery life
    • Up to 512 GB Flash storage – means you can store more files on the Pro
    • Power cover keyboard – this new keyboard cover gives your Surface Pro 2 extra battery life. You can also use the new backlit touch and type covers for your Surface Pro 2 as well. FYI – the power cover keyboard is not backlit (only so much stuff you can fit into a keyboard that thin). These new covers are more rigid so they work better on your lap as well.
    • USB 3.0 – faster file transfers!
    • The built in kickstand has two positions, just like the Surface 2, the Surface Pro 2 has two kickstand positions. Good news for all of us who found the single position less than ideal for certain situations.
    • Write & Draw – You still have an awesome pen drawing experience that pressure sensitive.
    • Widescreen HD display – For when you take a break from work to watch a movie
    • 1 year of unlimited free voice calling landlines and free Skype Wi-Fi at hotspots with purchase ( there are some limitations on numbers you can call, but this will save me money when I am calling home, or my kids steal my RT to skype their friends)
    • 200 GB extra SkyDrive storage with purchase (that's a lot of photos to share with your family)
    • Docking Station - The Surface team has also announced a docking station for the Surface Pro 2 so it’s easy to work at home and connect your external monitor, Ethernet, full size keyboard, speakers and other accessories. The docking station will be available in early 2014.

    And if Music is your life…

    Check out the Surface Remix project! A cover for DJS! You can also find out about it from Linkin Park’s’ Joe Hahn

  • Go DevMENTAL

    A bulletproof phone? Windows Phone 8 protects your data!


    Windows Phone 8 is now FIPS 140-2 certified. FIPS 140-2 is a government security standard used to accredit cryptographic algorithms that protect sensitive data inside products like smartphones.

    What does this mean?

    Basically it means that government agencies in the US and Canada trust the Windows 8 Phone certificates to protect sensitive data. So if you have any app ideas that will store sensitive data, you know that the Windows 8 Phone is up to the task. FIPS 140-2 is a mandatory standard for all Federal agencies that use cryptographic-based security systems to protect sensitive information in computer and telecommunication systems. It’s the standard required by the military, and I can assure you the military is very careful with their data!

    There are nine certificates accredited:

    The accreditation was awarded by the Cryptographic Module Validation Program, a joint effort of the U.S. National Institute of Standards and Technology and the Communications Security Establishment Canada, the country’s national cryptologic agency. This information was announced on the Windows Blog in mid September.

    If security is important to you, you should also check out the Windows Phone 8 Security Guide, you’ll find more information on security topics related to Windows Phone. You can download a copy of the updated guide here.

    Don’t forget if you are a student you don’t have to settle for Express versions of Visual Studio when you build Windows Phone apps. Get Visual Studio Professional, the Windows Phone SDK, and a free Windows Phone Store account from DreamSpark

  • Go DevMENTAL

    Visual Studio Tips: Starting to code your class project in TFS


    VisualStudioLogoOnce you have your requirements and tasks assigned, your developers can start coding the tasks for the first iteration

    This blog follows up two previous posts on how to use TFS for class projects, and how to use TFS for requirements.

    If you want more detail on how to start coding your tasks, there’s a nice article in MSDN: how to write code for a user story

    Find more Visual Studio Tips and Tricks here.

    In this post I will cover

    • Starting to work on a task
    • Creating a Unit Test for your code (it’s actually good to do this before you start coding!)
    • Testing and writing your code
    • Checking your code into Source Control

    Don’t forget students can get Visual Studio Professional for free through DreamSpark

    Starting to work on a task

    As a developer, I live in Visual Studio, and that’s where we start working on the tasks assigned to us. If you open up Visual Studio and go to Team Explorer | My Work, you will see the Available Work Items assigned to you.

    Team Explorer assigned work

    To start working on a task, just drag it from Available Work Items to In Progress Work.

    Team Explorer in progress work

    By the way, when you drag an item to In progress, the board for your team project is updated on your team project page. That way anyone on the team who views the board can see that you are working on that task.

    Active task on board

    Creating a Unit Test for your code

    Next I write a unit test for my code. Yes, a unit test! The advantage to creating a unit test for your code before you start coding is it forces you to think about how your method will be called. It’s also going to help me finish my work faster because I’ll have an easy way to test my code right from the get-go.

    To add a Unit Test I add a New Unit Test Project.

    Create Unit Test Project

    When I create the Unit Test project I get a C# file where I can add a test method for the method I am about to start creating. In my project the method is going to convert a pace from minutes/mile to minutes/km. Of course the code does not compile because the method to do the actual conversion doesn’t exist yet.

    using System;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    namespace UnitTestRunner
        public class UnitTest1
            public void TestConvertMinPerMiletoMinperKm()
                double minPerMile = 8.0;
                double minPerKm = 0.0;
                minPerKm = ConvertMinPerMiletoMinperKm(minPerMile);
                Assert.AreEqual(5.0, minPerKm);

    Now I need to add a project to my solution to hold the actual method I am assigned to code. Since this is one of several methods that will be used to do calculations for the app, I’ll put it in a class library.

    NOTE: Make sure you choose File | Add New Project  and not File | New project. Because you want to add a second project to your existing Visual Studio solution where the unit test project was created. You don’t want to create a separate solution to hold the class library.

    Create Class Library


    Testing and Writing your code

    Okay now I am going to get the Unit test project to generate the method stub for my actual method. If you haven’t discovered the Generate Stub feature yet, I think you will like this! Notice the squiggly red line under the method in the unit test class and the little blue line under the first letter of the method call. This is a hint to me that Visual Studio knows something is wrong with the code and is offering to help me correct it.

    generate code squiggle

    If I hover over the blue line, an icon appears with a drop down (or use <CTRL>+< . > as a keyboard shortcut). The drop down tells me I can generate a method stub. When I click it, Visual Studio creates a stub for my method. The end result looks like this:


              // ...
               minPerKm = ConvertMinPerMiletoMinperKm(minPerMile);
                Assert.AreEqual(5.0, minPerKm);
            private double ConvertMinPerMiletoMinperKm(double minPerMile)
                throw new NotImplementedException();

    Now I can quickly test my code any time I want, by just doing a right click in the code and choosing ‘Run all tests’ or CTRL <R><T>. Of course the test will fail if I do it right now, because the only thing my method does is throw an exception.

    Test Explorer results

    If I just remove the throw exception and add a return statement to my method, the test will pass.

        minPerKm = ConvertMinPerMiletoMinperKm(minPerMile); 
        Assert.AreEqual(5.0, minPerKm); 
    private double ConvertMinPerMiletoMinperKm(double minPerMile)
         return 5.0;

    Test Explorer Passed

    Now I can really start coding and testing. I can add additional test methods to test different scenarios as well, and quickly retest all of them whenever I make a code change.

    Checking your code into Source Control

    Once I am happy with my code I can check it in.

    Since I haven’t done any Source Control Check in or Check out on this project yet, I first need to set up the source control for this project.

    Open the Source Control Windows (View | Other Windows | Source Control Explorer)

    Source Control Explorer

    Select Not Mapped in the Source Control Explorer Window. Select a local folder to map to the folder in the source control.

    If you are the very first person to check in code, it’s a good idea to set up a folder structure, so you may want to add a Main folder to your Source Control. From the menu choose File | Source Control | New Folder

    NOTE: If New Folder is not enabled, you probably don’t have permissions to create a folder in source control, you will need the Contributor permission for the project. There is an article in MSDN on how to set a permission. Basically go to Team Explorer | Settings | Team Project | Security.

    Then in the window displayed, select the Security Tab, then select Users.

    Select the user who needs the contributor permission, select Member Of and then choose Join Group, when asked what group to join, type Contributors and Save your changes.

    Setting security TFS

    Now you can go back to the Source Control Explorer window and create a new folder called main.

    New folder source control explorer



    In Team Explorer, choose Pending Changes and choose check in from the Team Explorer Menu, add a comment

    Check in

    Using Windows Explorer, move your Visual Studio project folder into the Main folder you just created. Remember the local directory which you mapped to Source control? It now contains a Main folder that maps to the Source Control Main folder, so you are moving your Visual Studio project to that folder. That folder on your hard drive is how the source control will detect changes and will place any code that you check out in the future. There is a good MSDN article about how to check in code.

    Now open up your project in Visual Studio from the new location. In the Solution Explorer window, right click the solution and choose Add Solution to Source Control. Then right click the solution and choose Check In.

    When you choose Check in from the menu, the Pending Changes window appears in Project Explorer so you can review the files that will be included as part of the check in. When you are happy with the list of pending changes, just select Check in in Team Explorer.

    Check in Solution

    Phew! Okay we accomplished a lot today! We starting working on one of our tasks, created a test project to help us code efficiently and set up the initial source control for our project and checked in the first chunk of code! Give yourself a pat on the back for this step! Personally I have to say I really appreciate the documentation in MSDN as well, it’s been a big help for me in figuring a lot of this out.

  • Go DevMENTAL

    Visual Studio Tips: for JavaScript Coders try CoffeeScript


    VisualStudioLogoFor those new to JavaScript (or those of us who are just lazy) CoffeeScript allows you to forget all those pesky semi colons and still create JavaScript for your websites or Windows apps and you can use it in Visual Studio!

    CoffeeScript is a neat little language that compiles into JavaScript, but you don’t have to remember all the little curly braces and semi colons. Using VS Web Essentials you can use CoffeeScript to create the JavaScript for your projects in Visual Studio.

    Find more Visual Studio tips go here.

    Don’t forget students can get Visual Studio Professional for free through DreamSpark!

    For those of you who already know CoffeeScript

    If you just want to know how to use it in Visual Studio right now:

    • Go download and install VS Web Essentials
    • Add a new Item to your project, pick CoffeeScript as the item type
    • Write your CoffeeScript code, when you build the project or Solution, it will create the JavaScript code.

    For those of you who haven’t seen CoffeeScript before

    Let’s get into a bit more detail.

    Let’s get a CoffeeScript file added to a Visual Studio project and try it out so you can see how it works.

    You need to install VS Web Essentials so you can try out CoffeeScript in Visual Studio. Download it here.

    Now Got to a Windows HTML/JavaScript project or to a website project and in Solution Explorer select Add | New Item

    Add New Item


    Now select CoffeeScript file from the item types

    Coffee Script file in Visual Studio

    Open your .coffee file in the Visual Studio Code editor and you should see something like this

    coffee script file in Visual Studio

    Now we are ready to play!

    We write the CoffeeScript in the pane on the left, and when we build the solution, the JavaScript will appear on the right.

    Let’s start with something really simple. Let’s declare a few variables.

    Write the code below in the left hand pane. CoffeeScript uses whitespace to delimit code, so you don’t need semicolons.

    firstName = "Gordie"
    lastName = "Howe"
    score = true

    Now from the menu, choose Build | Solution, after the Build you will see the following JavaScript on the right

      var firstName, lastName, score;
      firstName = "Gordie";
      lastName = "Howe";
      score = true;

    If you go to Solution Explorer and select Show All Files, and expand your CoffeeScript file, you can actually see that the build generated a .js and a minimized .js file for your CoffeeScript.

    Generated js from .coffee

    Now let’s see what else CoffeeScript can do. I find the syntax for If statements confusing because no two languages are quite the same, in CoffeeScript, you can just specify what you want to happen if a condition is true and the corresponding JavaScript if statement will be generated for you. For example the following CoffeeScript

    lastName = "Amazing" if score

    becomes the JavaScript

      if (score) {
        lastName = "Amazing";

    You can also use indentation instead of curly braces {} for blocks of code in functions, if statements, switch statements and try/catch statements.

    For example the CoffeeScript


    if score 

    becomes the JavaScript

      if (score) {

    You can even define a function by listing parameters in parentheses

    The following CoffeeScript

    fullName = (first,last) -> first + last

    becomes the JavaScript

      fullName = function(first, last) {
        return first + last;

    Neat eh?

    If you are an experienced JavaScript coder, you may be thinking, it will take me so long to learn CoffeeScript syntax that it’s not worth it. But for a beginner coder who isn’t used to all those braces and semi-colons it’s a nice option. It’s also handy for those of us who are determined to save every keystroke we can when coding.

    I could give you more and more examples, but at this point, I would just be teaching you CoffeeScript, my goal with this post was to show you how to use it in Visual Studio. If you want to learn more about CoffeeScript syntax, visit coffeescript.org and have fun!

    NOTE: When I was using CoffeeScript in Visual Studio, I found that occasionally it would crash Visual Studio when I tried to copy the code from the JavaScript pane (which of course I was doing a lot when writing this blog post). As a simple work around, I just opened the generated JavaScript file and copied code from there and did not have any more problems

Page 1 of 2 (9 items) 12