-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Added tests for Out Variable Declarations in new expression contexts. #11987
Conversation
@dotnet/roslyn-compiler Please review. |
1 similar comment
@dotnet/roslyn-compiler Please review. |
@" | ||
public class X | ||
{ | ||
public static void Main() |
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.
Remove Main and commented out code below?
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.
I prefer to keep the commented code in the test source as placeholders for where we would wan't to test let
declarations. This is consistent with pattern matching tests.
LGTM. Thanks |
{ | ||
throw new System.InvalidOperationException(); | ||
} | ||
catch (System.Exception e) when (Dummy(TakeOutParam(e, out var x1), x1)) |
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.
Would it be interesting to capture x1 inside when - like Dummy(TakeOutParam(e, out var x1), ()=>x1)
?
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.
Another thing to try is to add await in the catch/finally.
Such try's need to be significantly rewritten and I am not sure that rewriter has ever seen locals declared in "when".
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.
These are good suggestions. In this particular case it is not likely to run into problems because exception variable is sharing the scope and we should be able to capture it. I added a work item into #11566 to make sure we have a good coverage for lambdas and await.
LGTM |
void Test1() | ||
{ | ||
try {} | ||
catch when (TakeOutParam(out var x1) && x1 > 0) |
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.
The tests as written are extremely difficult to review because of the large number of mixed positive and negative tests aggregated together. I cannot easily see both the test and the verification code on the same screen.
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.
I apologize for this inconvenience. At the moment, I am simply porting tests that we have for pattern variables. The base line comes from there too, modulo the source line content and the location on the line. I will take this feedback into consideration for non-ported tests, I heard the same feedback from other team members too.
No description provided.