VSCode intellisense with Unity not working - c#

Note this is on my desktop;
I started a little side project in unity several weeks ago, and intellisense was working just fine. It had been working since I switched my unity code editor to VSCode long before I started this project. I went to work on it a little today and it was just gone. The only suggestions it gave me were words it had already seen, i.e. C# methods I'd used like AddLast from a LinkedList or a few method names from my own classes I'd referenced.
Every suggestion was either marked with the little "abc" tag instead of the icons indicating whether they were properties or methods, or the suggestion was a method related to unity with a missing icon.
This is especially weird, because I have a "duplicate" project on my laptop that I carry with me on campus so I can jot ideas down the second I get them. Everything is the same between both devices, the same project settings, the same preferences, the same VSC environments, the same extensions, settings, preferences, and packages.
I get intellisense on my laptop.
I've been reading threads for hours, and nothing has worked from any of them! Fresh install of C# dev kit, eliminating sln/csproj files and regenerating them from preferences, changing .net compatibility level, pointing omnisharp "in the right direction," and hours of watching unity, vscode, and my desktop shut down and reboot just to name a few.
Thanks in advance for any helpful pointers, proof I belong in a mental ward, or both!

I found the issue
Modern C# extension updates with vs code don't support unity.
See here:
Following the issue's heed, I turned off modern net with omnisharp while using extension version 1.25. Then, I updated my vs code package to the latest version (1.2.5 as of writing) and regenerated all project files from preferences (having vs code set as the designated editor).
All credit to sleepysheepy for pointing me in this direction

Does it help if you go to the C# extension and roll back to version v1.24.4, and then reload VSCode?
Pardon me if you already said you tried that! That's what did the trick when IntelliSense stopped working for me recently.

Related

Rider redirects to online MSDN documentation -- can I get offline comments for C#?

