microsoft / vscode-dotnettools

This is a feedback repository to capture issues logged for the C# Dev Kit and related extensions from Visual Studio Code
Other
220 stars 10 forks source link

[SUGGESTION] Unity debugger: Debug decompiled code #1359

Open rhys-vdw opened 1 month ago

rhys-vdw commented 1 month ago

Describe the feature you'd like

I would like to be able to set breakpoints in code that is not from my project's Assets folder.

It seems there is an option justMyCode that would be disabled usually, but it is not supported by Unity debugger launch options.

Alternatives considered

Rider

Environment Information

Windows 11 VSCode 1.91 visualstudiotoolsforunity.vstuc 1.0.2

jbevain commented 1 month ago

Hi @rhys-vdw,

Thanks for reaching out!

Could you provide more details about what's not working?

In my case, I'm able to put breakpoints in Packages. For instance, if I open

Library/PackageCache/com.unity.entities/Unity.Entities/BlockAllocator.cs

from the Unity.Entities package, I can put a breakpoint and it will break when I run the game in Unity.

For things to work, the path of the file where you put the breakpoint needs to match the path of the file that Unity compiles.

rhys-vdw commented 1 month ago

Oh... Okay, maybe I just don't understand how to do it. I do "go to definition" from a method and it shows a decompiled view of the file and any added breakpoints are "unverified" and don't catch.

Side note: Frustratingly, "go to definition" does not work within this decompiled view, greatly limiting its usefulness. This particular thing was never an issue with the old omnisharp/unity setup, unsure about the breakpoints.

Does it sound like I have something wrong in my setup?

jbevain commented 4 weeks ago

Got it. No I think your setup is correct, but the Unity debugger doesn't support putting breakpoints in decompiled sources at the moment.

By Packages I thought you meant "Unity Packages" that are usually distributed with the source.

jbevain commented 4 weeks ago

@rhys-vdw also I'd encourage you to please file a bug at https://github.com/dotnet/vscode-csharp/ about the scenario where you want to be able to do Go To Definition in decompiled sources.

rhys-vdw commented 4 weeks ago

By Packages I thought you meant "Unity Packages" that are usually distributed with the source.

Ah yes, I did not have csproj generation for packages enabled in Unity's "preferences > external tools", hence why "go to definition" was decompiling instead of taking me to the package cache.

Silly me!