提交 8c6297de 编写于 作者: I Ivan Basov 提交者: GitHub

Flaky test in...

Flaky test in Roslyn.VisualStudio.IntegrationTests.VisualBasic.BasicExpressionEvaluator.StateMachineTypeParameters (#19966)
上级 71f01cbb
......@@ -135,6 +135,7 @@ End Function
End Module
");
VisualStudio.Debugger.Go(waitForBreakMode: true);
VisualStudio.LocalsWindow.Verify.CheckEntry("Type variables", "", "");
VisualStudio.LocalsWindow.Verify.CheckEntry( new string[] { "Type variables", "T" }, "String", "String");
// It is better to use the Immediate Window but DTE does not provide an access to it.
......
......@@ -23,50 +23,60 @@ public int GetCount()
return 0;
}
public Common.Expression GetEntry(string entryName)
{
return new Common.Expression(GetEntryInternal(entryName));
}
public Common.Expression GetEntry(params string[] entryNames)
{
return new Common.Expression(GetEntryInternal(entryNames));
}
var dte = ((DTE2)GetDTE());
if (dte.Debugger.CurrentStackFrame == null) // Ensure that debugger is running
{
throw new Exception($"Could not find locals. Debugger is not running.");
}
private EnvDTE.Expression GetEntryInternal(params string[] entryNames)
{
var entry = GetEntryInternal(entryNames[0]);
for (int i = 1; i < entryNames.Length; i++)
EnvDTE.Expressions expressions = dte.Debugger.CurrentStackFrame.Locals;
EnvDTE.Expression entry = null;
int i = 0;
while (i < entryNames.Length && TryGetEntryInternal(entryNames[i], expressions, out entry))
{
i++;
expressions = entry.DataMembers;
}
if ((i == entryNames.Length) && (entry != null))
{
entry = GetEntryInternal(entryNames[i], entry.DataMembers);
return new Common.Expression(entry);
}
return entry;
string localHierarchicalName = string.Join("->", entryNames);
string allLocalsString = string.Join("\n", GetAllLocals(dte.Debugger.CurrentStackFrame.Locals));
throw new Exception($"\nCould not find the local named {localHierarchicalName}.\nAll available locals are: \n{allLocalsString}");
}
private EnvDTE.Expression GetEntryInternal(string entryName, EnvDTE.Expressions expressions)
private bool TryGetEntryInternal(string entryName, EnvDTE.Expressions expressions, out EnvDTE.Expression expression)
{
var expressionCollection = expressions.Cast<EnvDTE.Expression>();
var expressionMatched = expressionCollection.FirstOrDefault(e => e.Name == entryName);
if (expressionMatched != null)
expression = expressions.Cast<EnvDTE.Expression>().FirstOrDefault(e => e.Name == entryName);
if (expression != null)
{
return expressionMatched;
return true;
}
string nestedExpressionNamesString = string.Join(",", expressionCollection.Select(e => e.Name));
throw new Exception($"Could not find the local named {entryName}. Available locals are {nestedExpressionNamesString}.");
return false;
}
private EnvDTE.Expression GetEntryInternal(string entryName)
private static IEnumerable<string> GetAllLocals(EnvDTE.Expressions expressions)
{
var dte = ((DTE2)GetDTE());
if (dte.Debugger.CurrentStackFrame != null) // Ensure that debugger is running
foreach (var expression in expressions.Cast<EnvDTE.Expression>())
{
EnvDTE.Expressions locals = dte.Debugger.CurrentStackFrame.Locals;
return GetEntryInternal(entryName, locals);
string expressionName = expression.Name;
yield return expressionName;
var nestedExpressions = expression.DataMembers;
if (nestedExpressions != null)
{
foreach (var nestedLocal in GetAllLocals(nestedExpressions))
{
yield return string.Format("{0}->{1}", expressionName, nestedLocal);
}
}
}
throw new Exception($"Could not find locals. Debugger is not running.");
}
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册