I am working on a Unity project (idk if that's relevant), but very often whenever I try to view a quick documentation popup in JetBrains Rider with CtrlQ the popup contains only the link to the online learn.microsoft.com page without providing any sensible inline help. This really hinders my workflow and forces me to make mental context switches.
Is this really the whole content of quick documentation that is available for those elements or is something broken on my side? Is their documentation reaaaaally that scarce? I thought that some basic doc for Enumerable.<LINQ queries> or Regex.* would be present...
(#EDIT even simple things like Console.WriteLine() are missing inline docs...)
Can I get the offline MSDN documentation that would be displayed in this popup?
Could it be a problem with my mono/dotnet installation, and if so how can I fix it?
IMPORTANT: I'm on Ubuntu 20.04 and using Rider 2021.3.2. I've also installed the documentation module for my unity editor instance, but I doubt it comes with MSDN included.
#UPDATE: It seems to be a unity/assembly problem, as plain C# projects do have inline documentation hints, only projects generated by unity are missing them. I tried reinstalling unity editor instance from the hub, but the documentation is still missing.
It turns out it is a Unity problem. I Managed to fix that (but it's hacky) using this unity forum thread as a reference and this bug report. I located the netstandard.xml files across my system (locate netstandard.xml command on Linux) and put it under /.../Unity/Editor/2021.2.8f1/Editor/Data/NetStandard/ref/2.1.0/netstandard.xml. (previously there was only a netstandard.dll with no xml file there).
Why isn't this shipped with the unity itself is beyond me. I had luck because I could easily find the location of my dotnet-sdk files on my machine.
If someone has other working and less hacky solution, I am happy to accept it.
#EDIT seems like unity broke something once again, because this solution no longer works... After going to symbol for any thing (e.g. ArrayList's Add()), the decompiled sources point to .../Unity/Editor/2022.1.22f1/Editor/Data/UnityReferenceAssemblies/unity-4.8-api/*.dll. I guess the "solution" would be to download and place the .xml for each corresponding .dll in this directory...
I don't really know what happened. Did I change the .NET API compatibility level somewhere? Did I change build platform (Mono, IL2CPP) or something? I don't know... (I started using the dynamic keyword which is a .NET 4.0 feature, which possibly upgraded my API Compatibility version to .Net Framework and I now target different dlls). But I shouldn't have to bother in the first place — documentation should be working by default, but we have to deal with unity here, so no surprise it's broken :)
#Edit I got frustrated by this lack of basic functionality and I "fixed" it myself... Here is a tool all of you can use to make this semi-automatic: https://t3st3ro.github.io/packages/unityIntelliSenseFixer/
It comes bundled with xmls that seem to work and a script that links them to automatic directories. Hit me up here or somewhere on my page if you have some improvements...

Has anyone conquered the Visual Studio installer project in VS2019?

I've been googling this all afternoon and I found any number of people ask the question, and all of the place a few people would answer it with the same things, and then there's a dozen comments by the rest of the world and the OP about how those answer don't fix it. So I'm going to include what I've tried here, and if your solution is to do one of the things I've already tried, I'm going to be very sad.
I have a solution in Visual Studio 2019 that has a class library, a wpf application, and a setup project (using the setup project extension). The WPF app also references a bunch of assemblies of course, but one of those is from another project I maintain in a different solution. I copy/paste the compiled dll after I update it from its own project to this one. Nothing tricky, everything works.
The problem is the installer. If I build everything and then build the installer, it produces an MSI as expected. If I right click on the project in Visual Studio and choose "Install", everything is perfect.
The problem is after I make some updates to either of the code projects, I then build both and build the setup project, and again if I right click to install it's perfect. If I run the MSI though, it doesn't always update the target files. If I delete the target files it will create them with the new ones, but it won't overwrite the old ones correctly.
AssemblyVersion and AssemblyFileVersion are both being incremented each time and are being kept in sync with the "Version" property of the setup project. I tested with these extensively, the new installer that isn't working properly 100% has updated dlls in it with correctly updated version numbers.
When I change the "version" of the setup, it asks to change the GUID for the ProductCode. I say yes, it changes the code. I have also tested without doing this and that makes it much worse as we all know.
"RemovePreviousVersions" is set to "true" in the installer project
If I right click the project and choose "Install" it seems to be 100% reliable at upgrading the existing installation.
If I run the MSI directly it seems to be 100% unreliable and never gets it right.
Side note, it does seem to usually but not always get the WPF application upgraded and the other project dll I bring in if I remember to update its version, but the class library (which is referenced by the WPF application) almost never works.
Has anyone got this to work reliably?
For all the people finding this in the future, here's the final word:
The build project can be inconsistent, this is well documented all over the internet as I have above. You're not doing anything wrong - it is just inconsistent.
Stop trying to solve it if it's affecting your project and move on (I've had a dozen projects before this one work just fine). The consensus seems to be to use WiX, but I'm not here to discuss the alternatives. Personally I am going to embark on the WiX learning curve though.

Intellisense no longer works

I've been using Visual Studio Code with unity for around 2 months now without problems, but since last week I suddenly get no more Intellisense (no code completion for C# or Unity). I don't recall changing anything and I have no idea why it suddenly stopped working.
I was using Unity 5.4 with this recommended plugin to enable VSCode integration when Intellisense stopped working.
I've already reinstalled VSCode and updated Unity to version 5.5. Unity 5.5 has built in support for VSCode, so I've removed the editor plugin from my project. I can indeed open Unity scripts in VSCode without the plugin now, but I'm still not getting any code completion.
I saw there was an update for the C# VSCode extension today, but updating that didn't help either. I've attached a screenshot of the log during this update:
As you can see there's no flame icon and the code completion is missing. The Omnisharp log is either empty or completely missing (not sure why this behaviour is not always the same).
Does anyone have any idea what I can do to fix this? Thanks.
So in my experience, whenever something weird like this happens in Visual Studio, the first thing you should do is kill all instances of VS and restart. For good measure, you could even reboot your computer, though this is often not necessary. If that still doesn't help, the next best thing is to reset your VS settings which can be done by going to
Tools -> Import and Export Settings -> Reset All Settings
A backup of the current settings are recommended, but not required.
After checking that VS is the default editor in Preferences, open your Unity project with Explorer. See if you can find a .sln file, and open it with VS. Then, go to your solution manger inside VS and try and open any of your Unity project's scripts from the manager. After doing this, your Intellisense should be working.
This worked for me when I had a similar issue side time ago.

Visual Studio error when I right click UWP project not finding framework

I am having the exact same issue/error as this post from yesterday. Similar SO Post
SIDE NOTE...As you can see, I am new and therefore, only have 45 reputation. As such, I could not simply add a comment to the above existing post and had to create a whole new post even though they are the same issue....seems silly. But I digress....
I wanted to provide additional comments in the hopes to get an answer. My issue started suddenly the a few days ago. I made no major changes to references, VS updates, etc... However, when I right click my csproj in visual studio, I get the error and I have to click it five times before it goes away, at which point I finally get the menu.
Again, I have made no major changes BUT I went ahead and confirmed that:
My target version and Min version is Windows 10(10.0; Build 10586). That is the SDK version that I have installed and am using.
I verified that my NuGet updates are complete and that my Microsoft.NetCore.UniversalWindowsPlatform are installed and update to date (5.2.2 as of now).
I do have a reference also to "Universal Windows". This was created automatically when I created my project and I cannot remove this reference but it is there. When I select it, I do see that it is "UAP,Version=10.0.10586.0" so this should be good. I do notice a possible issue here. Again, this reference was created for me and I cannot remove or change it. However, it is pointed to a folder named
C:\Program Files(x86)\Windows Kits\10\References\Windows.ApplicationModel.Calls.CallsVoipContract\1.0.0.0\
Why did the Windows Universal reference default to that folder and only that folder? I am not using VoIP so I wonder why it chose this one? Also, what if I need some of the other references in the References folder?
I created a brand new Windows Universal project and the same error happens on a fresh project.
Please help, it is annoying. Project still seems to build and work fine though.
Thanks!
I found the issue in my case, it was an extension that I added on to Visual Studio provided by SyncFusion (which their installer actually creates 7 or se extensions in Visual Studio). After troubleshooting my issue and doing some of the same things to resolve (repairing .Net, SDK, Visual Studio) I then thought about the error a bit more. While it is cryptic (and has poor english "An Exception has been occured") these are all clues that it could be any of the frameworks that I have installed via extensions as well.
I also had another clue, the issue started happening a few weeks ago, around the time I updated my SyncFusion controls to the latest version.
So, I went to Tools > Extensions and Updates. I went to Installed > All and found all of the SyncFusion items (there are several) and disabled them all. After I disabled them, and restarted Visual Studio, the problem went away!!!
This is a workaround for now. In the meantime, I put in a support ticket with SyncFusion on the issue. I will certainly update this thread when I get a response from them. Also in the meantime, I then went back and re-enabled each of them again, one at a time, to see who the real culprit was. In my case it was the SyncFusion Web Conversion and Migration extension.
If any of you are not using SyncFusion but having odd Visual Studio issues such as this, I suggest doing something similar by going through your extensions and disable any that you added on, starting with the most recent add ons, especially if they were added around the same time you started having the problem until you find the culprit.
Hope this helps!

VSCode does not detect typos, show nr of references, format C#, suggest API completions

When I switched to VSCode as my source code editor for Unity some weeks ago, it suggested API completions both for C# and for Unity. It listed the number of references above each variable declaration. It detected typos such as using undefined variables etc...
It does not anymore, none of these nice functionalities work anymore. I beleive it was caused by an extension update, but I did not pay attention at the time. (Anyway, IIUC, extension updates can't be rolled back)
I am running VSCode version 1.7.1 on windows 10 with a.o. following extension: C# for Visual Studio Code (powered by OmniSharp) v1.4.1
At the Unity side, I use the latest (v2.70) version of the Unity plug-in maintained by #Reapazor as suggested in Unity Development with VS Code
I have setup Unity to use VSCode, and turned on integration with VSCode.
I have no idea why it does (no longer) provide API completion, code checking etc... it even no longer formats the code!
Please advise...
Solved by thoroughly removing vscode and than reinstalling it.
Sorry for the noise
Try this on the Unity menu
Assets > Open C# project In Code

Categories

Resources