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

Disable EnC for active methods with v7 syntax and for any method with v7 switch statement #13754

Merged
merged 10 commits into from
Sep 14, 2016

Conversation

jcouv
Copy link
Member

@jcouv jcouv commented Sep 13, 2016

Adding a syntactic check for any v7 syntax around active statement during EnC. This is modeled after a similar check in VB for "on error or resume" statement.
Also adding a semantic check for v7 switch statement (looking at governing type of the switch).

Addresses some of the work items in #12379

@gafter I think it would be good to re-open your PR (#13498) with public API for checking v7 switch statement. I copied that method to unblock myself for now.

Since tuples and ref shouldn't affect EnC slots, I'm thinking to allow them. Any thoughts?
If this change looks good, I will do a similar change for VB.

@dotnet/roslyn-compiler for review.

@gafter
Copy link
Member

gafter commented Sep 13, 2016

Re

@gafter I think it would be good to re-open your PR (#13498) with public API for checking v7 switch statement. I copied that method to unblock myself for now.

There would only be a single client for that API - this code. We prefer to see at least two and preferably three potential clients to add a public API.

@@ -268,6 +268,7 @@ override Microsoft.CodeAnalysis.CSharp.Syntax.WhenClauseSyntax.Accept<TResult>(M
static Microsoft.CodeAnalysis.CSharp.CSharpExtensions.GetDeclaredSymbol(this Microsoft.CodeAnalysis.SemanticModel semanticModel, Microsoft.CodeAnalysis.CSharp.Syntax.DeclarationPatternSyntax declarationSyntax, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.ILocalSymbol
static Microsoft.CodeAnalysis.CSharp.CSharpExtensions.GetDeclaredSymbol(this Microsoft.CodeAnalysis.SemanticModel semanticModel, Microsoft.CodeAnalysis.CSharp.Syntax.SingleVariableDesignationSyntax designationSyntax, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.ISymbol
static Microsoft.CodeAnalysis.CSharp.CSharpExtensions.GetForEachStatementInfo(this Microsoft.CodeAnalysis.SemanticModel semanticModel, Microsoft.CodeAnalysis.CSharp.Syntax.CommonForEachStatementSyntax forEachStatement) -> Microsoft.CodeAnalysis.CSharp.ForEachStatementInfo
static Microsoft.CodeAnalysis.CSharp.CSharpExtensions.IsValidV6SwitchGoverningType(this Microsoft.CodeAnalysis.ITypeSymbol type) -> bool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IsValidV6SwitchGoverningType [](start = 54, length = 28)

Please do not add this public API. Instead use the code from #13334 (comment)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That works too. Thanks

@gafter
Copy link
Member

gafter commented Sep 13, 2016

    {

Should this method be extended to handle new node kinds?


Refers to: src/Features/CSharp/Portable/EditAndContinue/StatementSyntaxComparer.cs:572 in 2b29f9a. [](commit_id = 2b29f9a7070131fb066bb9cac769ecb2e455f0f1, deletion_comment = False)

@AlekseyTs
Copy link
Contributor

CC @dotnet/roslyn-interactive

<comment>{Locked="ref"} "ref" is a C# keyword and should not be localized.</comment>
</data>
<data name="v7_switch" xml:space="preserve">
<value>v7 switch</value>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v7 [](start = 11, length = 2)

Should we find a friendlier description?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to "C# 7 enhanced switch statement".
When I tried EnC in VS, I was not able to observe the error message or the diagnostics, except for an error popup with a generic message (there was an error with this edit & continue) and squiggles on the span. I didn't see anything in the error or output panes.
Do you know if the error message appears somewhere else?

@AlekseyTs
Copy link
Contributor

        LocalDeclarationStatement,         // tied to parent

Should we add Deconstruction Declaration here?


Refers to: src/Features/CSharp/Portable/EditAndContinue/StatementSyntaxComparer.cs:192 in 2b29f9a. [](commit_id = 2b29f9a7070131fb066bb9cac769ecb2e455f0f1, deletion_comment = False)

switch (n.Kind())
{
case SyntaxKind.IsPatternExpression:
case SyntaxKind.DeconstructionDeclarationStatement:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DeconstructionDeclarationStatement [](start = 32, length = 34)

Should we also handle VariableComponentAssignmentSyntax?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. That scenario was already caught by the tuples check, but this will make it safer to incrementally enable scenarios.

@jcouv
Copy link
Member Author

jcouv commented Sep 13, 2016

@gafter @AlekseyTs Regarding StatementSyntaxComparer.cs (around line 192), I only made the smallest change here to unblock the scenarios.
So it's possible this code will need to be updated, but I don't yet know a scenario that needs it.

As far as I can tell, the reason the new d-foreach statement reached this (the unreachable default in method TryComputeWeightedDistance) is because it holds a block.
I'm planning to leave this comparer as-is for now and continue investigating if there are scenarios that need it.

@jcouv
Copy link
Member Author

jcouv commented Sep 13, 2016

I changed the PR to point to the preview5 branch.

@gafter
Copy link
Member

gafter commented Sep 13, 2016

:shipit:

@gafter gafter removed their assignment Sep 13, 2016
@jcouv jcouv added this to the 2.0 (Preview 5) milestone Sep 13, 2016
@jcouv
Copy link
Member Author

jcouv commented Sep 14, 2016

@dotnet-bot retest vsi please

@jcouv
Copy link
Member Author

jcouv commented Sep 14, 2016

@dotnet-bot test eta please

case SyntaxKind.SelectClause:
return ((SelectClauseSyntax)node).SelectKeyword.Span;

case SyntaxKind.GroupClause:
return ((GroupClauseSyntax)node).GroupKeyword.Span;

case SyntaxKind.ForEachComponentStatement:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we gain anything by grouping cases with the same body? Won't the compiler do that anyway? I'm guessing the old order was deliberate.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could not discern any order and found it confusing to have them spread out. I'll revert that refactoring.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Undid the refactoring.

@jaredpar
Copy link
Member

test eta please

1 similar comment
@jaredpar
Copy link
Member

test eta please

@jcouv
Copy link
Member Author

jcouv commented Sep 14, 2016

@dotnet/roslyn-compiler for a second review. This is fairly urgent as preview-5 ask mode closes later today. Thanks

@jcouv
Copy link
Member Author

jcouv commented Sep 14, 2016

@dotnet-bot test windows_vsi_p1_open_prtest please

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants