Open Soroosh-Sharif opened 1 year ago
Hi! This looks to be very similar to #322. Could you make sure your C#
and C# Dev Kit
extensions are updated to at least:
C#
(v2.0.320)C# Dev Kit
(v0.4.2)Thanks!
I made sure to restart vscode and unity yet the problem still exists. Perhaps downgrading the C# to v2.0.320 would help?
Thanks for checking this. In Unity's Preferences -> External Tools, could you do “Regenerate project files” just in case? Then check the generated csproj
(like Assembly-CSharp.csproj), you should have a line like (but not with my username 😄):
<Analyzer Include="/Users/jbevain/.vscode/extensions/visualstudiotoolsforunity.vstuc-0.9.0/Analyzers/Microsoft.Unity.Analyzers.dll" />
You could also try to invoke the command .NET Restart Language Server
.
Regenerating project files and restarting the language server using .NET Restart Language Server
didn't solved the problem. My csproj
doesn't have a line like yours.
If I set Visual Studio as the external editor, Analyser line will appear in csproj
but when I switch back to Visual Studio Code the line disappears. I added the line manually to the csproj
but it doesn't work.
That points to a setup issue.
@Soroosh-Sharif, please make sure that in Unity's Package Manager, the Visual Studio Editor
package is updated to version 2.0.20
, then regenerate the project files?
Sorry for my late response. Visual Studio Editor
is already the latest version.
I suspect there is something wrong with my vscode installation because I face same problems in Blazor projects. I will test it and report back as soon as possible.
If you don't have an <Analyzer>
in your generated csproj, it's indeed possible that our Visual Studio Editor package somehow fails to find the analyzers.
On Linux and macOS we're looking at:
~/.vscode/extensions/visualstudiotoolsforunity.vstuc-0.9.0/Analyzers\*.dll
On Windows we're looking at:
%USERPROFILE%\.vscode\extensions\visualstudiotoolsforunity.vstuc-0.9.0\Analyzers\*.dll
Are you extensions installed elsewhere?
I see. I manage my vscode installation using Scoop. A quick search on my drive revealed that Microsoft.Unity.Analyzers.dll
can be found at the following locations:
C:\Users\<user>\scoop\apps\vscode\current\data\extensions\visualstudiotoolsforunity.vstuc-0.9.0\Analyzers
C:\Users\<user>\scoop\apps\vscode\1.81.0\data\extensions\visualstudiotoolsforunity.vstuc-0.9.0\Analyzers
C:\Users\<user>\scoop\persist\vscode\data\extensions\visualstudiotoolsforunity.vstuc-0.9.0\Analyzers
Is it possible to set a custom path for extension directory?
I also found one at C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\Extensions\Microsoft\Visual Studio Tools for Unity\Analyzers\Microsoft.Unity.Analyzers.dll
. I assume that's why it works fine for Visual Studio.
@Soroosh-Sharif Hah! That explains it! Thank you so much for the help and for the details. Now we need to find a better way to find our analyzers relative to your Visual Studio Code installation.
@Soroosh-Sharif what's the full path of the exe
you give to Unity as an external tool?
C:\Users\<user>\scoop\apps\vscode\current\Code.exe
@Soroosh-Sharif hi! Just wanted to provide a quick update. Today we don't support scenarios where VS Code is not using its standard extensions
folder. We have an idea on how to address that but it will require some work outside of the Unity extension. We're keeping this issue opened as a suggestion as this is something that we want to address. Thanks!
Thank you.
I temporarily solved the problem by copying the visualstudiotoolsforunity.vstuc-0.9.0
folder from:
C:\Users\<user>\scoop\persist\vscode\data\extensions
and pasting it into:
C:\Users\<user>\.vscode\extensions
Describe the Issue
I am encountering an issue with "Unity for Visual Studio Code". Intellisense suggests that a private variable decorated with "SerializeField" should be readonly. However, making the field readonly causes it to disappear from the unity editor, which seems incorrect behavior. Is there a way to hide this suggestion?
Steps To Reproduce
Expected Behavior
Intellisense should not complain about making a variable readonly if it is decorated with "SerializeField".
Environment Information