website icon indicating copy to clipboard operation
website copied to clipboard

Why propose debugging C++ code with `Visual Studio`, but it also works with VS Code?

Open Gustl22 opened this issue 9 months ago • 5 comments

Page URL

https://docs.flutter.dev/testing/native-debugging/

Page source

https://docs.flutter.dev/testing/native-debugging#debug-dart-and-cplusplus-code-using-visual-studio

Describe the problem

One can easily add a windows process to VS Code, after starting a Flutter app, also in VSCode, just with:

launch.json

        {
            "name": "Attach (Windows)",
            "type": "cppvsdbg",
            "request": "attach",
            "processId": "${command:pickProcess}",
        }

So I would propose to engage using just one IDE (here: VSCode) for developing on Windows instead of proposing to install Visual Studio.

This has the following advantages:

  • Using less storage (as no Visual Studio is needed)
  • Using less memory during development
  • No need to learn multiple IDEs
  • Debug in the same IDE (no need to switch between windows and breakpoints)

And no: one doesn't need to install Visual Studio (which requires at minimum than 20GB) vs "Visual Studio Build Tools" only (https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2022) in order to develop Windows apps.

Search request for "Visual Studio 2022" where we also should engage using only the "Visual Studio Build Tools" instead of the full blown setup (but this might be another topic): https://github.com/search?q=repo%3Aflutter%2Fwebsite+%22visual+studio+2022%22&type=code

Expected fix

Engage to use VSCode as default debugging tool for native code instead of "Visual Studio"

Additional context

I can try to rewrite the docs, but first I want your opinion, if that is something Flutter wants to engage.

I would like to fix this problem.

  • [ ] I will try and fix this problem on docs.flutter.dev.

Gustl22 avatar Feb 01 '25 08:02 Gustl22

@DanTup, is the following section still correct? That you need both VS Code and Visual Studio to debug? https://docs.flutter.dev/testing/native-debugging#debug-dart-and-cplusplus-code-using-visual-studio

sfshaza2 avatar Feb 04 '25 20:02 sfshaza2

Unfortunately I'm not familiar enough with debugging C++ in either editor to know if there's a significant difference between these. If VS Code does work, it might not have the same features so Visual Studio might still be recommended - I would defer to someone more familiar with debugging native code than I (@stuartmorgan is this something in your area, or do you know who might be best placed to answer this? thanks!).

DanTup avatar Feb 05 '25 08:02 DanTup

  • Using less storage (as no Visual Studio is needed)

Not telling people to install Visual Studio would require replacement workflows for everything, not just that page. Notably this would need rewriting as well.

Is there a fully featured VS Code-based replacement for that section that isn't much more complicated and/or a worse developer experience? Important factors would be:

  • Full code completion for plugin development, including of Flutter symbols
  • A build/debug cycle that works for both application and plugin code
  • Ability to launch under the native debugger (ideally without having to manually configure a long and arcane JSON config)

Search request for "Visual Studio 2022" where we also should engage using only the "Visual Studio Build Tools" instead of the full blown setup (but this might be another topic)

I would not view it as another topic; the goal of tool instructions is to provide a simple and easily understandable path to get all the tools they need to follow our instructions, not necessarily to minimize the install footprint. If we tell people to install Build Tools, then the first time they try to follow any of our docs that tell them to open the solution in VS they will be confused, and then have to figure out what to do; this is undesirable. So actively telling people to install something other than VS would need us to rewrite anything that assumes they have VS.

Similarly, making just the change proposed here, in isolation, without reworking the other content assuming VS, is probably not something we would want to do, because otherwise we have to make this page more complex, by telling people to install and configure additional things (e.g., the C++ extension) rather than using the tool they have almost certainly already installed.

If we can provide a good end-to-end story with VS Code, however, that's definitely something that seems worth considering.

And no: one doesn't need to install Visual Studio (which requires at minimum than 20GB) vs "Visual Studio Build Tools" only

To whom is this "and no" addressed? The Flutter team is aware—as you know from your prior related PR—that Build Tools is enough to build. Has someone argued otherwise?

stuartmorgan-g avatar Feb 05 '25 16:02 stuartmorgan-g

Hi @stuartmorgan, all I know is encapsulated here. It sounds like I should close this issue. Thanks for you input!

sfshaza2 avatar Feb 05 '25 21:02 sfshaza2

Not necessarily; as I said above:

If we can provide a good end-to-end story with VS Code, however, that's definitely something that seems worth considering.

I don't know if we can or not; investigating that wasn't ever a priority. I think we could leave this open so that others could investigate it and potentially put together a proposal that covers the rest of the use cases.

stuartmorgan-g avatar Feb 05 '25 21:02 stuartmorgan-g