Get ProjectItems for Partial Class through CodeModel
I ha开发者_Go百科ve seen looking for a way to get the list of ProjectItems (files) for a known class, which generated from several partial classes. I use CodeModel to search for a class and accessing the ProjectItem to do stuff, which works fine for normal classes. But when it comes to partial classes, the ProjectItem property give one file but dont provide the other files which make this partial class. How can I access the other ProjectItems that make up the class , through partial classes
Looks like the original poster did find the answer to the question on the MSDN Forum. Linking it back here as well for reference.
Given an EnvDTE.CodeClass, cast it to EnvDTE80.CodeClass2 and use the CodeClass2.Parts property to get the other (class) code element, whose ProjectItem property gives you the file of the partial class.
Are you doing so recursively? If you just query EnvDTE.Project.ProjectItems you'll get only the project items at the first level, you'll have to EnvDTE.ProjectItem.ProjectItems as well.
精彩评论