When using Visual Studio for Mac 17.4 preview build 715 with Unity 2021.3.8 I find that “using” statements are frequently being inserted into my c# scripts. I’m not sure the exact conditions that cause the insertions but the using statements are not needed and often break compilation.
Does anyone have a solution for this problem? Other than the obvious… don’t use this version of Visual Studio.
I would not be surprised to hear that this happens with autocompletion.
You might be typing the name of the class, you get a suggestions like “Classname” but there may be two or more classes of that name spread throughout namespaces and assemblies. But by the time you autocomplet the using statement was already added while you’re reverting the autocompleted text to the actually desired class.
Pulled my unity project fresh from the VCS this morning and noticed this issue is gone. This process nuked all the cached files in the Library folder. I suspect this is the culprit, and in the future I will be doing a clean pull anytime I upgrade either Unity or Visual Studio.
And you can confirm that you don’t have the /Library folder under VCS, correct? That sounds like the case from your description but I just wanted to make sure.
I have had this same issue for few months as well. Driving me crazy and I have no idea how to go around it or how is it happening. I’m seeing a lot of UnityEditor* using statements, which is the breaking our cloud builds. Also using 2021.3.* LTS branch and visual studio 17.3.*