Adjust OperationTreeVerifier and TestOperationVisitor to verify new constraints.

上级 4b85e651
......@@ -523,6 +523,7 @@ public override void VisitForEachLoop(IForEachLoopOperation operation)
LogString(nameof(IForEachLoopOperation));
LogLoopStatementHeader(operation);
Assert.NotNull(operation.LoopControlVariable);
Visit(operation.LoopControlVariable, "LoopControlVariable");
Visit(operation.Collection, "Collection");
Visit(operation.Body, "Body");
......
......@@ -272,22 +272,7 @@ public override void VisitForEachLoop(IForEachLoopOperation operation)
Assert.Equal(LoopKind.ForEach, operation.LoopKind);
VisitLocals(operation);
IEnumerable<IOperation> children;
// operation.LoopControlVariable shouldn't be null.
// The following conditional logic should be removed once https://github.com/dotnet/roslyn/issues/23820
// is fixed.
if (operation.LoopControlVariable == null)
{
Assert.Equal(LanguageNames.CSharp, operation.Language);
children = new[] { operation.Collection, operation.Body };
}
else
{
children = new[] { operation.Collection, operation.LoopControlVariable, operation.Body };
}
children = children.Concat(operation.NextVariables);
IEnumerable<IOperation> children = new[] { operation.Collection, operation.LoopControlVariable, operation.Body }.Concat(operation.NextVariables);
AssertEx.Equal(children, operation.Children);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册