Category Archives: Visual Studio

PDC09 : How VS2010 was built with WPF ?

PDC09

In my last blog post, I did a review of a PDC09 Session “Advanced performance tuning with WPF”. Today, I’m doing a review for another very interesting session “How VS2010 was built with WPF ?”. The video is available here.

vs2008tovs2010

Why did Microsoft choose WPF for VS2010 ?

  • Technological: prove the capabilities of WPF4
  • Architectural
    • Separated presentation
    • Support for long range road map (+10 years)
  • Key VS2010 features need it: Editor, Architecture Editor, Parallel tools debugging
  • Take an opportunity to give feedback for WPF4: when VS2010 development started, .Net 3.5 SP1 was just shipped and it was the right time to give feedback for the new features and fixes for WPF4.

It is worth noting that VS2010 is a project that is being watched carefully inside Microsoft. We can expect that more Microsoft applications will move to WPF in the next coming years.

What WPF features are used ?

  • Declarative UI using XAML
  • Databinding
  • Styles and templates
  • Application Resources
  • Interop Win32 (because they did not have the time to rewrite everything using WPF or because features doest not need to use WPF for example de WinForms designer…)
  • Integration with the message loop (to deal with particular focus issues)
  • New text stack (part of WPF4) based on DirectWrite

Staged approach

  • Define data models: a huge diagramming and architectural exercice
  • Replace the main window with WPF (only the window not its content !) to start the mix approach (managed/unmanaged, WPF/Hwnds)
  • Write new managed components: Window manager, command bar presentation
  • Scout with other VS teams
  • Test, Test, Test…

What were the challenges ?

  • Mixed mode application: native and managed code; WPF and HWNDs (Win32 or WinForms)
  • Keep existing extensions working and allow new extensions to take advantage of WPF
  • Don’t “stop the train” other teams were working at the same time on the product to add new functionalities
  • Text clarity
  • Performance
  • Focus management

You can watch the session here if you want more detail and demos of what I mention in this post.

Using Snoop to take a look at VS2010 !

Update 18th january 2011: as Cory pointed out, the latest version of Snoop is now available on CodePlex.

If like me you’re curious about how big WPF applications are made, you probably tried to use Snoop to inspect the visual tree of Visual Studio 2010 Beta2. And you probably had a problem because Snoop wasn’t able to detect the devenv process of VS2010:

I wasn’t sure about the cause of this problem, but I grab the source of Snoop and took a look at the code that list the available window:

public void Refresh() {
	this.windows.Clear();

	foreach (IntPtr windowHandle in NativeMethods.ToplevelWindows) {
		WindowInfo window = new WindowInfo(windowHandle, this);
		if (window.IsValidProcess && !this.HasProcess(window.OwningProcess))
			this.windows.Add(window);
	}

	if (this.windows.Count > 0)
		this.windowsView.MoveCurrentTo(this.windows[0]);
}

I setup a breakpoint to find out what was wrong and discover that the window.IsValidProcess failed with the VS2010 process. Because I just wanted to check if it was the only reason why Snoop wasn’t able to inspect it, I hack the code to remove this test:

public void Refresh() {
	this.windows.Clear();

	foreach (IntPtr windowHandle in NativeMethods.ToplevelWindows) {
		WindowInfo window = new WindowInfo(windowHandle, this);
		if (/*window.IsValidProcess &&*/ !this.HasProcess(window.OwningProcess))
			this.windows.Add(window);
	}

	if (this.windows.Count > 0)
		this.windowsView.MoveCurrentTo(this.windows[0]);
}

And it’s working:

vs2010-snoop

Happy exploration with Snoop 🙂