Hands-On Labs Visual Studio IDE

Tuesday, December 7, 2010 by Rainer Stropek

This week I will be one of the speakers at BASTA On Tour in Munich. One of the topics I am going to speak about is the Managed Extensibility Framework (MEF). In this blog post I want to share my slides and summarize the hands-on labs that I am going to go through with the participants.

Hands-On Lab 1: Directory Catalog Sample

Prerequisites:

Lab step by step description:

  • Open ContosoAutomotive.sln. You can find this solution in the installation folder for the training kit under Demos\ContosoAutomotive\Source\C#.
  • Run the application to get familiar with it's functionality.
  • Solution and projects:
    • Take a look at the soluction's project structure using the Solution Explorer.
    • Open the solution file in a text editor and take a look at it's structure.
    • Unload the project ContosoAutomotive.Common using the Solution Explorer.
    • Launch editor for ContosoAutomotive.Common.csproj using the Solution Explorer and take a look at it's structure.
    • Reload the project ContosoAutomotive.Common using the Solution Explorer.
  • Navigation:
    • Use the Navigate To feature to open the definition for class CohoQuery
      • Try the different features of Navigate To (e.g. case insensitive search, pascal casing, search for file names, etc.)
    • Try outlining features using mouse and keyboard commands.
    • Use the Find in files feature to look for ICarQuery.
      • Try the different navigation features available for search results (e.g. F8, Ctrl + "-", etc.)
    • Open ICarQuery.cs, put the cursor on the interface's name, try the Find Symbol Result feature (Shift + F12)
    • Use the Find in files feature to find all files (file names) that contain the word Query.
    • Open CohoQuery.cs, put the cursor on the class's base class (CarQueryBase), try the Go To Definition feature (F12)
    • Use the Go To Definition feature for a class defined in the .NET class library (e.g. INotifyPropertyChanged).
    • Try at least one of the find scenarios from above using the Find/Command Box.
    • Use the Navigate To feature to open the definition for the method Generate
    • Try the Call Hierarchy feature for this method (Ctrl+K, R)
    • Open the Code Definition Window, put the cursor on different variables, class names, etc. and watch how the Code Definition Windows changes.
    • Add a //TODO: comment and see if the comment appears in the task list.
    • Open CashMaker.xaml and try the Document Outline feature inside the XAML file.

Hands-On Lab 2: IntelliSense

Prerequisites:

  • Visual Studio 2010

Lab step by step description:

  • Open the existing code snippet for the C# for statement ( C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC#\Snippets\1033\Visual C#\for.snippet)
    • You can find out the location of the snippet file using the Code Snippets Manager feature.
  • Take a look at how the snippet is implemented.
  • Create an empty solution IntelliSenseDemo.
  • Add a new class library project Utilities.
  • Rename class1.cs to MathUtilities.cs.
  • Change the MathUtilities class to static.
  • Add a new test projectUtilitiesTest to your solution.
  • Add a reference to the Utilities class library project to the newly created test project.
  • Change the name of the generated test method TestMethod1 to TestIsEven.
  • Implement the method TestIsEvenas follows:
    • Tip: Use for snippet to generate the loop's code.
[TestMethod]
public void TestIsEven()
{
 for (int i = 0; i < 10; i++)
 {
  bool isEven = MathUtilities.IsEven(i);
  Assert.AreEqual(i % 2 == 0, isEven);
 }
}
  • Resolve the missing using statement by setting the cursor on MathUtilities and pressing Ctrl + .
  • Generate the code for IsEven by setting the cursor on IsEven and pressing Ctrl + .
  • Navigate to the generated code by using the Go To Definition feature (F12).
  • Implement the IsEven method: return i % 2 == 0;
  • Remove unused usings and sort usings (Visual Studio can do that for you).
  • Run unit tests and see if you get a green check in the test result window.
    • Test / Debug / All Tests in solution
  • Try to add additional method / test methods and test the differences between IntelliSense completion and suggestion mode.
  • Optional (if you are fast): Try to add and use you own custom snippet file. 
comments powered by Disqus

Rainer Stropek

Rainer Stropek

Co-founder, architect, developer

Bio

I am co-founder and CEO of the company software architects and have been serving this role since 2008. At software architects my team and I are developing the award-winning SaaS solution time cockpit. Previously, I founded and led IT consulting firms that worked in the area of developing software solutions based on the Microsoft technology stack.

In my work I focus on .NET development and software architecture. I have written some books and articles on C#, database development, Windows Azure, Windows 8 development, WPF, and Silverlight. Regularly I speak at conferences, do workshops and conduct trainings in Europe and the US. Since 2010 I have been MVP for Windows Azure.

I graduated the Higher Technical School Leonding (AT) for MIS with honors and hold a BSc (Hons) Computer Studies of the University of Derby (UK).

Contact

Twitter: @rstropek
Facebook
Google+
Xing
LinkedIn

Authors