2

When I was using Visual Studio 2017 my code was read-only until I hit "break all" or a breakpoint. I'm pretty sure this was out-of-the-box without me changing any option. I'm talking about Windows desktop development with C# and edit-and-continue.

With 2019 I'm always able to change the code, but since the debugger is not paused the change, highlighted with a green squiggle, can't be compiled on the fly.

ccalboni
  • 12,120
  • 5
  • 30
  • 38
  • 1
    Did you check the "Enable Edit and Continue' option in Tools - Options - Debugging - General ??? – Afshin Nov 07 '20 at 11:30
  • protip: instead of asking on Stackoverflow and getting annoyed no one's answering until you add a bounty, _ask the VS community_, and then maybe post to SO too as secondary avenue of information. SO is your last resort, whereas questions about VS very much have their own "best place" to ask - and if you don't get answers there, maybe your parallel post on SO does get an answer. – Mike 'Pomax' Kamermans Nov 07 '20 at 21:31
  • I'm not annoyed, I usually get my answer this way. I'm lucky enough to have a good amount of points coming from an old answer I gave and I spend them whenever I need. I know this is not how it is supposed to work, but works for me. Also, I have the feeling that the bounty encourages high quality answers.Appreciate your tip anyway, so thanks! – ccalboni Nov 12 '20 at 08:25

1 Answers1

2

With 2019 I'm always able to change the code, but since the debugger is not paused the change, highlighted with a green squiggle, can't be compiled on the fly.

This is the "expected behavior" since VS 2019 16.3. It was reported as a bug/regression on developercommunity.visualstudio.com under Able to type while debugging back in Oct 2019, and was resolved as "Closed - Not a Bug". Quoting from the Microsoft-sanctioned comments:

This behavior you described is expected for Visual Studio 16.3. We went through several changes on Edit and Continue and now allow editing the code while the application is running. Any errors or warnings regarding your changes will show up at the Error List Window. In order to apply these changes, you simply have to be on a break state (e.g. break all or stop on a breakpoint) and continue from there.

[...]

The new design allows you to edit the code while running, however these changes won't be actually applied until you stop at a breakpoint or break your app, so you'll have pretty much the same behavior as before.

If you edit your code with Edit and Continue disabled, you'll be notified that the file changed (only if "Require source files to exactly match the original version" is checked), but you shouldn't be forced to restart the app.

dxiv
  • 16,984
  • 2
  • 27
  • 49
  • 1
    Thanks @dxiv, makes sense. I'm changing my workflow according to this, in conjunction with the "[Break In Current Document](https://marketplace.visualstudio.com/items?itemName=thijstijsma.BreakInCurrentDocument)" extension I think it may work perfectly – ccalboni Nov 12 '20 at 09:04
  • 1
    @ccalboni Thanks for the pointer. VS could have at least provided an option to keep the old behavior, and this was suggested in several comments on the linked ticket, but there are no signs of that happening anytime soon. – dxiv Nov 12 '20 at 17:20