Skip to content

Commit

Permalink
Fixed handling of empty solutions
Browse files Browse the repository at this point in the history
[release]
  • Loading branch information
madskristensen committed May 25, 2022
1 parent c71e69b commit 43b9c5b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public static async Task<IEnumerable<PhysicalFile>> FromFilesAsync(params string

/// <summary>
/// Known attributes of a <see cref="PhysicalFile"/>.
/// This can be used to set an attribute of a file using the <see cref="PhysicalFile.TrySetAttributeAsync(PhysicalFileAttribute, string)"/> method.
/// This can be used to set an attribute of a file using the <see cref="PhysicalFile.TrySetAttributeAsync(PhysicalFileAttribute, object)"/> method.
/// </summary>
public enum PhysicalFileAttribute
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Automation.Peers;
using Microsoft.Internal.VisualStudio.PlatformUI;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Shell;
Expand Down Expand Up @@ -146,16 +147,24 @@ public void GetItemInfo(out IVsHierarchy hierarchy, out uint itemId, out IVsHier

SolutionItemType type = GetSolutionItemType(item.HierarchyIdentity);

return type switch
try
{
SolutionItemType.Solution => new Solution(item, type),
SolutionItemType.Project => new Project(item, type),
SolutionItemType.PhysicalFile => new PhysicalFile(item, type),
SolutionItemType.PhysicalFolder => new PhysicalFolder(item, type),
SolutionItemType.VirtualFolder => new VirtualFolder(item, type),
SolutionItemType.SolutionFolder => new SolutionFolder(item, type),
_ => new SolutionItem(item, type)
};
return type switch
{
SolutionItemType.Solution => new Solution(item, type),
SolutionItemType.Project => new Project(item, type),
SolutionItemType.PhysicalFile => new PhysicalFile(item, type),
SolutionItemType.PhysicalFolder => new PhysicalFolder(item, type),
SolutionItemType.VirtualFolder => new VirtualFolder(item, type),
SolutionItemType.SolutionFolder => new SolutionFolder(item, type),
_ => new SolutionItem(item, type)
};
}
catch
{
// If we failed to create the item, we should return null.
return null;
}
}

private static SolutionItemType GetSolutionItemType(IVsHierarchyItemIdentity identity)
Expand Down

0 comments on commit 43b9c5b

Please sign in to comment.