Moving breakpoint in middle of debug session with VSCode - c#

I am from Visual Studio land mostly working with C# applications. Recently switched to VSCode and it has been a . good experience so far. However, I miss a particular feature from that Visual studio has but I don't VsCode does have or at least I do not know how to.
With Visual Studio, I could move control from where it currently is to any previous position by physically clicking it and dragging it to a previous position. However, I do not seem to have that option with Visual Studio Code. Is there any way for me to enable that feature in VS Code for C#?

I believe still an open issue.
https://github.com/Microsoft/vscode-cpptools/issues/1025

Related

I just can't get the Visual Studio for Mac debugging to work (the option is greyed out)

no idea what I'm doing wrong here. I have two macs at home, one is mine, one is a work laptop. I have VS 2022 Preview installed on both, and .net 6 on both. On my home mac, if I start a new c# Console app I'm able to just stick a break point on the (single) Console.Writeline line, hit debug, and it stops on that line as you'd expect.
On my work mac, breakpoints just turn hollow immediately, and debugging the code just runs the code instead. The "Start Debugging" option is just greyed out in the menu bar. I've tried a bunch of things but I just can't work out why this isn't working!
I had the same issue and all the other solutions I found did not work for me with VS 2022 (v17.0.6), dotnet6.
It appears it is an IDE Issue and hopefully gets fixed soon. Installing Visual Studio 2019 seems to solve it. Credit here: Visual Studio For Mac 2022 - Cannot execute "{...}.exe".
Out of curiosity, the following appears too 'reset' it back to normal.
Set a breakpoint in your code (mine was hollow when doing so)
Select 'Visual Studio' -> 'Quit'
Re-open your solution and navigate back to your breakpoint
But after selecting "Start Debugging" option, it returns back to its previous state of no debugging.
I have had the same problem.
The extension ".Net Core Debugger" was disabled and therefore I was not able to debug projects.
Go to Visual Studio -> Extensions -> Installed and check the state

What intellisense settings I can use to change this behavior in Unity + Visual Studio?

This is a strange question so I will show a series of three gifs.
This is what happens in visual studio code if i'm writing c# (as expected):
https://gyazo.com/818c27f60d52b437dc3a7960d1e31b83
This is what happens in visual studio if i'm writing c# (as expected):
https://gyazo.com/80a5e28249fabc48192a6e051e157dbe
This is how my visual studio will behave forever until i reset to default settings for c# if i ever open a unity project in it (wtf):
https://gyazo.com/0eeb11d76fe6aab7343812882bd45314
Is this some problem specific to my env? Does unity have some default intellisense settings it's importing into my visual studio?
I tried the most recent 2 versions of unity and the most recent 2 versions of visual studio and get the same behavior.
It's extremely annoying because i have to reset my VS settings every time i open a unity project, if anyone knows what setting i am getting messed up i would be extremely grateful for an assist.

Visual Studio loses ability to attach to Unity, why?

