roslyn: "Unexpected Null" dialog (and consequences) in Visual Studio when using Refactor, Extract Method

Repro in VS2015 Update 1 (not sure if others are affected):

In src\Compilers\CSharp\Portable\Binder\Binder_Symbols.cs, add the following on line 1835:

void Foo(

Now select the ternary expression just above it (between return and ;). Do Refactor, Extract Method.

An error dialog appears, stating ‘Unexpected Null’.

image

Close the dialog, and open another a file. This file’s editor is now seemingly readonly (till you close and re-open again).

Not sure if this is caused by Roslyn.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Reactions: 16
  • Comments: 35 (9 by maintainers)

Commits related to this issue

Most upvoted comments

+1 for VS 15.2 (26430.15). Same as above: break seems to be related to non-compiling intermediate code-state, reboot fixes. Not noted above: workaround editing the name and then using “Show potential fixes” (Ctrl-.) and selecting “rename ‘old’ to ‘new’” keeps working.

image

image Same problem when renaming a variable. Happened more than twice. I knew it could be fixed if I restarted VS but it’s obviously a bug.

+1 v15.4.2, happens consistently several times per day, VS restart required.

I can close the solution and re-open the solution and get it working again.

Mondo escrow triage: keeping this in 15.3, given the number of reports.

I have gotten this error in VS 2015 Enterprise and now in VS 2017 Enterprise. It appears to be after other changes have been made to the code. Exiting and restarting VS resolves the issue but it should be fixed.