提交 a80650d8 编写于 作者: A Adam Speight 提交者: Julien Couvreur

Add additional information about the found and expected character, when there...

Add additional information about the found and expected character, when there is an unexpected difference. (#25296)
上级 9038e9fd
......@@ -42,7 +42,8 @@ internal static void VerifySource(this SyntaxTree tree, IEnumerable<TextChangeRa
var span = node.FullSpan;
var textSpanOpt = span.Intersection(fullSpan);
int index;
char found = default;
char expected = default;
if (textSpanOpt == null)
{
index = 0;
......@@ -52,6 +53,11 @@ internal static void VerifySource(this SyntaxTree tree, IEnumerable<TextChangeRa
var fromText = text.ToString(textSpanOpt.Value);
var fromNode = node.ToFullString();
index = FindFirstDifference(fromText, fromNode);
if (index >= 0)
{
found = fromNode[index];
expected = fromText[index];
}
}
if (index >= 0)
......@@ -63,11 +69,7 @@ internal static void VerifySource(this SyntaxTree tree, IEnumerable<TextChangeRa
var position = text.Lines.GetLinePosition(index);
var line = text.Lines[position.Line];
var allText = text.ToString(); // Entire document as string to allow inspecting the text in the debugger.
message = string.Format("Unexpected difference at offset {0}: Line {1}, Column {2} \"{3}\"",
index,
position.Line + 1,
position.Character + 1,
line.ToString());
message = $"Unexpected difference at offset {index}: Line {position.Line + 1}, Column {position.Character + 1} \"{line.ToString()}\" (Found: [{found}] Expected: [{expected}])";
}
else
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册