提交 abf3b965 编写于 作者: D David Poeschl 提交者: GitHub

Merge pull request #17884 from dpoeschl/BetterDumpsForFindTokenCoreInLinkedFiles

Capture better dumps when the contents of linked files don't match
......@@ -109,6 +109,7 @@
<Compile Include="FindUsages\IFindUsagesService.cs" />
<Compile Include="FindUsages\SimpleFindUsagesContext.cs" />
<Compile Include="Implementation\InlineRename\Dashboard\DashboardAutomationPeer.cs" />
<Compile Include="Implementation\Intellisense\QuickInfo\Providers\LinkedFileDiscrepancyException.cs" />
<Compile Include="Implementation\Structure\BlockTagState.cs" />
<Compile Include="Tags\ExportImageMonikerServiceAttribute.cs" />
<Compile Include="Implementation\NavigateTo\AbstractNavigateToItemDisplay.cs" />
......
......@@ -137,13 +137,15 @@ private async Task<SyntaxToken> FindTokenInLinkedDocument(SyntaxToken token, Doc
return linkedToken;
}
}
catch (Exception e)
catch (Exception thrownException)
{
// We are seeing linked files with different spans cause FindToken to crash.
// Capturing more information for https://devdiv.visualstudio.com/DevDiv/_workitems?id=209299
var originalText = await originalDocument.GetTextAsync().ConfigureAwait(false);
var linkedText = await linkedDocument.GetTextAsync().ConfigureAwait(false);
FatalError.Report(e);
var linkedFileException = new LinkedFileDiscrepancyException(thrownException, originalText.ToString(), linkedText.ToString());
FatalError.Report(linkedFileException);
}
return default(SyntaxToken);
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
namespace Microsoft.CodeAnalysis.Editor.Implementation.IntelliSense.QuickInfo
{
// Used to aid the investigation of https://devdiv.visualstudio.com/DevDiv/_workitems?id=209299
internal class LinkedFileDiscrepancyException : Exception
{
private readonly string _originalText;
private readonly string _linkedText;
public LinkedFileDiscrepancyException(Exception innerException, string originalText, string linkedText)
: base("The contents of linked files do not match.", innerException)
{
_originalText = originalText;
_linkedText = linkedText;
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册