Posts Tagged ‘Visual Studio 2010’

How do I use HTML5 in Visual Studio 2010?

cadhtml5coaIn this post, I’ll share what I learned about how to get started writing HTML5 code in Visual Studio 2010.

HTML5 seems to be everywhere these days! I started trying it myself a few months back and I quickly decided that if possible, I wanted to play with it in Visual Studio. I’ve been working with Visual Studio for years, it’s got to be simpler to keep working with the developer tool I already know and love rather than moving to a new tool. Besides I want to be able to incorporate HTML5 into ASP.NET applications!  It took me a bit of messing about to get up and running with HTML5 the way I know there will be greater support for HTML5 in Visual Studio 11. But for now I am working with Visual Studio 2010.  I thought I would share what I learned so hopefully it will be easier for you.

Here’s what you want to do:

  • Add HTML5 validation and intellisense
  • Create an HTML5 project
  • Set up for <video> and <audio>
  • Play!

Add HTML5 Validation and Intellisense

You will definitely want to make sure you have Service Pack 1 installed! By installing Service Pack 1 you get both intellisense (can’t live without that anymore) and validation for HTML5. Don’t forget after you install Service pack 1 to go to Tools | Options | Text Editor | HTML | Validation and set the validation to HTML5 or XHTML5 or the HTML5 validation won’t work.

First of all there is a really great blog by Burke Holland on how to use the MVC HTML5 template for Visual Studio 2010 here.

Create an HTML5 project in Visual Studio

You have a couple of choices here.

  • Modify an existing template to be HTML5 or create your own template. There is a great blog describing how to do that here.
  • Download the MotherEffin ASP.NET MVC HTML5 template that Jacob Gable was kind enough to post on the VisualStudio Gallery.
  • Download the mobile ready ASP.NET MVC HTML5 template that Sammy Ageil was kind enough to post on the Visual Studio Gallery

Set up for <video> and <audio>

