Sample: Get Calendar Data Using Exchange Web Services (C#)

When someone asked my former manager David Treadwell what he did on a daily basis his answer was “Go to meetings and delete email”.  Unfortunately that often describes my life as well.  It is always challenging to manage your time.  I want to ensure I’m spending enough on technology, people, customers, etc.  To make this easier, I’m using the Categories feature of Exchange to code each meeting I have (these are my custom categories):

image

At a glance I can then tell what kind of meeting I’m headed to next.  But I still need a way to understand how I’m spending my time every month.  What would be great is to collect all the category data from all my meetings and then get the ratios.  This blog covers a sample that does that.

There are several ways you can get your calendar data.  In this case the task is very simple:  collect all calendar items in a given month including the category setting.  The easiest way to do this is to use Exchange Web Services support to ask the server for the data directly.  The sample has a library which can be used to connect to EWS and collect all the calendar items and a console application which provides an easy way to drive the program logic.  The following shows the overall structure of the sample code (click for larger image):

image

The diagram was generated using new Generate Dependency Graph feature of Visual Studio Ultimate.  The graph is created by shredding the binaries themselves so we find everything.

There are a few key areas to look through for EWS code.  The first is the GetExchangeProxy helper which sets up the connection to Exchange using ExchangeServiceBinding.  In this case we are using integrated Windows security so that a userid/password is not required (you could supply them as an alternative):

image

The next interesting helper method is BuildQueryFilter which is responsible for creating a FindItemType filter class.  This class allows you to construct a query for the server to find the data we care about.  The code builds up a series of arguments to scope calendar items between the start and end dates.  For example, this snippet of code sets a criteria of all dates greater than or equal to the start date:

image

A similar block of code sets the filter for less than or equal to the end date.  Finally these two conditions are combined with an And clause to essentially mean “>= start AND <= end”:

image

Once the filter is set, we can retrieve all of the calendar items we asked for.  In this case I’m returning the array in our own CalendarItemList which will allow us to enumerate the data from the client code.  The GetNextItem method will then strip the full Exchange calendar item (with over 100 fields) down to just a handful we care about and return the data in a CalendarItemData instance.  There are a huge number of fields available for return.  You can use the DebugTraceCalItem helper method to dump the entire type if you are interested in pulling back more data.

The console application then becomes pretty easy:  parse and validate all the arguments, connect to the exchange server, then write each calendar item out in a comma separated view (CSV) format.  The output can either be written directly to a file or to the console for redirection to other locations.  At that point it is very easy to simply open the file directly in Excel where you can edit it, create charts, analyze it, etc. 

I’ve included a sequence diagram in the project which demonstrates the core logic of the Run method (click for larger image):

image

(Note that generating a sequence diagram with VS Ultimate is very easy: just place your cursor in the method and right click to run “Generate Sequence Diagram”)

image

Running the application is now very simple:

timespent /start:9/1/2009 /end:9/30/2009 /out:c:\temp\sept09.csv /mailpath:https://mydomain/ews/exchange.asmx

“mydomain” in this case is the domain address for your Exchange server.  You can get this from your exchange administrator (it will likely match the path you are using on your phone to sync your mail over the air). 

You can download the Exchange SDK from MSDN here.  You can download a full copy of the source code here.

Enjoy!

Posted 24 November 09 06:00 by Jasonz | 2 Comments   
Filed under
Announced at TechEd Europe, Teamprise Client Suite Acquisition

This afternoon in Berlin I gave the Developer General Session (keynote) around Visual Studio 2010.  As part of that keynote we have formally announced the purchase of the Teamprise Client Suite from Teamprise (a division of SourceGear). You can read details on Brian Harry’s blog here.

I’m very excited about bringing Teamprise into the Visual Studio family of products.  Many of you work in heterogeneous environments and having the Teamprise Client Suite means you can collaborate through Team Foundation Server (TFS) even if parts of your team are working with other systems like Eclipse.  I want to welcome the new Teamprise employees who now join our team at Microsoft!

Also at during the keynote I had a chance to bring three of our partners on stage to demo their new products base on Visual Studio 2010:

  • Micro Focus demonstrated their new COBOL support in the IDE including using the editor extensions for visually showing code flow, architecture diagram extensions (through DGML) for showing a flowchart of code logic, and new visualization support for seeing a preview of mainframe terminal displays.
  • Quest Software demonstrated their Oracle support for the advanced database features (now part of Visual Studio Premium and Ultimate).  With this support you can now import Oracle schema directly into Visual Studio, refactor database schema, and the other pre and post production features.
  • PreEmptive Solutions demonstrated their new support for instrumentation of code which can return runtime statics and information about how code is executed in the wild.  New support includes extensions for the architecture diagram (through DGML), a new margin control with preview of runtime data, and an inline WPF based graph system so one can review data directly in their editor next to the code which is impacted.

All of these solutions demonstrate the advanced features we are now starting to see on the core investments made with VS2010 (including the new editor, WPF investments, DGML, and others).

TechEd has been a lot of fun so far.  For those of you here in Berlin, I look forward to seeing you at the celebrations of the 20th anniversary of the “fall of the wall” this evening.  Enjoy TechEd!

Posted 09 November 09 09:58 by Jasonz | 0 Comments   
Filed under
VS2010 Beta 2 Feedback Survey

Last week we shipped Beta 2 for broad distribution.  Many of you have already sent us comments and improvement suggestions (thanks!)

At this point we are down to our final set of bug fixing, perf tuning, etc.  I’m very much interested in your feedback so we can take action on it before we ship the final version.  To help make it easy, you can take this simple survey.

imageOne thing in particular I am hearing a lot of feedback on is performance.  We are working hard on the next round of perf improvements.  You can supply your feedback through the survey.  When you give us your feedback, the more actionable you can make it the better.  We need to know what operations you are doing (like editing, debugging, etc), what kind of hardware you have (CPU, RAM, disk), and your hosting scenario (main machine, running in VM, terminal server, etc).

thanks in advance for your feedback!

Jason

Tutorial: Getting Started with TFS in VS2010

Earlier this month we announced the new Basic configuration for TFS.  This configuration gives you an easy to set up version of TFS that supports source control, work items, and builds.  It is a great place to migrate your Visual Source Safe assets and pick up new features in the process.  Now that we have released the formal Beta 2 bits for VS2010, I wanted to do a walk through on how to get started using the system. 

This post will be most helpful for those of you who have not installed or used TFS before.  TFS can support sophisticated environments that include reporting, SharePoint integration, support across multiple domains, distributed databases, etc.  I’m not going to cover any of that here.  Instead my goal is to help you understand “why TFS” and how you can get started using the system.  In a future post I will walk through the process to convert a Visual Source Safe database into TFS in case you are coming from a VSS deployment today.

First let’s talk about “why TFS?”  The goal of Team Foundation Server is to create a central repository with a set of tools that make it really easy to collaborate between roles.  You could try to stitch together multiple disparate systems as follows:

image

In this case each system has its own storage, own set of identity for assets, own commands and tools.  Getting this going is like trying to hook up a set of custom stereo components:  you can pull it off but it’s going to be a lot of work and you are missing out on some stuff.

What I’d rather have is a system which can integrate these items together and then enable my default work flow through the system:

image

This integration enables some very common scenarios.  In a typical day I’m going to edit source code, build the product, test it, file bugs, fix them, lather/rinse/repeat.  When the entire work flow is supported with one integrated repository then all items can be related to each other.  As an example when I check in bug fixes I’d really like to see those defects resolved with the change set recorded (see sample below).

The Basic configuration of TFS allows you to do precisely this which is a big improvement over just having source control.  The full version of TFS then adds new features including automated testing, virtual lab deployment, and architectural validation (to name a few).  This expands your work flow as follows:

image

You can decide which of these new components you add when you use the Visual Studio Premium and Ultimate SKUs. 

There are many ways to access TFS.  As an engineer your most typical access point will be a version of Visual Studio.  But if you are a tester you can use the new Test and Lab Manager product (no VS install necessary).  If you are a project manager, you can also use the Web interface, Excel, Microsoft Project, or (new for VS2010) MOSS support for dashboards.  More on this later.

In the rest of this post I will give you some step by step instructions on how to get going with TFS using the basic configuration for your first project.

Getting Started

Now that you have the conceptual level it’s time to hook things up.  You should start by doing the steps listed in Brian Harry’s TFS post here.  This will get all the required software on your machine with a default collection, creatively enough called DefaultCollection.

At this point we can connect to the TFS collection from Visual Studio.  The easiest way to accomplish this is to use the Team Menu (you can also use the link from the home page):

image

You will be asked to find the Server where TFS lives.  In this case my Windows 7 machine is called JLZB2REL.  Add the server to the list using the Add button, then click Close:

image

At this point you can select the server from the combo box and then the DefaultCollection, then click Connect:

image

The Team Explorer tab will now have your server connection and DefaultCollection, but we don’t yet have a TFS Project to store anything in yet:

image

For this tutorial I have created a new Windows Form project to act as our sample solution (File, New Project, Windows Forms).  If you try to add this new code project to source control, you will get an error.  For example:

image

After you select the “Add Solution to Source Control” menu item you get the error “No team project source control folders are available.”:

image

The error isn’t that intuitive (especially given the word project is used for both TFS and inside your VS code solution but are different things).  The error means you must create an actual TFS project to contain all of the assets for your work.  In the Team Explorer, right click your collection and choose New Team Project:

image

In this case I’m going to create a TFS project for an Accounts Payable system.  This project will contain all of the solutions, data, etc required for the overall system.  After entering the data, click Next:

image

The Agile template is the default but you can also select CMMI.  You can find more details on MSDN about the project template types.  If you are using any agile methodologies (like TDD) this is a fine choice.  After making a choice, just click Finish:

image

You will get various status updates as the project is being created:

image

After success, click the Close button:

image

Team Explorer will now have the project ready to hold Work Items, Builds, and Source Control:

image

At this point you can update the project collection.  Let’s add the new solution to TFS again.  Right click the project in the Solution Explorer and select Add Solution to Source Control:

image

At this point you could create a new folder in TFS for the solution or just take the default.  When you are happy, click the OK button:

image

Upon success the Solution Explorer will now show the files are under source control (see the ‘+’ symbol in front of the files):

image

You will also see the list source control actions taken to publish the solution.  Add a comment and then click Check-In:

image

Confirm the check-in by clicking Yes.

image

At this point your new solution is in TFS and ready for Work Items.

Work Items

You can create work items directly inside Visual Studio using the Team Explorer, through the web front end, and the Test and Lab Management tool.  To look at your work items, open the Team Explorer and expand the Work Items, Team Queries item.  You can then double click any query (such as Active Bugs) to see any items available to you:

image

Our TFS project is empty so there are no active bugs in the list:

image

Let’s create a new item just to get us in business.  Select the Team, New Work Item menu.  Here you can create several types of work items to track features, defects, etc.  We’ll select Bug to get going:

image

Enter any data you want for the new bug and click Save Work Item to commit it to the database:

image

If you now refresh your active bug query list, you will see the new bug:

image

Let’s add a real bug to fix our project.  In my example I just created a default Windows Forms application.  We’ll want to update the title:

image

Now we need to fix the bug.  Navigate back to the Solution Explorer, select Form1.cs then choose Check Out for Edit:

image

Click the Check Out button to confirm:

image

The file will now have a check mark next to it so you know it is open for edit:

image

As you update the Text property of the main window, VS will automatically check out any dependent files for you:

image

This is a Windows Forms application but it works on all solution/project types.  Now that we are happy with the code change, select the Pending Changes tab in the bottom of VS:

image

In this case we are fixing a bug, so click the Work Items icon button:

image

Select bug #2 which tracks our title error.  We are going to resolve it with this check-in:

image

Add any comments you want and click Check-In, then Yes to confirm:

image

image

If you refresh bug #2, you will now see the status changed to Resolved and the history is updated:

image 

Notice the change set (the set of source control changes) have been automatically included in the history.

image

At this point you could continue to create and fix bugs as required to ship your solution. 

Other Ways to Explore TFS

I mentioned that you don’t have to use VS itself to access the TFS repository.  We’ve done a lot of deep integration with other clients like the Web and Office.  As an example, I can simply pull up my web browser and go right to my server by using the server name (where 8080 is the default port):  http://jlzb2rel:8080/tfs/

image

At this point I can explore my collections and projects.  If you select the new AccountsPayable project we just created then the Continue button, you get more details.  In this case by navigating to the Work Items tab I can find the bugs in the system including our newly resolved bug:

image

This is a really easy way to explore your project from any machine with no setup required.  There is similar support for using Excel, Microsoft Project, etc.  This kind of access makes it easy for all people working on your project (engineers and project managers) to work together.

At this point you have a very useful set of assets you can use to get your job done.  For those of you using VSS today, you might be very happy with just this level of support.  You can put down this tutorial now and come back later if you want to try some advanced features, for example the testing scenario I showed using beta 1 in this tutorial.

Build Support

The next typical part of your work flow will be to automate your builds for the product.  Assuming you followed Brian’s installation instructions, you now have local build support on your machine with TFS Basic.  The first step is to navigate to the Team Explorer, right click on Build Definitions, and select New Build Definition:

image

This will give us a set of definitions to fill out, just like a code project property page:

image

The Trigger page allows us to decide when builds are kicked off.  You have many options to pick from:

  • By default this is manual which is the option we will use.  We will have to kick of our own builds with this option.
  • Continuous Integration is very helpful when you want to have a new build after every check-in.  This allows you to validate new changes right away rather than waiting later when many check-ins get mixed together. 
  • Rolling builds give you a way to batch changes together which is very handy when builds are starting to take a while and you can’t afford to do every one. 
  • Gated Check-ins allow you to ensure all check-ins build before they are committed to TFS.  This makes sure you never expose a build break to other members of your team.
  • Scheduled builds are useful for getting a daily build out for the entire team to try out.

You can create and use many different build definitions which allow you to employ different build types for different purposes.

You can explore all the tabs at your leisure (each is fully documented with the product).  But we need to resolve the yellow warning sign on Build Defaults by giving the build a place to store our new build, in this case a public UNC I created on my machine:

image

Now you can save the build definition to TFS.  If we go back to the Team Explorer we can queue a build of the project:

image

We’ll get a confirmation dialog where we can just select the Queue button:

image

This will then queue off a build on my machine as shown by the status page:

image  

If you double click the queued build you will get the detailed status of the build:

image

From here you can see warnings and errors, view the log file, navigate to the drop, etc.  As an example if you select the “View Log File” link you can see the executed build script (subset):

image

If you select the Open Drop Folder link you will be taken to our drop location:

image

Now anyone can pick up the build and do their daily testing, release to a customer, etc.

At this point you really have everything you need to make full use of the Basic configuration of TFS. 

In the future I will do a tutorial on how to hook up the Virtual Lab system (part of Visual Studio Ultimate) which allows you to deploy complex applications to a Hyper-V environment and do automated testing.

Creating a New TFS Collection

[Note this section is totally optional]  You can store all of your work in one TFS Collection if you like.  If you are a Visual SourceSafe user today, this is just fine and you can skip this whole section.  But if you want to create a new top level collection, it is pretty easy.  The first step is to start then Team Foundation Administration Console: 

image

After the console starts, select the Team Project Collections item and click the “Create Team Project Collection” link:

image

Fill in a name for the project collection and any description you want, then click Next:

image

Accept the defaults for the data tier, then click Next:

image

The Basic configuration for TFS does not support Lab Management, so just click Next on this step:

image

At this point all the required data is configured and you can click the Verify button:

image

The verification step will ensure the collection can be created:

image

Once it passes, click the Create button:

image

This will provision all the required pieces of the TFS store per our configurations.  Click Next and you are done:

image

You will now see the new project collection with the default version:

image

Posted 21 October 09 01:00 by Jasonz | 14 Comments   
Filed under
Announcing VS2010 / .NET Framework Beta 2!

I’m happy to announce that Beta 2 is now ready for download!  MSDN subscribers may download the beta immediately with general availability on Wednesday.  Beta 2 comes with a “go live” license which means you can start using the product for production related work (see the license agreement with the product for more details).

I have a few tutorials queued up which I will be publishing over the next several weeks; stay tuned.

image

The biggest change you’ll see with these release is the change to the SKU line up.  The goal with the new line up is to reduce the number of SKU’s you have to think about and install and make it a very simple set:

  • Visual Studio Express:  the free Express SKUs for C++, C#, VB, and Web have been updated and released with this version and give you the basics for writing applications
  • Microsoft Visual Studio 2010 Professional with MSDN: professional development tools as you are used to today with the addition of source control integration, extensibility, etc.
  • Microsoft Visual Studio 2010 Premium with MSDN: Premium has everything in Professional plus advanced development (including profiling and debugging), advanced database support, coded UI testing, etc.  Rather than buying multiple “Team” SKUs, you can now get this combination of features in one box.
  • Microsoft Visual Studio 2010 Ultimate with MSDN: Ultimate has everything in Premium plus additional advanced features for developers, testers, and architects including features like Intellitrace (formerly Historical Debugging), the new architecture tools (UML, discovery), etc.  All of the scenarios we’ve talked about are supported with this version of the product.

In addition to these changes, Team Foundation Server (TFS) is now available with all versions of Visual Studio 2010.  You can get started with TFS Basic and work up to full multi-sever support, SharePoint integration, etc as your needs grow.

The new “Test Elements” SKU is designed for testers who don’t need to write code.  You can manage your test cases, work items, and do manual testing using the SKU.  Because everything is integrated through TFS, you can continue to collaborate with the entire team.

The UI has been refreshed with a new start page that gives you quick links to common tasks or background on programming tasks.  I have TFS Basic installed on my laptop; you can see Team Explorer support for source control, work items, and builds:

image

Beta 2 now ships with several new project types we’ve mentioned before such as Windows Azure (under “Cloud Service”) and SharePoint, all available for C# and Visual Basic programmers:

image

In addition support for Silverlight 3 and ASP.NET MVC 2 are included in the build.

As an engineering team, the goal for Beta 2 was to work very hard on performance, stability, and the integration of the feature set.  Our focus is now transitioning to getting your feedback on the product and preparing for the release candidate (RC) milestone which is our final milestone before shipping the product.  Please download the beta and send us your feedback.

Enjoy!

Jason

Posted 19 October 09 06:07 by Jasonz | 60 Comments   
Filed under ,
Announcing TFS Basic!

If you are a SourceSafe user you know VSS is an easy to install and easy to use source control system.  TFS gives you a much more powerful system including not only source control but also work item tracking and build support.  Today we are announcing the new Basic configuration for TFS coming your way with Beta 2 of VS2010.  Brian Harry has a great post introducing the new configuration and going over some history and design goals.  My favorite features:

  • You can use SQL Server Express as the database
  • The install runs in about 20 minutes and configures everything for you automatically
  • It can run on your client machine

I’ve been using it to build out several new tutorials I’m queuing up for Beta 2.  It’s awesome!  Stay tuned for Beta 2 and make sure to give it a try...

Posted 02 October 09 04:21 by Jasonz | 25 Comments   
Filed under
Staff Meeting Bingo (aka Geo Distributed Engineering Challenges)

Like many of you my engineering organization is spread out around the globe.  With some recent relocations we’ve hit a point where we can no longer have a staff meeting slot that actually works for everyone.  Jeff Beehler (our Chief of Staff for Visual Studio) just sent out a great chart demonstrating the issue as we searched for a good time to meet:

image

We use several different techniques to help make things work (not exhaustive). 

For keeping the team in sync, every meeting has a Live Meeting link in the invite.  My “All Hands” meetings are also done with a Live Meeting link and in some cases I’ll repeat the content in person when I’m visiting a dev center.

For engineering purposes we (obviously) make heavy use of TFS to track features, source, etc.  Product teams work in their own “PU branches” for reasonable isolation and changes are integrated at the central branch on a regular basis.  Standard sets of tests and verifications are run as code goes up / down in the system to help prevent breaks across the system.  Making these kind of scenarios easier was part of the motivation behind our new testing features in VS2010.  There are similar benefits with the new architecture features (like layer validation).  Etc…

Have you developed best practices for working in a geo distributed environment?

Posted 04 September 09 10:11 by Jasonz | 1 Comments   
Filed under
Sample: Parsing Content in C# Using IFilter

I’m working on a 3 (or 4) part tutorial right now that requires parsing of PDF files.  The code started to get big enough I decided to pull it out and turn it into a new post that I can use in the series (stay tuned).

There are several solutions for reading through various file formats.  The IFilter interface was defined to help Windows do search indexing on files for this purpose.  There are lot’s of filter providers for various formats, including several from Microsoft.  If you want to parse PDF files you’ll need to have a provider installed for that as well.  The FoxIt IFilter download page has a provider that according to their website is free for client use (my case).

In looking around for some sample code I found a few examples that did close to what I wanted but didn’t have a lot of luck finding a C# example.  I’ve pulled together various pieces of code to create a basic implementation for my (simple) needs.  You can find some interesting links here:

The sample contains a class library for parsing the code and a console application that can be used to exercise the library against files.  The code is built using a current internal build of VS2010 (stay tuned here for beta notice) but the key code (FilterCode.cs) should work fine on previous versions of VS and .NET Framework.

I’ve uploaded the solution to the MSDN code gallery here:

To use the sample, include FilterCode.cs in your project, create a new instance of FilterLibrary.FilterCode, and call the GetTextFromDocument method against the file you want to parse.  If you have a filter installed for that document type, you will get back a StringBuilder with the text contents of the file.

Enjoy!

Posted 31 August 09 05:09 by Jasonz | 7 Comments   
Filed under ,
Popfly Game Engine Source Code Released

Ben Anderson just released the source code for the Popfly Game Engine on codeplex.  You can read Ben’s full post here and download the source code here.  The project is a C# Silverlight application that demonstrates several concepts of XAML and .NET for RIA.

Posted 27 August 09 03:42 by Jasonz | 5 Comments   
Filed under
Announcing the XP2Win7 Reference Application

If you are like me you’ve been using Windows 7 for a while now and it’s a great release!  There are a number of very cool features in the system, including things like touch and sensor support.  We want to make sure it is easy for you to get started lighting up your application, managed or unmanaged, with the new system.  To that end I’m happy to announce the availability of the new XP2Win7 Reference Application which you can download here:

Filmstrip

XP2Win7 Reference Application

The download contains a full set of reference material and source code.  The demo is a fully functional application called PhotoView which shows many categories:

  • Infrastructural work like Restart & Recovery, and IO Optimization
  • User interaction support like jump lists and local search
  • And cool Windows 7 light up with touch and sensors

The application makes it easy to explore each feature with a tab pane at the top:

image

In this example you can see a light sensor plugged into the left (the bar chart mixer view).

Win7 is going to be an awesome release and I hope you will find this application a great resource to get started.

Enjoy!

Posted 14 July 09 04:46 by Jasonz | 11 Comments   
Filed under
Distinguished T-Shirt Engineer Best Hits

One of the fun things I used to do while running the CLR team was help pick out the final design for our t-shirts (not that picking out code generation strategies wasn’t also fun).  Fortunately Sonja Keserovic on our team is a master at designing awesome shirts (while not doing her day job designing engines and languages).  She just sent me the “best of” shirts from over the years:

Sonja's TShirts 1

“Enter the Core”

You’ll notice a big movie inspiration in the designs.  The matrix style green text is actually the MSIL for “Hello World” run through ildasm.  You can read through the PE file header and string table in addition to the IL instructions themselves.

Sonja's TShirts 7

“Roll Call”

Always the analytical bunch, this shirt has every email name for everyone on the team. Colors denote discipline (I’m white for ‘pointy hair’), font size denotes how long you’d been on the CLR team.  The island behind the front logo is Whidbey island, the code name for V2.0.

Sonja's TShirts 4

“One Runtime to Run them All”

Around the time of LOTR, this text that makes up the ring is actually the source control root for every Microsoft project using the CLR at the time (with a nice Elvish style font).

Sonja's TShirts 5

“Don’t Panic”

The final build number for the V2.0 product was V2.0.50727.42, just around the time the Hitchhiker’s Guide movie came out.  Did I mention we like geeky stuff?

Sonja is now a SDE on the languages team in VS and is creating an awesome new VS design involving pi calculus, can’t wait to see it!

Posted 17 June 09 03:55 by Jasonz | 14 Comments   
Filed under
MVC 1.1 for VS2010 Beta 1 Released

The MVC framework for ASP.NET allows you to create applications that follow the model/view/controller architecture.  VS2010 Beta 1 did not have MVC built-in to the product but you can now download it here.  MVC will be included in the final release of the product.

After installation you will have MVC templates installed for both VB and C#:

image

Scott Guthrie has a fantastic walk through on MVC using the VS2008 product which is also be relevant to V2010 (modulo a few dialog changes here and there).

Enjoy!

Posted 12 June 09 07:43 by Jasonz | 7 Comments   
Filed under
VS2010 Tutorial: Building VS Extensions with the Beta 1 SDK

The SDK is used to create extensions to Visual Studio itself like those you can find on VS Gallery.  You can download it here.  The installation is done on top of an existing install of VS 2010 and gives you a set of build tools, templates, and a short cut for debugging devenv.exe (VS) that can be used for testing your new extensions.

Once you get the SDK installed, you will find a new set of templates.  Let’s start by doing File, New Project.  Type ‘editor’ in the search box to find example editor extensions:

image

Select the ‘Editor Text Adornment’ template and click OK.  This sample template extends the editor with a Text Adornment which basically gives you the ability to change how text is displayed.  By default this adornment finds all instances of the character ‘a’ and highlights them.

Build the solution (Ctrl+Shift+B).  The template automatically packages the new .dll into a .vsix file (basically a zip with some dialogs, the code, and other data required to extend VS).  It then copies the new package into the Extensions directory for the test instance of VS:

image

Now hit F5 to debug the new extension.  Because you are extending Visual Studio itself, the test instance of VS is launched:

image

This is a separate instance of devenv.exe as shown by tlist:

image

Notice the key difference is devenv.exe is launched with a special /rootsuffix flag which gives it a different instance for the extension location:

image

In the experimental instance of VS, open a text file (such as the one generated for this add-in).  When it loads, you’ll notice the editor extension is in effect and has drawn a red box around every ‘a’ in the file:

image

image

The code is pretty straightforward.  The constructor sets up a event handler for layout changed, whenever the change happens every line is scanned, within each line when an ‘a’ is found a red box is placed around it.

If you open the .vsixmanifest file you will get an editor for all the settings an extension needs:

image

This includes things like the images you will see when you browse / install the extension, the description, etc. 

Extensions can be easily shared with your friends.  To install an extension, either double click the VSIX file to install it or copy the unzipped extension contents to your extensions directory.

In addition to local usage, you can also publish (or acquire) extensions from the VS Gallery.  This is easy to do from inside VS by choosing Tools, Extension Manager:

image

If you select the Online Gallery, you will find all the controls, templates, and tools from the public site:

image

You can easily download and install an extension by selecting it and hitting the Download button. In this case I’ll download the Demo Dashboard which is one of our samples:

image

After you download the file (assuming you accept the license), you will be prompted to restart VS so the extension can be loaded:

image

If you select Restart Now, VS will start again and restore your state.  The new extension is now in place:

image

Once you have written an extension you really like and you think others may want, you can use the VS Gallery site to upload your item:

image

You can update, delete, etc your extension after it is uploaded.

As you can see, loading new items, creating new items, etc is very straightforward.  I’m looking forward to seeing what you come up with.

Enjoy!

Posted 01 June 09 04:00 by Jasonz | 10 Comments   
Filed under
Azure: New Support for the Cloud, New Skills Not Required

Last October at PDC, the Windows Azure team released the first CTP of Windows Azure along with the first SDK for developers who are interested in pushing their apps to the cloud.  The team committed to releasing regular SDK updates, and today we are announcing an update to Windows Azure Tools for Visual Studio.  This release includes:

  • Visual Studio 2010 Beta 1 support
  • Update for Visual Studio 2008 support
  • Improved Visual Studio integration with Development Fabric and Development Storage

This is in addition to the current Windows Azure Tools for Visual Studio, which includes:

  • C# and VB Project Templates for building Cloud Services
  • Tools to change the Service Role configuration
  • Integrated local development via Development Fabric and Development Storage services
  • Debugging Cloud Service Roles running in the Development Fabric
  • Building and packaging of Cloud Service Packages
  • Browsing to the Azure Services Developer Portal

One of our key goals is to make your skills as a developer easily transferrable to new domains. If you learn .NET, pick a favorite language (like VB or C#), and learn Visual Studio, then you can easily use your skills to target the ASP.NET, Silverlight, SharePoint, Windows Mobile, and even the Xbox.  The tooling support for Azure brings your same skill set forward into the Cloud.

You can download the latest SDK for Windows Azure here.  If you’re interested in the cloud, check out the Windows Azure CTP and the SDK.  Make sure to check out the how to videos here.

Enjoy!

Posted 28 May 09 11:00 by Jasonz | 1 Comments   
Filed under ,
VS2010 Tutorial: Testing Tutorial (Step 2)

Last week I posted the Step 1 tutorial for creating a WPF application from scratch using Visual Studio 2010.  In this post, I’m going to create a test plan and test case for the application using the new Visual Studio Test and Lab Manager project.

For this tutorial, I’m using Visual Studio Team Suite 2010 (which includes all of the roles and TFS access).  I’ve already added the demo to TFS so I have full source control.  For the sake of demonstration, I’ve commented out the final fix from the walk through so the label does not update:

image

When I run the application, the label is not updated:

image

The Tester

To create my test, I’m going to run the Test and Lab Manager tool from the start menu:

image

The main page has tabs for test plans, tests, and for tracking work items:

image

First I need to connect to my TFS server by click Add.  My server is VLM13267036 (auto generated name by our internal Hyper-V testing tools):

image

I’ve already got a collection with my code stored in the Projects folder:

image

Next I’ll select Projects and choose the Connect option. This prompts me to set a context:

image

I’ll choose “Set context” which brings up the editor for my new context:

image

I’ll select New:

image

I can now edit all of the properties:

image

After all data has been entered, click Save and Close.  The new item is now in our list:

image

Double clicking the item allows me to add a new test case to this test suite:

image

Here you can fill out all details for the test case:

image

Steps can now be added by clicking on the “Click here to add a step”:

image

I’ve added a few steps including launching the application, hitting the buttons, etc:

image

Now hit Save and Close to go back to the test case list.  The Plan is now complete.  We can run it any time a new build is produced, for each flavor of build, for different configurations, etc.  To execute the test, change focus to the Test tab:

image

Our test plan and test case are already in the list.  Right click the test case and select Run:

image

This will launch the test case.  The manual test runner window docks itself to the left side of my desktop so I can see both the steps I want to run and the full Windows desktop:

image

The “Start test and record” option allows me to not only do the testing steps, but it will also allow recording a WMV of all the steps I do as well as recording my steps to help me author coded UI tests (big helper with automation).  This is really handy if you want someone to see exactly what you did to produce a bug and automate testing in the future. 

In this case I will select “Start test”.  Notice the Test Runner now shows the steps I created above:

image

The first step is to “Launch the PicViewer application” which I’ll do by running the application.  Since that worked, I’ll press the combo box status item behind the step and select ‘Pass’ from the drop down:

image

The item is now marked as passing:

image

I’ll repeat the process for the next two steps, so far so good:

image

When I get to my last step, I discover the file path isn’t actually set.  That makes this item a failure.  Select the drop down box and choose ‘Fail’ from the list.  I’m automatically asked for comments on the failure:

image

Since I didn’t record a video of my steps, I would like to give the developer a screen shot of what went wrong.  Select the camera tool bar button:

image

This will bring up a capture tool turning the cursor into a cross hair that allows me to select a region of the screen.  I’ll select the top of the application to demonstrate the busted label:

image

Notice that the failed test now has a .png file added with the image:

image

I’ve got enough supporting data now so I’ll create a new bug using the toolbar:

image

I’m now prompted to create my bug with a description, etc:

image

Notice the detailed test steps I’ve taken have already been added to the bug:

image

As has my screen shot (the .png file):

image

I’ll now do a Save and Close which will commit the bug to TFS as a Work Item.  Finally I’ll do End Test then Save and Close the test runner.  This will return us to Test and Lab Manager.

image

as a tester, I could now double click the test case and see all of the same data I just saved for the failure:

image

I can also select My Bugs and see the bug filed for this issue (since I conveniently assigned it to me):

image

And just to show how everything is wired together, I can open Visual Studio, Team Explorer and look for bugs assigned to me there as well:

image

At this point my job as a tester is now done. 

The Developer

As a developer, I can now open the bug and read through the issue.  If I select Other Links I’ll find the .png which I can open to see the issue:

image

Sure enough, the label is not updated.  If a WMV had been recorded, I could have actually watched the testing steps in action.  Because the bug is quite simple to find and fix (some idiot commented out the update line!) I can simply make my fix and test it.

Now that things are fixed, I want to check in the bug fix and resolve the work item at the same time.  Click on the Pending Changes tab in VS and select the correct work item:

image

Now we can Check In the fix:

image

I can now verify the bug has been Resolved:

image

In Summary

A key goal for Visual Studio Team System 2010 was to reduce the number of times a tester and developer wind up in a ‘no-repro’ situation.  There are several things I’ve demonstrated in this tutorial which help:

  • Test case steps are documented and set up for repeatable execution
  • Pass/Fail steps are outlined and stored in bugs automatically
  • Video capture is allowed to see all steps taken, and screen snapshots are easy to acquire and file with a bug
  • System information including build number, OS, etc are recorded for you (System Info tab)
  • Although not shown, I could also have collected all of the historical debugging traces from the run as well
  • All data from test cases, results, work items, and source code are kept in TFS and can be shared by test and dev

I hope you’ll pick up Beta 1 and try this set of tutorials for yourself.  Let us know how well it works for you and if you have any suggestions.  I should also point out the work item tracking, auto resolve, etc are all part of VS 2008 so a great way to get prepared for the new version is to get TFS deployed today and get your projects into the system.

Enjoy!

Posted 26 May 09 08:00 by Jasonz | 11 Comments   
Filed under
More Posts Next page »

Search

This Blog

Syndication

Page view tracker