0

In Visual Studio 2017 (15.9.16) I can keep on editing source files after I started a build with the Debug > Start Debugging command (F5). While I am specifically asking this for the C# compiler, it would also be interesting to know if C++ behaves differently.

When I edit once the debugger has been attached, and edit-and-continue is enabled, then edits are underlined with squiggly purple and everything is clear.

When I edit before the debugger has attached, and my edit is saved before the build succeeds, the whole thing appears to be in limbo. Either my edit was too late, and the debugger executes the code that has been built (not obvious except for hollow breakpoint bullets, if any). Or it was timely, and is included.

Where is the point in a build's timeline when it is decided if a recent edit will still be included? By the timestamp the build started? Indeterminate? Immediately before the source file is processed by the compiler? Does the linker check if the obj was generated from a source that changed after it started?

Cee McSharpface
  • 8,493
  • 3
  • 36
  • 77
  • 1
    For c# project,actually, when you check the option `Enable Edit and Contniue`, the code changes will be applied into the debugger only when you return the breakpoint execution arrow to the change part. But the changes are being put into a temporary library, only for debugging purposes, and are not being built into the output path(obj and bin). Include this only if you start the build when you interrupt and debug again. That's the C# mechanism. – Mr Qian Feb 04 '20 at 15:41
  • And this is the opposite of a C++ project. When you move the cursor to the modified part of a c++ project, it triggers build task to recompile the project, which will include these changes directly. It is the time which includes the modified part in the build process. – Mr Qian Feb 04 '20 at 15:48
  • these two comments almost form a complete answer. just one detail is still bugging me: how long into the build process can you save changes to source files so their latest version will still be included in the ongoing build's output? – Cee McSharpface Feb 05 '20 at 10:32

1 Answers1

1

Behavior of Visual Studio when editing whilst building

Faced with this behavior, C# and C++ projects show two different manifestations:

For c# project,actually, when you check the option Enable Edit and Contniue, the code changes will be applied into the debugger only when you return the breakpoint execution arrow to the change part. But the changes are being put into a temporary library, only for debugging purposes, and are not being built into the output path(obj and bin). Include this only if you start the build when you interrupt and debug again. That's the C# mechanism.

And this is the opposite of a C++ project.

For C++ projects, when you move the cursor to the modified part of a c++ project, it triggers build task to recompile the project, which will include these changes directly. It is the time which includes the modified part in the build process.

how long into the build process can you save changes to source files so their latest version will still be included in the ongoing build's output?

For C++ projects, Once you move the cursor to the modified part to trigger the rebuild task, the modified part is permanently included in the build file. During this process, you do not need to build your project again.

If you debug a C# project, when you move the cursor to the modified part, this does not trigger the automatic build task, so this part is not automatically included in the output file, but only in the current debugging phase.

So when you finish the crrent debugging proecess and then start debug again which will trigger the build process or click build button directly so that these edits can be permanently included in the build file.

Overall, when you click the debug button, the build process will be triggered automatically, so you can debug later. Once the build is triggered, these parts are permanently included in the build file.

And you can see all of these on the Output window.

Mr Qian
  • 21,064
  • 1
  • 31
  • 41