The first tags I started playing with in Visual Studio were the video and audio tags. I immediately had problems getting an actual video to display on my web page it was really frustrating. Here is what I had to do to get everything working. The basic problem was with the MIME types. When a .avi, or .MP3 file was used on my website, the web server didn’t recognize that those were video and audio files. To get it working I had to edit my web.config file and make sure I had IIS express running in the development environment instead of the development server built into Visual Studio to ensure that my web.config file was being used to figure out the MIME types. You need to do this for the WOFF fonts as well.

  • Install IIS Express
  • Specify the mime types you will be using in your web.config file. Here’s an example:
        <system.webServer>
          <staticContent>
            <mimeMap fileExtension=".mp4" mimeType="video/mp4" />
            <mimeMap fileExtension=".m4v" mimeType="video/mp4" />
            <mimeMap fileExtension=".woff" mimeType="application/x-woff" />
            <mimeMap fileExtension=".webm" mimeType="video/webm" />
            <mimeMap fileExtension=".ogg" mimeType="video/ogg" />
            <mimeMap fileExtension=".ogv" mimeType="video/ogg" />
          </staticContent>
        </system.webServer>

    .csharpcode, .csharpcode pre
    {
    font-size: small;
    color: black;
    font-family: consolas, “Courier New”, courier, monospace;
    background-color: #ffffff;
    /*white-space: pre;*/
    }
    .csharpcode pre { margin: 0em; }
    .csharpcode .rem { color: #008000; }
    .csharpcode .kwrd { color: #0000ff; }
    .csharpcode .str { color: #006080; }
    .csharpcode .op { color: #0000c0; }
    .csharpcode .preproc { color: #cc6633; }
    .csharpcode .asp { background-color: #ffff00; }
    .csharpcode .html { color: #800000; }
    .csharpcode .attr { color: #ff0000; }
    .csharpcode .alt
    {
    background-color: #f4f4f4;
    width: 100%;
    margin: 0em;
    }
    .csharpcode .lnum { color: #606060; }

Change the project settings, by right clicking on the project and changing the settings to Use IIS Express when debugging in Visual Studio.VisualStudioDevelopmentServer

Play!

Once you have it up and running you can start exploring the world of HTML5. There are some great resources on learning HTML5 here. Make sure you read up on feature detection since different browsers will support different HTML5 features and because you will need this for backwards compatibility as well!

If you want to experiment with <video>, I found it handy to just download Big Buck Bunny since you can get it in multiple formats so it’s great for experimenting with the fallback features of HTML5 <video> for different browsers.

Since a big part of HTML5 is the cross browser support, make sure you try it out in different browsers, or use the F12 developer tools in Internet Explorer to test how your code will work in different browsers or older browsers.

Most of all have fun!

My love affair with Visual Studio: Error Correction

I have been working with Visual Studio for years, and I’ve found a few tricks along the way that make my coding easier. In this blog post I’ll show one of my favourite time savers the Error Correction feature.

When you are writing code for a form or a class as part of a team, or even if you are just starting work on a project which will be made up of multiple classes, you always end up having to reference classes, properties, or methods in your code that haven’t been written yet. So you either have to comment out those calls, add them later, or add stubs so your code will compile. In Visual Studio 2010 they added a neat little feature that will add the stubs for you!

Say I am writing code for a click event handler that will create and populate an instance of a Student object who will be registering for a course. I haven’t created the Student class yet so I see a squiggly under the word student and this little rectangle at the end of the squiggly.

image

Now comes the cool part, I can carefully hover the mouse over the tiny rectangle and a little warning symbol will appear, if I hover just right it will appear with an arrow beside it that I can click on.

ErrorCorrectionOptionSmall

Clicking on that little arrow will bring up a menu of options that will fix the error for me! By the way, if like me, you find using the mouse to bring up the list fiddly, you can use the keyboard to bring up the correction menu by putting the cursor on the word student and hitting CTRL + . that’s CONTROL KEY and a PERIOD.

ErrorCorrectionListSmall

Visual Studio is offering to create a Student class for me, or to define a new type (variable essentially). If I click on Generate ‘Class Student’ I can see a new class appear in Solution Explorer called Student.vb

image

If I open up the Student class I see it has not only created a class, but because my code called a constructor and passed in two variables, it created a constructor method in the class as well that accepts two variables!

image

The code isn’t complete by any means, but it’s enough to get rid of the squiggly on Student in my event handler!

image

Of course now I have squiggly lines under vFirstName and vLastName because I haven’t declared those yet, but if I bring up the Error Correction list for those variables I select Generate field for vFirstName and then Generate field for vLastName and it adds the declarations for me!

image

Sure, it didn’t’ know what data type to make the variables, it’s not perfect, but when I am trying to test something quickly these little Error Correction tools that will generate code stubs for me can be a real time-saver.

This blog also appears on the Canadian Solution Developer Blog

Thank You Thank You Sam I Am! I do so like this ALM!

It’s fall and that means back to school for kids, it also means time to start up and really get rolling on new projects, which means it’s a good time to think about the big picture: Application Lifecycle Management (ALM). Developing an application is about much more than just writing code.  You have to collect requirements, you have to determine which requirements you will develop in each phase or sprint, you have to develop the code, you have to test the code, you have to deploy the code, you have to support the code, you have to update the code and add additional features in each phase or sprint. This involves a lot of work and a lot of different people! You need a way to help the teams collaborate, you need a way to send feedback, you want to follow best practices, and ideally you don’t want all the teams using different tools! That’s where Application Lifecycle Management tools come into play.

Any application lifecycle management tool has to support the flow through the different phases of the projects and the flow from one team to another. The truth is most of us think of Visual Studio as a tool for editing and deploying code and nothing more, but that copy of Visual Studio installed on your PC right now may be capable of more than you realize. You may have an ALM tool sitting in front of you already. The best part is, it’s an ALM tool you already know. Yes, learning how to use the ALM features will take a bit of effort but many of the interfaces will be familiar and will integrate well with the code editor we know and love (btw – yes I do love the Visual studio code editor) . Visual Studio 2010 lets you track requirements, manage source control, and connects Quality Assurance (QA) with development and even supports the Eclipse development environment so its not just for .NET developers. Visual Studio vNext will take it even further with easier tracking and assignment of requirements in each sprint, a new code review feature, and more!

One of our goals this year is to help you understand the full potential of Visual Studio as an ALM tool and learn how to leverage that potential to help your next project. If you prefer self study you can check out the Visual Studio Roadmap, a great read with links to whitepapers and videos to help you understand all that Visual Studio has to offer as an ALM tool. If you prefer to have someone walk you through it, join us in a series of online webcasts over the course of the year. Starting with a series to help you make your testing more efficient.

Today’s Top 5 is all about helping you get up to speed on testing features

QAWebcasts5 Free Webinars to help you improve your testing

  1. Getting Agile with Testing, Sept 21st 1PM Eastern
  2. Manual Testing Evolved, Sept 28th 1PM Eastern
  3. Automating Virtual QA Environments, October 5th 1PM Eastern
  4. Raising Your Technical Debt Ceiling…Or Not? October 12th 1PM Eastern
  5. Quality Assurance in Mixed Technology Environments, Oct 19th 1PM Eastern

SAMGYou definitely want to catch the first session featuring none other than Sam “ALM” Guckenheimer, Sam is the Product Planner at Microsoft for Visual Studio Team System and an authority on software testing and ALM. He literally wrote the book (Software Engineering with Microsoft Visual Studio Team System). This is an amazing opportunity to hear directly from the source. We are also bringing Sam to visit Canada as a keynote speaker at TesTrek in Toronto.

So register today for the Getting Agile with Testing seminar, September 21st with Sam “ALM” Guckenheimer and more great sessions to help you with your testing!

It struck me that if Dr Seuss was learning ALM from Sam “ALM” Guckenheimer it might have gone something like this:

That Sam A LM! That Sam A LM
I do not like that Sam A LM
Do you like your A L M?
I do not like it, Sam A LM
I do not like that A L M
Would you like it here or there?
I would not like it here or there
I would not like it anywhere?
Would you like them when you test?
That is when they’re at their best!

You should try it when you code
It will keep you on the road
When I test? is that best?
When I code? Keep to road?
I did not know this A L M
I am not sure now SAM A LM

Would you like it when you’re live?
Your ops team will surely thrive.
Would you like it to track need?
Help your project to succeed!
When I test that is best.
When I code Stay to road.
Sure to thrive when we’re live
Help succeed meet user need!

I did not know this A L M
I am not sure now Sam A LM

Would you like it when you plan
know if deadlines meet you can?
Would you like code source control
It will help most every role
When I test that is best.
When I code Stay to road.
Sure to thrive when we’re live
Help succeed meet user need!
When I Plan? Know I can?
Code Control? Help each role?
I did not know this A L M
I am not sure now Sam A LM

You do not like it, so you say
Try it, try it, and you may
Try it and you may, I say
Sam! If you will let me be,
I will try it, you will see…
Say! I like this A L M
I do! I Like it Sam A LM
I will use it when I test
I will use it that is best
I will use it when I code
That will keep us on the road
I will use it when we’re live
It will help my ops team thrive
I will track each users need
Then my project will succeed!
I will use it when I plan!
Deadlines meet, I know I can!
I will do my source control
It will help in every role!
I will use it here and there
I will use it EVERYWHERE!
I do so like this A L M
THANK YOU THANK YOU SAM A LM!

with apologies to to Dr. Theodor Seuss Geisel whose original Green Eggs and Ham is far superior to my attempts at prose!

(By the way I was going to  have a verse that said Do you like them in a cubicle but i couldn’t find a rhyme)

Visual Studio Hands On Labs for FREE!

VS2010WhiteBackgroundThere are a lot of different ways to learn a product or feature. You can watch videos, you can read blogs and articles. You can download training kits and developer guides. These work very well when you have a sandbox to play in, somewhere you can try out the features and code shown in the articles and blogs. But what if you don’t have anywhere to try it out? What if trying something out requires having a sample project as a starting point? Kind of hard to see how to complete testing faster using Test Manager without a project to test or Test Manager! Hard to try out software architecture features without Visual Studio Ultimate and an architecture to explore!

Technology to the rescue! With the rise in popularity and capabilities of virtual machines, more and more product groups are providing Hands On Labs inside virtual machines complete with all the software and sample projects to make it easy for you to try out lots of cool features. Case in point, Brian Keller, an evangelist for Visual studio wrote a blog announcing the Visual Studio team has a Virtual Machine with Visual Studio 2010 RTM loaded with sample data and they have even provided a set of manuals you can use to complete a series of different hands on lab experiences.

You may only use Visual Studio to edit and deploy your code, but there is so much more hiding in there!

Ever wondered how Visual Studio can help you with testing? Check out these labs

  • Authoring and Running Manual Tests using Microsoft Test Manager 2010
  • Introduction to Test Case Management with Microsoft Test Manager 2010
  • Introduction to Coded UI Tests with Visual Studio 2010 Ultimate
  • Debugging with IntelliTrace using Visual Studio 2010 Ultimate
  • Using Code Analysis with Visual Studio 2010 to Improve Code Quality
  • Introduction to Exploratory Testing with Microsoft Test Manager 2010
  • Introduction to Platform Testing with Microsoft Test Manager 2010
  • Introduction to Quality Tracking with Visual Studio 2010
  • Introduction to Test Planning with Microsoft Test Manager 2010

Interested in how Visual Studio can help you discover the architecture of a project (since we have been talking about how to handle code without documentation)? Check out these labs

  • Code Discovery using the architecture tools in Visual Studio 2010 Ultimate
  • Understanding Class Coupling with Visual Studio 2010 Ultimate
  • Using the Architecture Explore in Visual Studio 2010 Ultimate to Analyze Your Code

Has ITIL arrived at your company and is everyone asking you about your processes and configuration management? Check out these labs.

  • Planning your Projects with Team Foundation Server 2010
  • Branching and Merging Visualization with Team Foundation Server 2010

You can download the labs here. You can even choose between Hyper-V, Virtual PC 2007, or Windows 7 Virtual PC! There is more detail about the virtual machines, the labs and how to use them at Brian Keller’s blog post “Now Available: Visual Studio 2010 RTM Virtual Machine with Sample Data and Hands-on-Labs”.

Todays Top 5

5 Reasons to check out Tech Days Canada 2011 (in person or online)

  1. For the first time, we will have Hands On Labs at the event! (See the top 5 is related to the blog post Winking smile). Bring your laptop to the show, try out the features you have been hearing about on the blogs on all kinds of products!
  2. For the first time, we will have Instructor Led Labs at the event! If you find self paced labs don’t give you enough information, there will be several instructor led labs where you can bring your laptop and walk through a lab with the presenter!
  3. There will be Hands On Labs online! If you can’t make it to TechDays in person, we will be hosting lots of great labs throughout the year from the TechDays website.
  4. Free WiFi – yes we heard you, and yes we listened, and yes we will have free WiFi this year.
  5. Bigger better TechDays Online – We will be launching an expanded and richer TechDays Online later this year to provide you with great content throughout the year!

This blog is also posted on the  Canadian Solution Developer Blog

By The Way There is no documentation (yet!)

In the past few weeks I have talked about some tips on how to survive when you inherit code from someone that has no associated documentation. We looked at how to generate dependency graphs, and how to generate sequence diagrams. But sometimes we do make an effort to document our code. If you are going to spend time documenting code you want to ensure that is time well spent.

One of the problems I ran into on occasion was documentation that was created during coding could not be located by the developers down the road when they were supporting the application. As a result, I am a big believer in including code documentation within the code itself. If the documentation is part of the project and the code, then anyone who has access to the code has access to the documentation. This is why even though they have been around for a while, I love XML comments and wanted to remind you of a few tips to make them as easy as possible to work with.

To add XML comments to your project just go to the beginning of the class or method and put three “/” marks on a line then hit enter (C#) or three ‘ single quotes (VB). When you hit Enter you will get a skeleton for XML comments you can fill in

        /// <summary>
        /// 
        /// </summary>
        /// <param name="StudentToAdd"></param>
        /// <returns></returns>
        public string Add(Student StudentToAdd)
        {

The XML skeleton that is generated will be different depending on where you add the XML comments. The skeleton is just a starting point, you can add a number of other elements to your XML documentation as well by just going inside the XML comments and entering a “<” symbol the intellisense will give you a list of elements to choose from as shown in Figure 1

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }addingNewXMLElementZoomedin

Figure 1 Adding Additional XML Elements to the Comments

 

You probably want to sit down at the beginning of a project and decide what elements you want to include for different objects such as classes, methods and properties. After doing this you will want to standardize it for your team by modifying the default skeletons. Well good news, if you are a VB developer you can create a document called VBXMLDoc.xml, for instructions on where to find this file and how to edit it, see the MSDN article Recommended XML Tags for Documentation Comments. If you are a CSharp programmer unfortunately for now we don’t have an equivalent file, but you can create code snippets for the different skeletons.

By the time you are finished entering the comments it can start to take up a fair bit of screen space which can be annoying when you already know your way around the code.  You can collapse/expand the comments using the +/- symbols or CTRL+M CTRL+M (if like me, you prefer keyboard shortcuts) as shown in Figure 2.

CollapsedCommentsZoomedIn

Figure 2 Collapsing comments

 

So now you have comments in your code, which can be accessed by all programmers who are working on the code in the future, but honestly I can just do that with normal comments and I can use Code Snippets to insert skeletons. So why use the XML comments? there are two great reasons to use the XML comments

You can generate an XML documentation file from your XML Comments

When you build your project you can generate a file that contains the XML comments. This gives you one document which summarizes all your classes and their members that you can make available to other team members. To generate the documentation you can either specify /doc using the command line compiler or if you are building from within Visual Studio go to Project Properties | Build | Output and select XML Documentation file as shown in Figure 3

GenerateXMLDocumentationProperty

Figure 3 Setting Build Options to Generate XML Documentation File

 

Generate Help files from XML Comments

You can generate Help files from XML Comments using Sandcastle which is available on CodePlex. Sandcastle will generate Microsoft style help topics by reflecting your assemblies and reading your XML comments. Help files are an often requested by users and can be a tedious task for development teams so why not leverage XML comments to help with documenting your code and generating the help files!

So instead of creating a separate document that contains the documentation for your code, keep it with your code where the next programmer will always be able to find it, and if you are going to take the time to document your code consider getting your comments to do double duty as source information for user help!

Today’s Top 5 is of course related to documenting your code

5 Best Practices for adding comments to code

  1. Add comments at all levels – explain the purpose of the class and the methods not just the methods themselves.
  2. Tell me something I don’t know – telling me that a method called Insert will do an insert is not very helpful, what will it insert, are their parameters that affect how it will perform the insert
  3. Document the exceptions – When I call someone else’s code I really like to know what exceptions may be raised by that method, so please tell me what exceptions my code needs to handle
  4. Be professional – as tempting as it may be sometimes to write tongue in cheek comments, it’s always best to take the high road and keep your comments professional
  5. Set a standard – define what you will document for each type of object and consider also standardizing the writing style, will it be bullet point, complete sentences, third person, first person, present tense, past tense? This is particularly important if you plan to generate help files from the comments.

Visual Studio, so much more than just a code editor Smile

This blog is also available on the Canadian Solution Developer Blog

By The Way There is Still No Documentation…

A couple of weeks ago I talked about the challenges of finding up to date documentation and showed you how to generate dependency graphs to help you figure out the structure of your code using Visual Studio 2010 Ultimate Edition.

This week I want to show you another useful feature in Visual Studio 2010 to help you generate documentation from existing code. The dependency graphs are great for big picture analysis, which assemblies are referenced and the classes in each assembly, but what if I need a lower level of detail?

Once again Visual Studio 2010 Ultimate Edition comes to the rescue with the sequence diagram generator. Maybe you’ve been asked to investigate an error message received by a user when they click on a particular button. You can just go into the event handler and generate a sequence diagram to determine the method calls from that event handler. This is much simpler than manually walking through the code class by class, method by method. Simply place the cursor in the code editor window, within the method for which you want to generated a sequence diagram and right click. Choose Generate Sequence Diagram from the context menu as shown in Figure 1.

GenerateSequenceDiagramCallZoomIn

Figure 1 Generating Sequence Diagram

When you select Generate Sequence Diagram you get a window which allows you to control the level of detail you want to include in the sequence diagram.

generatesequenceDiagramMenu

Figure 2 Generate Sequence Diagram Pop Up Window

 

Let’s take a quick look at the different options

  • Maximum call depth controls how many calls deep you want the sequence diagram to draw. If you have a lot of nested calls and different classes you probably want to increase this from the default value of 3.
  • Include calls in Current project will display only calls to methods in the same project as the method you selected
  • Include calls in Current Solution will display only calls to methods in the same solution as the method you selected
  • Include calls in Solution and external references will display all calls to all methods regardless of the assembly or location where they reside
  • Exclude calls to Properties and events will leave out calls to get and set methods for properties or event handlers, unless you suspect the error is in a get or set method, the diagram is usually easier to read without these calls.
  • Exclude calls to System namespace will leave out calls to any methods that are part of the System namespace, since most of the time the bugs are in our code, we often exclude these calls, though there are times when seeing System namespace calls can be helpful, for example when debugging localization issues or database connections.
  • Exclude calls to Other namespaces allows you to explicitly list namespaces whose calls you want excluded from the diagram, this allows you to focus in on specific sections of code
  • Add diagram to current project allows you to save the diagram in your project with a .sequencediagram extension

If I choose OK and generate the sequence diagram with the default values shown in Figure 2, Visual Studio generates the sequence diagram shown in Figure 3.

GeneratedSequenceDiagramDefaultZoom

 

Figure 3 Default Sequence Diagram

You can see my event handler instantiates a new Student object, and then calls the Save method of the Student class which instantiates an instance of the StudentData class and calls the Add method. This is a very simple example, but shows how quickly you can outline method calls from the event handler. Generating a sequence diagram does not take very long so you can experiment with different settings to get the right level of information for your needs.

So once again, without using any external tools, we have the ability to generate documentation for our undocumented project! You already have Visual Studio, it is so much more than just a code editor! For just a quick sense of how much more it can do, just take a minute to look at the Visual Studio 2010 feature comparison chart. What features are you using? Testing? Database development? Version Control? Build Automation?

Today’s My 5 is related to documentation

5 ways to make your code more readable

  1. Do not abbreviate variable names with autocomplete and intellisense features (especially the pascal case intellisense in Visual Studio 2010), you don’t need to keep your variable names 3 characters long anymore!
  2. Do not call your variable “id” unless it is REALLY obvious what id is stored in that variable. The number of times I have had to read through code to figure out if id represented a StudentId, CourseId, CategoryId or ClassId, this is one of my pet peeves.
  3. Start using LINQ to SQL building T-SQL statements by concatenating strings is really confusing to read and prone to syntax errors like missing spaces or commas, LINQ to SQL is easier to read and debug.
  4. Use meaningful parameter names once again the intellisense is a great feature and it works for your methods as well as the built-in methods, so use meaningful parameter names so that anyone calling your method can easily figure out the expected parameter values.
  5. Be consistent with casing are you going to use uppercase for constants? pascal casing vs camel casing for public variables. Be consistent and everyone will get immediately recognized the different types of variables from their names alone.

This blog is also posted on the Canadian Solution Developer blog

By The Way There Is No Documentation…

Have you ever been asked to make changes or fixes to someone else’s code? Do any of these scenarios sound familiar? A developer leaves the team and now you have to continue with their code. A consulting company develops an application and then your company decides to do the maintenance themselves to save money and now you have to maintain an application built by another team. An application developed years ago now needs updating with new functionality but all the people who originally worked on that application are now elsewhere in the company.

Yup, that’s life as a developer. To be honest I prefer to just build a new application from scratch then try to decipher someone else’s code and ad or fix their functionality. It is not because the other programmers haven’t produced good code, it’s just the extra hurdle of learning how someone else has built an application. To help with this we traditionally add comments to our code and we create documentation that explains the application. Then we starting running short on time, and the users ask for last minute changes that are have to be included. So we put off updating the documentation and focus on heads down coding to meet our deadlines. After the application goes live, there are changes and fixes to the application as well. We open tickets and create change requests and if you add comments or records to keep track of which modules were updated and why. But is the original application documentation kept up to date? All too frequently the answer is no.

So where does that leave a developer who inherits someone else’s code and needs to add an enhancement or bug fix. Well if you have Visual Studio Ultimate 2010, there is hope. When you open Visual Studio Ultimate you see a brand new menu option called Architecture. So when you open up that code in Visual Studio and you find yourself wondering how this application is designed, and you don’t want to spend hours opening up the different classes to see what is called where. Check it out!

Here’s how it works, you open up the Solution containing the code you need to update. You choose Architecture | Generate Dependency Graph | By Assembly.

ArchitectureMenuZoomIn

Figure 1 Generating a Dependency Graph

This will generate a graph that shows you each of your assemblies and assemblies are dependant on each other. This by itself is very useful when you are trying to determine the risk and potential impact of making a change to a particular assembly. It will also help you estimate the effort that will be required to test a change to a particular assembly because you start to get a sense of where the dependencies lie.

DependencyGraphAssemblyZoomedIn

 

Figure 2 Sample Dependency Graph By Assembly

As you can see in the dependency graph shown in Figure 2 the Registration project references the Courses assembly. So I know I need to retest parts of the Registration project if I make any changes to the code in the courses assembly.

If you want more information about the classes within the assemblies you can expand each assembly as shown in Figure 3

ZoomInExpandedAssemblyDependency

 

Figure 3 Expanded Assembly Dependency Graph

Unfortunately this view will not show you exactly which class within the assembly references the other classes. If you want that you need to generate a dependency graph by class. Choose Architecture | Generate Dependency Graph | By Class and you get a diagram that shows you each of your classes and the classes they reference in their code.

ClassDependencyGraphZoomIn

Figure 4 Class Dependency Graph

You can see in Figure 4, now we have an up to date view of all our classes and their dependencies. This can make it a lot easier to figure out where to find the code we need to update for a fix, or to determine the impact and effort that will be involved in a particular change.

So there you have it, there are other reverse engineering tools out there, but life is simpler if you don’t have to keep launching separate applications to do everything, so make the most out of the tool you have. Visual Studio Rocks!

Today’s My 5 –

5 ways to learn more about Visual Studio 2010 Ultimate

  1. Download a free trial and play with it.
  2. Read the product description (it does wayyyy more than just let you write code!)
  3. Look at the Feature Comparison Chart so you can see what is available in each version of Visual Studio.
  4. Check out a video on the Lab Management feature, a little known gem in Visual Studio Ultimate.
  5. Check out Modelling projects, UML right in Visual Studio!

And please share your own documentation success or horror stories from your life as a developer on LinkedIn or by commenting on this blog! I am sure I am not the only one to inherit code with out of date or non existent documentation Smile

This blog is also available on the Solution Developer Blog

Free Training on .NET Framework 4 and Visual Studio 2010 on YOUR schedule

VisualStudioBoxThe Visual Studio Team has released a new Visual Studio 2010 and .NET Framework 4 Training Course. You can complete it online, or if you prefer you can download the training kit and work offline. For those who don’t have the training budget to take an in person course, these training kits are a fantastic resource! This course is designed for people who have already been playing with .NET but want to get up and running with the new features in .NET 4 and Visual Studio 2010.

The course includes presentations, hands-on labs, and demos. Whether you develop on windows or web, with VB or C#, there is material here to interest you. You will get a chance to look at C# 4, Parallel Extensions, Silverlight 4, ASP.NET 4, enhancements to the data platform, WCF, and Workflow updates, the Application Lifecycle Management tools in Visual Studio, Windows Azure, and more!

You do need Visual Studio 2010 in order to complete the labs. If you don’t have it yet you can download a full trial version.

Since we are in the planning stages for TechDays Canada 2011, I thought I would use TechDays as the inspiration for this week’s My 5.

5 Great Sessions from TechDays 2010 you can watch to learn more about .NET Framework 4 and Visual Studio 2010

  1. Getting Your Return on Investment with Microsoft .NET Framework 4 – this is an overview session of the new features in .NET Framework 4 across the different technologies
  2. Microsoft Visual Studio 2010 Tips and Tricks – For anyone who works with Visual Studio, pick up a few tricks to impress your boss and co-workers.
  3. New IDE and Language Features in Microsoft Visual Studio 2010 Using Visual Basic and C# – this session is focused on the new features in the programming languages themselves.
  4. Web Load Testing with Microsoft Visual Studio 2010 – Learn how to use VS2010 to make it easier to do your web load testing
  5. Microsoft Visual Studio 2010 for Web Development – improve your web deployment process

This post is also available on the Canadian Solution Developer blog.