Skip to content

Add warning message if semantics may change due to inline temporary variable refactoring#43959

Merged
allisonchou merged 7 commits intodotnet:masterfrom
allisonchou:InlineInvalidBug
May 6, 2020
Merged

Add warning message if semantics may change due to inline temporary variable refactoring#43959
allisonchou merged 7 commits intodotnet:masterfrom
allisonchou:InlineInvalidBug

Conversation

@allisonchou
Copy link
Contributor

Fixes #42835 by adding a warning message in certain refactoring scenarios that may cause semantic changes.

Also fixes #43666. (I was unable to repro the issue on subsequent attempts, but I added some checks where the initial exception occurred in order to hopefully avoid the issue triggering again.)

@allisonchou allisonchou requested a review from CyrusNajmabadi May 4, 2020 19:35
@allisonchou allisonchou requested a review from a team as a code owner May 4, 2020 19:35
@CyrusNajmabadi
Copy link
Contributor

can yuo show some screenshots of what this looks like?

{
var findReferencesResult = await SymbolFinder.FindReferencesAsync(local, document.Project.Solution, cancellationToken).ConfigureAwait(false);
var locations = findReferencesResult.Single(r => Equals(r.Definition, local)).Locations;
var referencedSymbol = findReferencesResult.SingleOrDefault(r => Equals(r.Definition, local));
Copy link
Contributor

Choose a reason for hiding this comment

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

why did this change to single-or-default?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That line threw an exception in #43666 and crashed the refactoring provider. I opened the original issue but haven't been able to repro it since then, so I'm unable to figure out the root cause, although I thought this might be a good way to at least prevent the crash from occurring.

Copy link
Contributor

Choose a reason for hiding this comment

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

let's undo this. i don't like this offhand change without a clear thing we know it's fixing.

Copy link
Contributor

@sharwell sharwell Sep 20, 2020

Choose a reason for hiding this comment

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

I just hit this same issue in VB code (build https://dev.azure.com/dnceng/public/_build/results?buildId=822731 has two heap dumps). I don't know exactly what it's fixing, but we certainly need to keep it. I've ported the same change to VB in 9016991.

Copy link
Contributor

@CyrusNajmabadi CyrusNajmabadi left a comment

Choose a reason for hiding this comment

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

Done with pass.

@allisonchou
Copy link
Contributor Author

inlinewarning
@CyrusNajmabadi Here's a screenshot of what the updated UI with the warning looks like.

@CyrusNajmabadi
Copy link
Contributor

Can you show an example where we inline into 3+ places?

@allisonchou
Copy link
Contributor Author

allisonchou commented May 4, 2020

inlinewarning2
@CyrusNajmabadi yep! Here's another screenshot where we inline into more areas.

Copy link
Contributor

@CyrusNajmabadi CyrusNajmabadi left a comment

Choose a reason for hiding this comment

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

Done with pass.

@allisonchou allisonchou merged commit 5bf25c6 into dotnet:master May 6, 2020
@ghost ghost added this to the Next milestone May 6, 2020
@JoeRobich JoeRobich modified the milestones: Next, 16.7.P2 May 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clicking on empty line causes InvalidOperationException in InlineTemporaryCodeRefactoringProvider Invalid refactoring for Inline Temporary Variable

4 participants