Debugging Roslyn Analyzer - c#

I am working on writing a DiagnosticAnalyzer. I was able to unit test it just fine. I wanted to try it out in Visual Studio. The VSIX project that got created seems to be working. When I set that to the default project and Run the solution another instance of VS launches and I can see that my VSIX got installed. However when I set breakpoints it shows that the symbols aren't loaded and the breakpoint won't be hit. Anyone have any ideas why this would happen?

Have you made sure, that you have installed the correct version of the ".NET Compiler Platform SDK Templates" extension? I had the same problem and noticed that I had installed the wrong version. I'm using CTP 6 of VS2015 so I had to install ".NET Compiler Platform SDK Templates for CTP6" (Visual Studio Gallery). After that I've been able to debug the analyzer extension just like any other program.

Related

Intellisense working for one project but not for another on same machine

I have a Unity project on my laptop where intellisense and autocompletion works just fine with visual studio code (mac os system).
Now, i created a brand new project (same Unity version as the old one) and for that project intellisense is not working :O Same machine, same editor, everything else is the same.
Any suggestions on what could fix that since the required dependencies are already installed (the visual studio code output is not giving me any logs or other messages by the way) ?
From omnisharp's announcements
If you still need Unity or .NET Framework support, you can set omnisharp.useModernNet to false in your VS Code settings and restart OmniSharp. Please see the Requirements section above to ensure necessary tooling is installed.
So we just need to uncheck Omnisharp: Use Modern Net in vscode settings, and beware of the settings precedence.

VSCode OSX C#, classes not highlighted, no ⌘ + F12 goto implementation

I have Visual Studio Code (v. 1.69.2) running on OSX and it's not doing the following:
Doesn't highlight any classes (custom or system classes)
⌘ + F12 doesn't go to implementation of a class or method
Doesn't show tooltips over System classes indicating what library they come from, etc.
It does do the following:
Highlights basic system struts like int, double, string.
Gives intellisense autocomplete while typing.
Some background:
I have the C# (OmniSharp) extension installed and up to date. My VSCode is also up to date. My projects are all .net core 3.1, there are multiple projects in my folder along with a solution file. I've tried "⌘ + ⇧ + P" choosing "OmniSharp Select Project" and selecting the solution, but it doesn't resolve the issue.
The most annoying part is not being able to see the tooltips regarding what exactly a class is and what library it's coming from. For example I was "Using System.Security.Claims" and when I type "User" down in the code, it autocomplete it's available methods but I get no details on what the class is or where it comes from. Is this just the way things are with VSCode, if so it's bordline unusable.
Am I using the wrong extension? (seems to be the Microsoft suggested one)
Screenshots:
I ended up installing Visual Studio for Mac 2022 (not Visual Studio Code), for work with another project. This re-installed .net core 3.1 on my machine. After that my Visual Studio Code IntelliSense (OmniSharp Extension) started working. Now I can right click and go to definition etc.
So not sure what the initial issue was, but seems a re-install of .net core 3.1 worked. If anyone else runs into the issue, I'd suggest first removing the OmniSharp Extension, restarting your Mac, restarting VSCode and re-installing the extension. If that doesn't work uninstall VSCode entirely and re-install. Basically after a fresh install of .net core framework everything worked.

Unity Code Snippets not auto-completing in Visual Studio Code

I've come across a bug in Visual Studio Code involving the Unity Code Snippets extension and its auto-complete function.
After installing Visual Studio Code, in some cases, when you open the program you will get a notification that states "The .NET Core SDK cannot be located. .NET Core debugging will not be enabled. Make sure the .NET Core SDK is installed and is on the path."
This will cause a bug in the Unity Code Snippets extension causing it to not auto-complete the code once inputted into the IDE.
To fix this issue:
1.) Click on the .NET Core SDK link that pops up in Visual Studio Code or simply google .NET Core SDK.
2.) Before installing .NET Core SDK, close Visual Studio Code.
3.) Re-install .NET Core SDK.
4.) Re-open Visual Studio Code and the auto-complete feature should work now!

Cannot start OmniSharp because Mono version >=6.4.0 is required

