Skip to content

Commit

Permalink
Disable EnC for active methods with v7 syntax and for any method with…
Browse files Browse the repository at this point in the history
… v7 switch statement (#13754)
  • Loading branch information
jcouv authored Sep 14, 2016
1 parent c606d75 commit 24cafcb
Show file tree
Hide file tree
Showing 9 changed files with 805 additions and 10 deletions.
403 changes: 403 additions & 0 deletions src/EditorFeatures/CSharpTest/EditAndContinue/ActiveStatementTests.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -6455,11 +6455,11 @@ static IEnumerable<int> F()

CSharpEditAndContinueTestHelpers.Instance40.VerifySemantics(
edits,
ActiveStatementsDescription.Empty,
ActiveStatementsDescription.Empty,
null,
null,
null,
null,
new[]
new[]
{
Diagnostic(RudeEditKind.UpdatingStateMachineMethodMissingAttribute, "static IEnumerable<int> F()", "System.Runtime.CompilerServices.IteratorStateMachineAttribute")
});
Expand Down Expand Up @@ -6501,6 +6501,130 @@ static IEnumerable<int> F()
null);
}

[Fact]
public void CSharp7SwitchStatement()
{
var src1 = @"
class C
{
static void F(object o)
{
switch (o)
{
case int i:
break;
}
System.Console.WriteLine(1);
}
}
";
var src2 = @"
class C
{
static void F(object o)
{
switch (o)
{
case int i:
break;
}
System.Console.WriteLine(2);
}
}
";
var edits = GetTopEdits(src1, src2);

CSharpEditAndContinueTestHelpers.Instance.VerifySemantics(
edits,
ActiveStatementsDescription.Empty,
expectedDiagnostics: new[]
{
Diagnostic(RudeEditKind.UpdateAroundActiveStatement, null, CSharpFeaturesResources.v7_switch)
});
}

[Fact]
public void AddCSharp7SwitchStatement()
{
var src1 = @"
class C
{
static void F(object o)
{
}
}
";
var src2 = @"
class C
{
static void F(object o)
{
switch (o)
{
case string s:
break;
}
switch (o)
{
case int i:
break;
}
}
}
";
var edits = GetTopEdits(src1, src2);

CSharpEditAndContinueTestHelpers.Instance.VerifySemantics(
edits,
ActiveStatementsDescription.Empty,
additionalOldSources: null,
additionalNewSources: null,
expectedSemanticEdits: null,
expectedDiagnostics: new[]
{
Diagnostic(RudeEditKind.UpdateAroundActiveStatement, "switch (o)", CSharpFeaturesResources.v7_switch)
});
}

[Fact]
public void AddCSharp7SwitchStatement2()
{
var src1 = @"
class C
{
static void F(object o)
{
switch (o)
{
case 1:
case """":
break;
}
}
}
";
var src2 = @"
class C
{
static void F(object o)
{
}
}
";
var edits = GetTopEdits(src1, src2);

CSharpEditAndContinueTestHelpers.Instance.VerifySemantics(
edits,
ActiveStatementsDescription.Empty,
additionalOldSources: null,
additionalNewSources: null,
expectedSemanticEdits: null,
expectedDiagnostics: new[]
{
Diagnostic(RudeEditKind.UpdateAroundActiveStatement, null, CSharpFeaturesResources.v7_switch)
});
}

#endregion

#region Await
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,10 @@ internal void VerifyLineEdits(
internal void VerifySemantics(
EditScript<SyntaxNode> editScript,
ActiveStatementsDescription activeStatements,
IEnumerable<string> additionalOldSources,
IEnumerable<string> additionalNewSources,
SemanticEditDescription[] expectedSemanticEdits,
RudeEditDiagnosticDescription[] expectedDiagnostics)
IEnumerable<string> additionalOldSources = null,
IEnumerable<string> additionalNewSources = null,
SemanticEditDescription[] expectedSemanticEdits = null,
RudeEditDiagnosticDescription[] expectedDiagnostics = null)
{
var editMap = Analyzer.BuildEditMap(editScript);

Expand Down
63 changes: 63 additions & 0 deletions src/Features/CSharp/Portable/CSharpFeaturesResources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions src/Features/CSharp/Portable/CSharpFeaturesResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,30 @@
<value>into clause</value>
<comment>{Locked="into"} "into" is a C# keyword and should not be localized.</comment>
</data>
<data name="is_pattern" xml:space="preserve">
<value>is pattern</value>
<comment>{Locked="is"} "is" is a C# keyword and should not be localized.</comment>
</data>
<data name="deconstruction" xml:space="preserve">
<value>deconstruction</value>
</data>
<data name="tuple" xml:space="preserve">
<value>tuple</value>
</data>
<data name="local_function" xml:space="preserve">
<value>local function</value>
</data>
<data name="out_var" xml:space="preserve">
<value>out variable</value>
<comment>{Locked="out"} "out" is a C# keyword and should not be localized.</comment>
</data>
<data name="ref_local_or_expression" xml:space="preserve">
<value>ref local or expression</value>
<comment>{Locked="ref"} "ref" is a C# keyword and should not be localized.</comment>
</data>
<data name="v7_switch" xml:space="preserve">
<value>C# 7 enhanced switch statement</value>
</data>
<data name="global_statement" xml:space="preserve">
<value>global statement</value>
<comment>{Locked="global"} "global" is a C# keyword and should not be localized.</comment>
Expand Down
Loading

0 comments on commit 24cafcb

Please sign in to comment.