|
3 | 3 | using System.Diagnostics; |
4 | 4 | using System.Linq; |
5 | 5 | using System.Threading.Tasks; |
| 6 | +using System.Windows.Automation.Peers; |
6 | 7 | using Microsoft.Internal.VisualStudio.PlatformUI; |
7 | 8 | using Microsoft.VisualStudio; |
8 | 9 | using Microsoft.VisualStudio.Shell; |
@@ -146,16 +147,24 @@ public void GetItemInfo(out IVsHierarchy hierarchy, out uint itemId, out IVsHier |
146 | 147 |
|
147 | 148 | SolutionItemType type = GetSolutionItemType(item.HierarchyIdentity); |
148 | 149 |
|
149 | | - return type switch |
| 150 | + try |
150 | 151 | { |
151 | | - SolutionItemType.Solution => new Solution(item, type), |
152 | | - SolutionItemType.Project => new Project(item, type), |
153 | | - SolutionItemType.PhysicalFile => new PhysicalFile(item, type), |
154 | | - SolutionItemType.PhysicalFolder => new PhysicalFolder(item, type), |
155 | | - SolutionItemType.VirtualFolder => new VirtualFolder(item, type), |
156 | | - SolutionItemType.SolutionFolder => new SolutionFolder(item, type), |
157 | | - _ => new SolutionItem(item, type) |
158 | | - }; |
| 152 | + return type switch |
| 153 | + { |
| 154 | + SolutionItemType.Solution => new Solution(item, type), |
| 155 | + SolutionItemType.Project => new Project(item, type), |
| 156 | + SolutionItemType.PhysicalFile => new PhysicalFile(item, type), |
| 157 | + SolutionItemType.PhysicalFolder => new PhysicalFolder(item, type), |
| 158 | + SolutionItemType.VirtualFolder => new VirtualFolder(item, type), |
| 159 | + SolutionItemType.SolutionFolder => new SolutionFolder(item, type), |
| 160 | + _ => new SolutionItem(item, type) |
| 161 | + }; |
| 162 | + } |
| 163 | + catch |
| 164 | + { |
| 165 | + // If we failed to create the item, we should return null. |
| 166 | + return null; |
| 167 | + } |
159 | 168 | } |
160 | 169 |
|
161 | 170 | private static SolutionItemType GetSolutionItemType(IVsHierarchyItemIdentity identity) |
|
0 commit comments