Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issues with AllProjects not working with solution folders #66

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 60 additions & 4 deletions Src/BridgeVs.AsyncVsPackage/BridgeVsExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Diagnostics;
using System.IO;
using System.Linq;
using BridgeVs.VsPackage.Helper;
using BridgeVs.VsPackage.Helper.Command;
using BridgeVs.VsPackage.Helper.Configuration;
using EnvDTE;
using Microsoft.VisualStudio;
using Project = EnvDTE.Project;

namespace BridgeVs.VisualStudio.AsyncExtension
Expand All @@ -55,17 +57,71 @@ private IEnumerable<Project> AllProjects
{
get
{
List<Project> projects = new List<Project>();//AllProjects.ToList();
foreach (Project proj in _application.Solution.Projects)
{
_findProjects(projects, proj);
}
Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();
Projects projects = _application.Solution.Projects;
if (projects == null)
if (projects.Count == 0)
return Enumerable.Empty<Project>();

return from project in projects.Cast<Project>()
where IsSupported(project.UniqueName)
where (IsSupported(project.UniqueName) || IsSupported(project.FullName))
select project;
}
}


IEnumerable<Project> _findProjects(IList<Project> projects, Object projectItem)
{
var proj = projectItem as Project;
var projItm = projectItem as ProjectItem;
if (proj != null)
{
Debug.WriteLine($"Project => {proj.Name} {proj.Kind}");
}

if (projItm != null)
{
Debug.WriteLine($"ProjectItem => {projItm.Name} {projItm.Kind}");
}
if (proj == null && projItm != null)
{
proj = projItm.SubProject;
}
if (proj != null)
{
Debug.WriteLine($"Resolved Project => {proj.Name} {proj.Kind}");
}
if (proj != null && (proj.Kind == VSConstants.UICONTEXT.CSharpProject_string
|| proj.Kind == VSConstants.UICONTEXT.VBProject_string
|| IsSupported(proj.UniqueName)))
{
projects.Add(proj);
return projects;
}
else if (proj != null && (proj.Kind == VSConstants.ItemTypeGuid.VirtualFolder_string
|| proj.Kind == "{66A26720-8FB5-11D2-AA7E-00C04F688DDE}")
)
{
foreach (ProjectItem itm in proj.ProjectItems)
{
_findProjects(projects, itm);
}

return projects;
}
else if (proj == null && projItm != null && projItm.ProjectItems != null)
{
foreach (ProjectItem pi in projItm.ProjectItems)
{
_findProjects(projects, pi);
}
}

return projects;
}

private string SolutionName => Path.GetFileNameWithoutExtension(_application.Solution.FileName);

public void Execute(CommandAction action)
Expand Down