提交 c7169d7f 编写于 作者: C CyrusNajmabadi

Merge branch 'fixupTests' into parserDiagnostics39

......@@ -131,12 +131,11 @@ public override void VisitForEachIterationVariables(BoundForEachStatement node)
if (deconstructionAssignment == null)
{
// regular, not deconstructing, foreach declares exactly one iteration variable
_variablesDeclared.Add(node.IterationVariables.Single());
_variablesDeclared.AddAll(node.IterationVariables);
}
else
{
// deconstruction foreach declares multiple variables
// Deconstruction foreach declares multiple variables.
((BoundTupleExpression)deconstructionAssignment.Left).VisitAllElements((x, self) => self.Visit(x), this);
}
}
......
......@@ -3756,6 +3756,27 @@ void M(ref sbyte p1, ref sbyte? p2)
Assert.Equal("this, p1, p2, local_0, non_nullable", GetSymbolNamesJoined(dataFlowAnalysisResults.WrittenOutside));
}
[WorkItem(17971, "https://github.com/dotnet/roslyn/issues/17971")]
[Fact]
public void VariablesDeclaredInBrokenForeach()
{
var dataFlowAnalysisResults = CompileAndAnalyzeDataFlowStatements(@"
struct S
{
static void Main(string[] args)
{
/*<bind>*/
Console.WriteLine(1);
foreach ()
Console.WriteLine(2);
/*</bind>*/
}
}
");
Assert.Equal(null, GetSymbolNamesJoined(dataFlowAnalysisResults.VariablesDeclared));
}
#endregion
#region "lambda"
......
......@@ -4066,7 +4066,7 @@ public class Test
// TODO...
}
[Fact]
[Fact(Skip = "https://github.com/dotnet/roslyn/issues/18800")]
public void CS0306ERR_BadTypeArgument01()
{
var source =
......
......@@ -1930,5 +1930,44 @@ private static FormattableString NewMethod()
await TestExtractMethodAsync(code, expected);
}
[WorkItem(17971, "https://github.com/dotnet/roslyn/issues/17971")]
[Fact, Trait(Traits.Feature, Traits.Features.ExtractMethod)]
public async Task BrokenForeachLoop()
{
var code = @"using System;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
[|Console.WriteLine(1);
foreach ()
Console.WriteLine(2);|]
}
}
}";
var expected = @"using System;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
NewMethod();
}
private static void NewMethod()
{
Console.WriteLine(1);
foreach ()
Console.WriteLine(2);
}
}
}";
await TestExtractMethodAsync(code, expected);
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册