Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes rude error reporting for lifted implicit value parameters #14276

Merged
merged 2 commits into from Oct 4, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -4188,6 +4188,138 @@ void F()
Diagnostic(RudeEditKind.NotCapturingVariable, "a1", "a1"));
}

[Fact, WorkItem(234448, "https://devdiv.visualstudio.com/DevDiv/_workitems?id=234448")]
public void Lambdas_Update_CeaseCapture_SetterValueParameter1()
{
var src1 = @"
using System;

class C
{
int D
{
get { return 0; }
set { new Action(() => { Console.Write(value); }).Invoke(); }
}
}
";
var src2 = @"
using System;

class C
{
int D
{
get { return 0; }
set { }
}
}
";
var edits = GetTopEdits(src1, src2);

edits.VerifySemanticDiagnostics(
Diagnostic(RudeEditKind.NotCapturingVariable, "set", "value"));
}

[Fact, WorkItem(234448, "https://devdiv.visualstudio.com/DevDiv/_workitems?id=234448")]
public void Lambdas_Update_CeaseCapture_IndexerSetterValueParameter1()
{
var src1 = @"
using System;

class C
{
int this[int a1, int a2]
{
get { return 0; }
set { new Action(() => { Console.Write(value); }).Invoke(); }
}
}
";
var src2 = @"
using System;

class C
{
int this[int a1, int a2]
{
get { return 0; }
set { }
}
}
";
var edits = GetTopEdits(src1, src2);

edits.VerifySemanticDiagnostics(
Diagnostic(RudeEditKind.NotCapturingVariable, "set", "value"));
}

[Fact, WorkItem(234448, "https://devdiv.visualstudio.com/DevDiv/_workitems?id=234448")]
public void Lambdas_Update_CeaseCapture_EventAdderValueParameter1()
{
var src1 = @"
using System;

class C
{
event Action D
{
add { new Action(() => { Console.Write(value); }).Invoke(); }
remove { }
}
}
";
var src2 = @"
using System;

class C
{
event Action D
{
add { }
remove { }
}
}
";
var edits = GetTopEdits(src1, src2);

edits.VerifySemanticDiagnostics(
Diagnostic(RudeEditKind.NotCapturingVariable, "add", "value"));
}

[Fact, WorkItem(234448, "https://devdiv.visualstudio.com/DevDiv/_workitems?id=234448")]
public void Lambdas_Update_CeaseCapture_EventRemoverValueParameter1()
{
var src1 = @"
using System;

class C
{
event Action D
{
add { }
remove { new Action(() => { Console.Write(value); }).Invoke(); }
}
}
";
var src2 = @"
using System;

class C
{
event Action D
{
add { }
remove { }
}
}
";
var edits = GetTopEdits(src1, src2);

edits.VerifySemanticDiagnostics(
Diagnostic(RudeEditKind.NotCapturingVariable, "remove", "value"));
}

[Fact]
public void Lambdas_Update_DeleteCapture1()
{
Expand Down Expand Up @@ -4304,6 +4436,105 @@ class C
Diagnostic(RudeEditKind.CapturingVariable, "a1", "a1"));
}

[Fact]
public void Lambdas_Update_Capturing_IndexerSetterValueParameter1()
{
var src1 = @"
using System;

class C
{
int this[int a1, int a2]
{
get { return 0; }
set { }
}
}
";
var src2 = @"
using System;

class C
{
int this[int a1, int a2]
{
get { return 0; }
set { new Action(() => { Console.Write(value); }).Invoke(); }
}
}
";
var edits = GetTopEdits(src1, src2);

edits.VerifySemanticDiagnostics(
Diagnostic(RudeEditKind.CapturingVariable, "set", "value"));
}

[Fact]
public void Lambdas_Update_Capturing_EventAdderValueParameter1()
{
var src1 = @"
using System;

class C
{
event Action D
{
add { }
remove { }
}
}
";
var src2 = @"
using System;

class C
{
event Action D
{
add { }
remove { new Action(() => { Console.Write(value); }).Invoke(); }
}
}
";
var edits = GetTopEdits(src1, src2);

edits.VerifySemanticDiagnostics(
Diagnostic(RudeEditKind.CapturingVariable, "remove", "value"));
}

[Fact]
public void Lambdas_Update_Capturing_EventRemoverValueParameter1()
{
var src1 = @"
using System;

class C
{
event Action D
{
add { }
remove { }
}
}
";
var src2 = @"
using System;

class C
{
event Action D
{
add { }
remove { new Action(() => { Console.Write(value); }).Invoke(); }
}
}
";
var edits = GetTopEdits(src1, src2);

edits.VerifySemanticDiagnostics(
Diagnostic(RudeEditKind.CapturingVariable, "remove", "value"));
}

[Fact]
public void Lambdas_Update_Capturing_MethodParameter1()
{
Expand Down