I am sort of reopening the bug that I reported in http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=295434 because it was closed without acknowledging the bug and providing a f¡x. The problem has nothing to do with scenarios or what to accomplish with DTE. It is just that the current implementation of the automation model VS 2005 and VS 2008 Beta2 has a bug. I will try to explain it much better and even provide where the code of MS is wrong:- An EnvDTE.ProjectItem of a project can be a folder or a file.- A folder contains folders or files- 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:1) ProjectItem.ProjectItems: this collection returns the children of the ProjectItem (be a folder or a file). It is used to navigate the hierarchy from top to bottom.2) ProjectItem.Collection: this collection returns the collection of items the ProjectItem (be a folder or a file) belongs to. In particular, the ProjectItem.Collection.Parent property returns the parent of the ProjectItem. It is used to navigate the hierarchy from bottom to top.It should be clear at this point that both collections are different and can not be the same.SQL Server Database projects implement the automation model in the Microsoft.VisualStudio.Package.Automation. namespace of the Microsoft.VisualStudio.TeamSystem.DataPackage.dll package. In this namespace, there are two classes of interest:1) OAProjectItem<T>This class implements correctly the Collection property as follows:public virtual ProjectItems get_Collection(){ HierarchyNode parent = this.node.Parent; if (parent is ProjectNode) { return ((OAProject) parent.GetAutomationObject()).ProjectItems; } if ((parent is FileNode) && (parent.FirstChild != null)) { return ((OAProjectItem<FileNode>) parent.GetAutomationObject()).ProjectItems; } if (!(parent is FolderNode)) { throw new NotImplementedException(); } return ((OAProjectItem<FolderNode>) parent.GetAutomationObject()).ProjectItems;}Notice that it uses "parent" because the Collection property refers to the parent, not to the children.2) OAFolderItem, which inherits from that class and overrides (incorrectly) the ProjectItems and Collection to return the same value!:public override ProjectItems Collection{ get { return new OAProjectItems(base.Project, base.Node); }} public override ProjectItems ProjectItems{ get { return this.Collection; }} Notice that this implementation is absolutely wrong!
Version
Please wait...