Add warning message if semantics may change due to inline temporary variable refactoring#43959
Conversation
|
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)); |
There was a problem hiding this comment.
why did this change to single-or-default?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
let's undo this. i don't like this offhand change without a clear thing we know it's fixing.
There was a problem hiding this comment.
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.
...s/CSharp/Portable/CodeRefactorings/InlineTemporary/InlineTemporaryCodeRefactoringProvider.cs
Outdated
Show resolved
Hide resolved
...s/CSharp/Portable/CodeRefactorings/InlineTemporary/InlineTemporaryCodeRefactoringProvider.cs
Outdated
Show resolved
Hide resolved
src/Features/CSharp/Portable/xlf/CSharpFeaturesResources.es.xlf
Outdated
Show resolved
Hide resolved
|
|
|
Can you show an example where we inline into 3+ places? |
|
|


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.)