MZ-Tools Articles Series: BUG: Inconsistent behavior of EnvDTE80.Events2.WindowVisibilityEvents from a Visual Studio add-in

A reader of my article:

HOWTO: Detect when a Visual Studio toolwindow is shown or hidden.
http://www.mztools.com/articles/2011/MZ2011010.aspx

pointed me to an inconsistent behavior of the EnvDTE80.Events2.WindowVisibilityEvents in one case, so I have investigated all the cases and I have documented all the inconsistent behaviors (which are a lot in several VS versions) in a new article:

BUG: Inconsistent behavior of EnvDTE80.Events2.WindowVisibilityEvents from a Visual Studio add-in
http://www.mztools.com/articles/2012/MZ2012001.aspx

Since VS 11 Beta exhibits the same two bugs than VS 2010, I have opened two bug reports to Microsoft:

EnvDTE80.Events2.WindowVisibilityEvents.WindowHiding event not fired when collapsing toolwindow
https://connect.microsoft.com/VisualStudio/feedback/details/729827/envdte80-events2-windowvisibilityevents-windowhiding-event-not-fired-when-collapsing-toolwindow#details

EnvDTE80.Events2.WindowVisibilityEvents.WindowShowing event fired twice
https://connect.microsoft.com/VisualStudio/feedback/details/729845/envdte80-events2-windowvisibilityevents-windowshowing-event-fired-twice#details

VS 11 Beta bug: EnvDTE80.Solution2.GetProjectTemplate(“ClassLibrary.zip”, “VisualBasic”) returns Windows Metro template

When running the unit tests of my MZ-Tools add-in today, I have found the following exception when creating a Class Library project:

System.Runtime.InteropServices.COMException (0x80042003): The project file ‘<omitted>’ cannot be opened.

The project type is not supported by this installation.
at Microsoft.VisualStudio.Windows.UI.Xaml.Project.ProjectFlavoring.TailoredLibraryProject.OnAggregationComplete()
at Microsoft.VisualStudio.Shell.Flavor.FlavoredProjectBase.Microsoft.VisualStudio.Shell.Flavor.IVsAggregatableProjectCorrected.OnAggregationComplete()
at EnvDTE.SolutionClass.AddFromTemplate(String FileName, String Destination, String ProjectName, Boolean Exclusive)
at Microsoft.VisualStudio.TemplateWizard.Wizard.Execute(Object application, Int32 hwndOwner, Object[]& ContextParams, Object[]& CustomParams, wizardResult& retval)
at EnvDTE.SolutionClass.AddFromTemplate(String FileName, String Destination, String ProjectName, Boolean Exclusive)

Debugging it I have found that the unit test was using the following template to create the project:

“C:\Program Files (x86)\Microsoft Visual Studio
11.0\Common7\IDE\ProjectTemplatesCache\VisualBasic\Windows Metro
style\1033\ClassLibrary.zipClassLibrary.vstemplate”

while in the past (using other VS versions and even VS 11 Developer Preview if I remember correctly) it was using:

“C:\Program Files (x86)\Microsoft Visual Studio
11.0\Common7\IDE\ProjectTemplatesCache\VisualBasic\Windows\1033\ClassLibrary.zipClassLibrary.vstemplate”

Notice that the former template belongs to “Windows Metro style” apps and the latter one belongs to “Windows” apps.

The unit test uses the following code to get the template:

EnvDTE80.Solution2.GetProjectTemplate(“ClassLibrary.zip”, “VisualBasic”)

and the root problem is that the “ClassLibrary.zip” template file name is duplicated in two folders, and therefore there is a conflict. According to the MSDN docs, templates should not duplicate names:

“Custom templates require unique file names that do not conflict with the file names defined in:

<drive>:Program Files\Microsoft Visual Studio 8\Common7\IDE\ProjectTemplates\Language

The doc refers to custom templates, but obviously it assumes that built-in templates provided by Microsoft already use unique names.

So, I have opened a bug report in Microsoft Connect:

EnvDTE80.Solution2.GetProjectTemplate(“ClassLibrary.zip”, “VisualBasic”) returns Windows Metro template
https://connect.microsoft.com/VisualStudio/feedback/details/728382/envdte80-solution2-getprojecttemplate-classlibrary-zip-visualbasic-returns-windows-metro-template

The workaround is to hardcode portions of the path to templates in the unit tests, avoiding the Solution2.GetProjectTemplate method. UPDATE (05-JUL-2013): Apparently there is another workaround for the C# case using GetProjectTemplate(“csClassLibrary.vstemplate”, “CSharp”) instead. For VB.NET it doesn’t work because the template is named classlibrary.vstemplate and not vbClasslibrary.vstemplate.

VS 11 Beta: again a painful release for add-ins (and other extensions)

A couple of days ago VS 11 Beta was released. I installed it yesterday and I am still shocked. A few days before, we could read in the Visual Studio Blog about the “New Developer Experience” of VS 11. First I thought is was a joke what I was reading, as if it was April 1 (in Spain that day for jokes is December 28 so I always forget April 1). Then I noticed that is was real. Some (new?) design team has taken full control of the user interface of Visual Studio and, well, you can read the post and the 750+ comments at the time of this writing. VS 11 Beta is almost gray, no colors, no borders, no gradients, toolwindow captions that are SHOUTING and with “:::::::::::::” characters that seem to come from the text-based screens of MS-DOS applications a couple of decades ago. Furthermore, you can choose between the “Light” and the “Dark” color themes, but no “VS 2010” color theme is provided.

Something is severely broken at the Visual Studio team in charge of the user interface since a couple of versions ago:

Furthermore, not only toolbar icons are affected. All the user interface is affected if you want to match the new themes. For example, if you use toolwindows that use icons for classes, interfaces, methods, etc.

What strikes me most is that nobody in the huge VS team (hundreds of developers) or in the VS management team (Scott Guthrie, Brian Harry, etc. or even S. Somasegar) has stopped this abomination before going Beta. This causes a lot of uncertainty to developers of extensions given the huge negative feedback and future direction:

  • How many betas will be? This has not been named “Beta 1”, but “Beta” (scary?)
  • How much time to final release (RTM)?
  • Will the VS 2010 theme color be back?
  • Will the Dark and Light theme colors be gone?
  • Will they coexist?
  • Should an extension that provides toolbars match the horrible Dark and Light themes, or be a color oasis in the gray desert?
  • Can the same custom pictures of an extension be used for both the Dark
    and Light themes, or two custom pictures must be provided?
  • How to provide custom pictures dynamically when the user changes the theme in the Options window?
  • Should I wait until next beta or release candidate?
  • Should I stop my current extension and get rich creating a new extension for VS 11 that provides commands, menus, toolbars and toolwindows that do the same that the ones of VS 11, but with color? 😉

My personal approach is that I will stick to VS 2010 during the next two years if VS 11 is released with the current color themes because actually they distract me a lot. About matching the new color themes in my MZ-Tools add-in, it won’t be my priority now. First I have to run hundreds of unit tests to check that they work and ensure that no bugs are introduced by VS 11, or get Microsoft to fix them. I already reported two of them here and here and more are coming in next posts.