I use VSCode for Unity development. Unfortunately, I'm not getting any IntelliSense within VSCode for my C# code. The root cause appears to be OmniSharp failing to find Mono, as the OmniSharp Logs within VSCode read:
"[ERROR] Error: Cannot start OmniSharp because Mono version >=6.4.0 is required."
This is an issue I've run into multiple times. On 3/4/2021 and for months prior everything was working just fine and IntelliSense was working perfectly for multiple Unity projects and multiple Unity versions. Then the next day it broke for some unknown reason and didn't work for any project, until late at night after trying a bunch of things I was able to get it working. And now this morning I'm once again getting this error. Each time between it working and it breaking I didn't make any changes besides restarting my computer.
MacOS Mojave 10.14.6
Unity 2020.2.0f1 + Visual Studio Code Editor 1.2.3 package for Unity
VSCode 1.54.1 + C# 1.23.0 plugin for VSCode
Mono 6.12.0.122 installed at /usr/local/bin/mono via brew
Mono 6.12.0 also installed manually at /Library/Frameworks/Mono.framework/Versions/Current/Commands/
which mono in my terminal and VSCode's terminal outputs /usr/local/bin/mono
mono --version in both terminals outputs Mono JIT compiler version 6.12.0.122
echo $PATH contains paths to both versions of Mono, /usr/local/bin/mono appearing first
msbuild outputs Microsoft (R) Build Engine version 16.6.0 for Mono and which msbuild outputs /usr/local/bin/msbuild
dotnet --info outputs .NET Core SDK Version: 3.1.201
In my VSCode's settings I've set the following:
"omnisharp.loggingLevel": "debug",
"omnisharp.monoPath": "/usr/local/bin/mono",
"omnisharp.useGlobalMono": "always"
Things I've tried:
Downgrading/upgrading VSCode's C# plugin (including to the latest version of 1.23.9)
Downgrading Unity's Visual Studio Code Editor package
Switching VSCode to use the version of Mono 6.12.0 I manually installed at /Library/Frameworks/Mono.framework/Versions/Current/Commands/ (and uninstalling the brew-installed version)
Unsetting the omnisharp settings in VSCode (it leads to a different error about .NET SDKs)
Deleting Unity's .csproj and .sln files so that it can regenerate them
Manually telling Unity to regenerate all the .csproj files
Restarting
Looking at many forums posts and Stack Overflow questions on the topic for solutions
So does anyone have any suggestions for getting IntelliSense working in VSCode? Any tips for debugging why OmniSharp can't find Mono? I feel like I've done everything in my power to point OmniSharp to the correct place, I wish it logged a bit more about what it was trying.
I was able to resolve the issue by downgrading Visual Studio Code to 1.52.1 at https://code.visualstudio.com/updates/v1_52 and turning off automatic updates in VS Code. OmniSharp is now working without any exceptions. Seems likely that the root cause lies with VS Code 1.54 (or possibly 1.53)
I had this same problem (no Intellisense). Tried many of the things listed here and elsewhere. Turned "ominsharp.useGlobalMono" to "never" as suggested most places, and restarted omnisharp when prompted, and it changed nothing. However, I got an error that I didn't get before (didn't save it, but it's the message stating that older versions of mono(?) aren't supported).
I therefore put it back (to "always") and restarted omnisharp when prompted...and autocomplete works. Didn't even exit VS code. Scripts were still open. No clue why it works now, but it does. So....set to never and back to always?
Using VS Code v 1.55.2.
Using dotnet 5.0.202
Set "omnisharp.useGlobalMono" to "never", and make sure you have a .NET .sln file for your project in the root of your workspace. If the solution is not in the root of your workspace, press Ctrl+Shift+P, and run "OmniSharp: Select Project" to select your .sln file.

debugging visual studio extension, different version

I am building an extension (Editor Classifier) using VS2012, and I can verify that it works with VS2013 by setting the install target to include the correct versions.
However as it is today, I need to install and verify features. This is ok for most cases, except when I would like to debug the extension.
Now, if I were debugging an extension on VS2012, using VS2012, then launching the Experimental Instance works well.
But if in a VS2012 project, if I set the startup program to be devenv.exe of VS2013, with rootSuffix /exp then although the VS2013 experimental instance is launched, it does not register the extension under development.
Any tips to configure Visual studio debugging across versions would be greatly appreciated!
It's not simple case of switching 3 letters when trying to make your VS2012 extension work with VS2013 :-).
You will need to do quite few things:
update referenced dlls
update the manifest
let the VS also do his magic when upgrading the project.
http://geekswithblogs.net/TarunArora/archive/2013/06/27/upgrading-vsix-extensions-from-vs2012-to-vs2013.aspx
You might also need to use ProvideAutoload on your package: Visual Studio Package Initialize method does not call when debugging

Categories