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
Add c# 12 test project #3734
Add c# 12 test project #3734
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -218,33 +218,10 @@ private void Method(object o) | |
Action<int> h = delegate (int x, __arglist) { Console.WriteLine(); }; | ||
} | ||
}"; | ||
var expected = new[] | ||
{ | ||
Diagnostic().WithLocation(8, 20), | ||
Diagnostic().WithLocation(9, 20), | ||
Diagnostic().WithLocation(10, 25), | ||
Diagnostic().WithLocation(11, 30), | ||
Diagnostic().WithLocation(12, 30), | ||
Diagnostic(CS1065).WithLocation(12, 53), | ||
Diagnostic().WithLocation(13, 30), | ||
Diagnostic(CS7014).WithLocation(13, 47), | ||
Diagnostic().WithLocation(14, 30), | ||
Diagnostic(CS1670).WithLocation(14, 47), | ||
Diagnostic().WithLocation(15, 25), | ||
Diagnostic(CS1669).WithLocation(15, 42), | ||
}; | ||
|
||
var expectedAfterFix = new[] | ||
{ | ||
Diagnostic().WithLocation(12, 30), | ||
Diagnostic(CS1065).WithLocation(12, 53), | ||
Diagnostic().WithLocation(13, 30), | ||
Diagnostic(CS7014).WithLocation(13, 47), | ||
Diagnostic().WithLocation(14, 30), | ||
Diagnostic(CS1670).WithLocation(14, 47), | ||
Diagnostic().WithLocation(15, 25), | ||
Diagnostic(CS1669).WithLocation(15, 42), | ||
}; | ||
var expected = this.GetExpectedResultCodeFixSpecialCases(); | ||
|
||
var expectedAfterFix = this.GetExpectedResultAfterFixCodeFixSpecialCases(); | ||
|
||
var test = new CSharpTest | ||
{ | ||
|
@@ -828,11 +805,7 @@ public class TestClass | |
} | ||
"; | ||
|
||
DiagnosticResult[] expected = | ||
{ | ||
Diagnostic().WithSpan(4, 50, 4, 58), | ||
DiagnosticResult.CompilerError("CS1660").WithMessage("Cannot convert anonymous method to type 'EventHandler[]' because it is not a delegate type").WithSpan(4, 50, 4, 62), | ||
}; | ||
var expected = this.GetExpectedResultVerifyInvalidCodeConstructions(); | ||
|
||
var test = new CSharpTest | ||
{ | ||
|
@@ -1010,5 +983,48 @@ public void Test() | |
|
||
await VerifyCSharpFixAsync(testCode, DiagnosticResult.EmptyDiagnosticResults, fixedCode, CancellationToken.None).ConfigureAwait(false); | ||
} | ||
|
||
protected virtual DiagnosticResult[] GetExpectedResultCodeFixSpecialCases() | ||
{ | ||
return new[] | ||
{ | ||
Diagnostic().WithLocation(8, 20), | ||
Diagnostic().WithLocation(9, 20), | ||
Diagnostic().WithLocation(10, 25), | ||
Diagnostic().WithLocation(11, 30), | ||
Diagnostic().WithLocation(12, 30), | ||
Diagnostic(CS1065).WithLocation(12, 53), | ||
Diagnostic().WithLocation(13, 30), | ||
Diagnostic(CS7014).WithLocation(13, 47), | ||
Diagnostic().WithLocation(14, 30), | ||
Diagnostic(CS1670).WithLocation(14, 47), | ||
Diagnostic().WithLocation(15, 25), | ||
Diagnostic(CS1669).WithLocation(15, 42), | ||
}; | ||
} | ||
|
||
protected virtual DiagnosticResult[] GetExpectedResultAfterFixCodeFixSpecialCases() | ||
{ | ||
return new[] | ||
{ | ||
Diagnostic().WithLocation(12, 30), | ||
Diagnostic(CS1065).WithLocation(12, 53), | ||
Diagnostic().WithLocation(13, 30), | ||
Diagnostic(CS7014).WithLocation(13, 47), | ||
Diagnostic().WithLocation(14, 30), | ||
Diagnostic(CS1670).WithLocation(14, 47), | ||
Diagnostic().WithLocation(15, 25), | ||
Diagnostic(CS1669).WithLocation(15, 42), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Same applies for |
||
}; | ||
} | ||
|
||
protected virtual DiagnosticResult[] GetExpectedResultVerifyInvalidCodeConstructions() | ||
{ | ||
return new[] | ||
{ | ||
Diagnostic().WithSpan(4, 50, 4, 58), | ||
DiagnosticResult.CompilerError("CS1660").WithMessage("Cannot convert anonymous method to type 'EventHandler[]' because it is not a delegate type").WithSpan(4, 50, 4, 62), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Same here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I noticed that the only thing differing was the span, so I simplified to only check the start location. Ok simplification? |
||
}; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Let's move all the
Diagnostic()
items back into the test itself, and only have theCS*
diagnostics in this virtual method.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. I thought of that too briefly, but ended up not doing it. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added them as annotations in the tested code instead. This removed the need for two methods before and after the fix. Ok simplification?