提交 f2c5af56 编写于 作者: J Jason Malinowski

Fix null reference exception thrown if previewing a new file added

In the preview changes dialog we'd call this method to try to get an
icon for it; if the file was a new file we'd throw exceptions which
were swallowed by the shell.
上级 d0bb9f0e
......@@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#nullable disable
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
......@@ -12,6 +10,7 @@
using Microsoft.VisualStudio.Imaging.Interop;
using Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem;
using Microsoft.VisualStudio.Shell.Interop;
using Roslyn.Utilities;
namespace Microsoft.VisualStudio.LanguageServices.Implementation.Extensions
{
......@@ -73,7 +72,7 @@ public static bool TryGetImageListAndIndex(this VisualStudioWorkspaceImpl worksp
{
var hierarchy = workspace.GetHierarchy(id.ProjectId);
var document = workspace.CurrentSolution.GetDocument(id);
if (hierarchy != null)
if (hierarchy != null && !RoslynString.IsNullOrEmpty(document?.FilePath))
{
var itemId = hierarchy.TryGetItemId(document.FilePath);
return TryGetImageListAndIndex(hierarchy, imageService, itemId, out imageList, out index);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册