I'm using Visual Studio with Unity. In general in VS I can simply click "Attach to Unity" and it will build the solution and indeed attach to Unity.
Sometimes, however, a project loses the "ability" to do so, what means that suddenly clicking the button will only build the solution and not attach to Unity.
I really would like to know what's happening there as I'm not aware of doing anything that could result in such a behaviour.
There are some parameters that might have an effect:
it happens only for some Unity projects: a project is either "infected" or it happens never (on my watch)
if it starts happening it will always happen until I reboot the PC (closing VS and Unity is not enough)
For me (Unity 2020.x and VS19) this happens quite often.
Simply close VS and in Unity > Edit > Preferences > External Tools
Click on "Regenerate project files" (you don't need to check anything else, just click the button)
Start VS again, and it should work as normal.
For me "Attach to Unity" disappeared from the toolbar.
But I still have a button in Debug -> Attach Unity Debugger
Hope it will help someone.
Visual Studio Community 2019 16.7
Unity 2020.1.2f1
To prevent this from happening:
When there are compiling errors in your code, don't double click on Unity Debug Log line, which opens VS at the line that threw the error, but it messes with the project files.
Regenerating the project files under Unity > Preferences > External Tools > Regenerate Project Files. Also make sure that Visual Studio is set under external tools, as well as all the Unity dependencies are correctly installed via the Visual Studio installer.
Visual Studio will prompt you to reload the project, optionally rebuild your entire solution in VS and restart both Unity and VS.
Delete all visual studio related files from the project folder. sln, csproj, vs (hidden) folder.. Reopen project with unity hub, edit one of script and all files will be generated and you will see Attach to Unity button again.
This is a quite common issue when using Unity. Me and my colleges have experienced this a couple of times each month. It usually automatically "repairs itself" after restarting VS/Unity or in worst case rebooting the computer.
Now, I've got this problem again with latest VS2019. I've tried:
Generate a new clean project
Rebooting
Regenerated all visual studio files
Reinstall VS 2019 (clean)
Reinstall Unity (It is clean - I'm only using one! editor version)
All the above suggestions
Are there any network-related issue to this or how does the attach to Unity works ? Can I check some log-files related to this?
Last time this happened to me, I needed to reinstall Windows. I might be in that situation again.
I had a similar issue, underneath the file tabs does it say miscellaneous files? To fix it I right clicked the Assembly C-Sharp in the solution explorer and rebuilt the project as shown in the picture.
Normally just restarting visual studio is sufficient, this issue was addressed and fixed by MS in VS around early december. Previously it happened each time you made a new script file.
Make sure you have installed the latest visual studio patch, as well as the "visual studio tools for unity"
I had this issue once, what fixed it for me was reconnecting Visual Studio to Unity Edit > Preferences > External Tools > External Script Editor
Also check the correct version of Visual Studio is listed there.
For Unity 2020.1.1 and above
in VisualStudio19:
go to "Build" -> "Rebuild Solution"
Unity > Edit > Preferences > External Tools > Editor Attaching
In my case (Unity 2020.2, VS Code 1.53.2) Attaching Debug option is missing on Unity.
After restarting my macbook,
Open VS Code
Open Unity
In VSCode-> Run -> Start Debugging
Unity show up to me alert just like below.
I choose Enable debugging for all projects option.
I hope, It will help someone.

Stopping Continues Testing recompilation stealing cursor in Visual Studios 2017 and Resharper

I have just started out on my journey to learn TDD with C# and to help me I have started using Reshaper 2017.1.3 Continues Testing tool to re-run all my tests that are affected by my modifications upon saving. I was hoping this would be a seamless experience with no interruptions to development but every time the projects need to be recompiled the cursor is stolen from the editor and placed inside the Output Pane which leads to a halt in development.
Is there any way to stop this behaviour without having to sacrifice the convince of the Continues Testing tool?
This might be Visual Studio behaviour - try unchecking the "Show output window when build starts" option in Tools → Options → Projects and Solutions → General.
If this doesn't help, please report an issue: youtrack.jetbrains.com
In my case I wanted to keep the focus in the editor after running my program and this solution is still available in 2021 for Visual Studio 2019.
Here is a screenshot for Visual Studio in French:

Debugging C# code in Visual Studio Code on Windows

How do you debug C# in Visual Studio Code on Windows?
I have an aspnet core project set up, I can build and edit it in VS Code and it works great.
I've installed the C# Omnisharp extension as per all of the getting started guides show and it's really easy to get going, except for one hugely important thing...
How do you actually debug it on Windows? Every article / blog post that I've come across only shows C# debugging with OSX or Linux.
Debugging with Mono doesn't work, I get the following:
Mono Debug is not supported on this platform (Win32NT).
And you can't install the Mono-Debugger extension on Windows - only OSX and Linux. Which makes sense, but what are the steps to do this with Windows?
I must be missing something really easy - how do I set up C# debugging with Visual Studio Code on Windows?
I've stumbled upon it myself and found the answer in instalation guide of debugger:
https://marketplace.visualstudio.com/items?itemName=Unity.unity-debug
You should check whether you have launch.json file already. If so, delete it and after clicking a cogwheel on top of debug view, select Unity Editor from dropdown.
There is also a VSCode Unity plugin, which may overwrite the file every time you start the game in the editor. To disable this uncheck the "Edit/Preferences/VSCode/Always Write Launch File" checkbox

Categories