![]() |
||||
Introduction This article explains a bug in the EnvDTE.ProjectItem.Collection implementation of folders of SQL Server projects of the Visual Studio Team Edition for Database Professionals. More Information An EnvDTE.ProjectItem of a project can be a folder or a file. A folder can contain folders or files and a file can contain dependant files (such as .designer.cs or .resx). For that purpose, the EnvDTE.ProjectItem class of the automation model provides two properties:
Due to a bug in the implementation of ProjectItem.Collection of folders of SQL Server projects, the collection returned is the same than ProjectItem.ProjectItems. Steps to reproduce the problem:
Dim objProjectItemFolder As ProjectItem
Dim colParentCollection As ProjectItems
objProjectItemFolder = DTE.Solution.Projects.Item(1).ProjectItems.Item("Data Generation Plans")
colParentCollection = objProjectItemFolder.Collection
If colParentCollection.Count = 0 Then
MsgBox("We should be 3 folders, not 0")
End If
The macro returns 0 folders because ProjectItem.Collection is actually returning the children of the folder, which are zero. A consequence of this bug is that since ProjectItem.Collection.Parent returns itself, you can enter in an infinite recursion if you try to navigate the hierarchy of files and folders from bottom to top. Go back to the 'Resources for Visual Studio .NET extensibility' section for more articles like this
|
| Copyright © 2000-2013 MZTools Software. All Rights Reserved. Legal Notice |