提交 d527fd14 编写于 作者: D Dustin Campbell

Add more diagnostic information to better understand what's happening if...

Add more diagnostic information to better understand what's happening if TestAddAndRemoveViaTextChangeManyTimes fails
上级 3b53ae40
......@@ -213,6 +213,8 @@ internal void OnBeforeCodeElementCreated(SyntaxNode node)
if (!nodeKey.IsEmpty && _codeElementTable.TryGetValue(nodeKey, out codeElement))
{
var managedElement = ComAggregate.GetManagedObject<AbstractKeyedCodeElement>(codeElement);
Debug.Assert(managedElement != null, $"Could not get the underlying {nameof(AbstractKeyedCodeElement)} from {nameof(codeElement)} with {nameof(nodeKey)}: {nodeKey}");
if (managedElement?.IsValidNode() != true)
{
_codeElementTable.Remove(nodeKey);
......
......@@ -3845,7 +3845,20 @@ class C$$
Await TestElement(code,
Sub(state, codeClass)
For i = 1 To 100
Dim variable = codeClass.AddVariable("x", "System.Int32")
Dim initialDocument = state.FileCodeModelObject.GetDocument()
Dim variable As EnvDTE.CodeVariable
Try
variable = codeClass.AddVariable("x", "System.Int32")
Catch ex As InvalidOperationException
Assert.False(True,
$"Failed to add variable in loop iteration {i}!
Document text:
{initialDocument.GetTextAsync(CancellationToken.None).Result}")
Throw ex
End Try
' Now, delete the variable that we just added.
Dim startPoint = variable.StartPoint
......@@ -3856,7 +3869,7 @@ class C$$
document = document.WithText(text)
Dim result = state.VisualStudioWorkspace.TryApplyChanges(document.Project.Solution)
Assert.True(result)
Assert.True(result, "Attempt to apply changes to workspace failed.")
Next
End Sub)
End Function
......
......@@ -3154,7 +3154,20 @@ End Class
Await TestElement(code,
Sub(state, codeClass)
For i = 1 To 100
Dim variable = codeClass.AddVariable("x", "System.Int32")
Dim initialDocument = state.FileCodeModelObject.GetDocument()
Dim variable As EnvDTE.CodeVariable
Try
variable = codeClass.AddVariable("x", "System.Int32")
Catch ex As InvalidOperationException
Assert.False(True,
$"Failed to add variable in loop iteration {i}!
Document text:
{initialDocument.GetTextAsync(CancellationToken.None).Result}")
Throw ex
End Try
' Now, delete the variable that we just added.
Dim startPoint = variable.StartPoint
......@@ -3165,7 +3178,7 @@ End Class
document = document.WithText(text)
Dim result = state.VisualStudioWorkspace.TryApplyChanges(document.Project.Solution)
Assert.True(result)
Assert.True(result, "Attempt to apply changes to workspace failed.")
Next
End Sub)
End Function
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册