void TraverseProject(Project project)
        {
            if (project == null)
            {
                return;
            }

            if (BeforeTraverseProject(project))
            {
                ProjectItems projectItems = project.ProjectItems;
                if (projectItems != null)
                {
                    //var codeModel = project.CodeModel;
                    //var codeLanguage = codeModel.Language;

                    var items = projectItems.GetEnumerator();
                    while (items.MoveNext())
                    {
                        var item = items.Current as ProjectItem;
                        TraverseProjectItem(item);
                    }
                }
                AfterTraverseProject(project);
            }
        }
        private static void RecursiveFindFilesInProject(ProjectItems items, ref Queue <ProjectItem> projectFiles)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            var e = items.GetEnumerator();

            while (e.MoveNext())
            {
                var item = e.Current;
                if (item == null)
                {
                    continue;
                }
                var projectItem = item as ProjectItem;
                if (projectItem == null)
                {
                    continue;
                }

                Guid projectItemKind = new Guid(projectItem.Kind);
                if (projectItemKind == VSConstants.GUID_ItemType_VirtualFolder ||
                    projectItemKind == VSConstants.GUID_ItemType_PhysicalFolder)
                {
                    RecursiveFindFilesInProject(projectItem.ProjectItems, ref projectFiles);
                }
                else if (projectItemKind == VSConstants.GUID_ItemType_PhysicalFile)
                {
                    projectFiles.Enqueue(projectItem);
                }
                else
                {
                    Output.Instance.WriteLine("Unexpected Error: Unknown projectItem {0} of Kind {1}", projectItem.Name, projectItem.Kind);
                }
            }
        }
Example #3
0
 private IEnumerable<ProjectItem> Enumerate(ProjectItems items)
 {
     IEnumerator enumerator = items.GetEnumerator();
     while (enumerator.MoveNext())
     {
         ProjectItem current = (ProjectItem)enumerator.Current;
         yield return current;
         foreach (ProjectItem iteratorVariable1 in this.Enumerate(current.ProjectItems))
         {
             yield return iteratorVariable1;
         }
     }
 }
Example #4
0
        private IEnumerable <ProjectItem> Enumerate(ProjectItems items)
        {
            var enumerator = items.GetEnumerator();

            while (enumerator.MoveNext())
            {
                var current = (ProjectItem)enumerator.Current;
                yield return(current);

                foreach (var iteratorVariable1 in Enumerate(current.ProjectItems))
                {
                    yield return(iteratorVariable1);
                }
            }
        }
        private void InitTestprojectStructure()
        {
            //mock exist file *.cs with name equal to name method
            mainMethodFileProjectItem = Substitute.For <ProjectItem>();
            mainMethodFileProjectItem.Name.Returns("TestMethodName.cs");

            methodWrapperFileProjectItem = Substitute.For <ProjectItem>();
            methodWrapperFileProjectItem.Name.Returns("TestMethodNameWrapper.cs");

            methodTestsFileProjectItem = Substitute.For <ProjectItem>();
            methodTestsFileProjectItem.Name.Returns("TestMethodNameTests.cs");

            List <ProjectItem> methodFiles = new List <ProjectItem>()
            {
                mainMethodFileProjectItem, methodWrapperFileProjectItem, methodTestsFileProjectItem
            };

            ProjectItems specialMethodFolderProjectItems = Substitute.For <ProjectItems>();

            specialMethodFolderProjectItems.GetEnumerator().Returns(methodFiles.GetEnumerator());

            specialMethodFolderProjectItems.Item("TestMethodName.cs").Returns(mainMethodFileProjectItem);
            specialMethodFolderProjectItems.Item("TestMethodNameWrapper.cs").Returns(methodWrapperFileProjectItem);
            specialMethodFolderProjectItems.Item("TestMethodNameTests.cs").Returns(methodTestsFileProjectItem);

            //mock folder with method
            specialMethodFolder = Substitute.For <ProjectItem>();
            specialMethodFolder.Name.Returns("TestMethodName");
            specialMethodFolder.ProjectItems.Returns(specialMethodFolderProjectItems);

            List <ProjectItem> methodFolders = new List <ProjectItem>()
            {
                specialMethodFolder
            };

            ProjectItems serverMethodsFolderItems = Substitute.For <ProjectItems>();

            serverMethodsFolderItems.GetEnumerator().Returns(methodFolders.GetEnumerator());
            serverMethodsFolderItems.Item("TestMethodName").Returns(specialMethodFolder);

            //mock main methods folder "ServerMethods"
            ProjectItem serverMethodsFolderProjectItem = Substitute.For <ProjectItem>();

            serverMethodsFolderProjectItem.Name.Returns("ServerMethods");
            serverMethodsFolderProjectItem.ProjectItems.Returns(serverMethodsFolderItems);

            List <ProjectItem> projectFolders = new List <ProjectItem>()
            {
                serverMethodsFolderProjectItem
            };

            ProjectItems projectItems = Substitute.For <ProjectItems>();

            projectItems.Item("ServerMethods").Returns(serverMethodsFolderProjectItem);
            projectItems.GetEnumerator().Returns(projectFolders.GetEnumerator());

            Project project = Substitute.For <Project>();

            project.UniqueName.Returns("ProjectName");
            project.ProjectItems.Returns(projectItems);

            DTE2 dte2 = Substitute.For <DTE2>();

            dte2.ActiveSolutionProjects.Returns(new Project[] { project });
            this.serviceProvider.GetService(Arg.Any <Type>()).Returns(dte2);
        }
        private void GetFilesRecursive(Project project, AsyncTask.Context context, List <string> solution_files, List <string> projects)
        {
            ///mariotodo
            if (context.Cancelled)
            {
                return;
            }
            string       project_kind  = project.Kind.ToLower();
            ProjectItems project_items = project.ProjectItems;

            if (project_kind == "{66A26720-8FB5-11D2-AA7E-00C04F688DDE}".ToLower())
            {
                if (project_items == null)
                {
                    return;
                }
                {
                    IEnumerator enumerator = project_items.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        Project sub_project = ((ProjectItem)enumerator.Current).SubProject;
                        if (sub_project != null)
                        {
                            this.GetFilesRecursive(sub_project, context, solution_files, projects);
                        }
                        if (context.Cancelled)
                        {
                            break;
                        }
                    }
                    return;
                }
            }
            try
            {
                if (project_kind != "{66A2671D-8FB5-11D2-AA7E-00C04F688DDE}".ToLower())
                {
                    string project_full_name = project.FullName;
                    if (!string.IsNullOrEmpty(project_full_name))
                    {
                        projects.Add(project_full_name);
                    }
                }
            }
            catch (Exception arg_B9_0)
            {
                Utils.LogExceptionQuiet(arg_B9_0);
            }
            try
            {
                if (project_items != null)
                {
                    foreach (ProjectItem project_item in project_items)
                    {
                        this.GetProjectFilesRecursive(project_item, context, solution_files, projects);
                        if (context.Cancelled)
                        {
                            break;
                        }
                    }
                }
            }
            catch (Exception arg_10E_0)
            {
                Utils.LogExceptionQuiet(arg_10E_0);
            }
        }