Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Visual Studio - no documentation text for System types

Discussion in 'Code Editors & IDEs' started by maxim6394, Aug 1, 2022.

  1. maxim6394

    maxim6394

    Joined:
    Feb 24, 2015
    Posts:
    9
    Hello, I'm currently using Visual Studio 2019 Community Edition with Unity 2021.3, but somehow Visual Studio doesn't show the documentation texts for the system classes like List:
    upload_2022-8-1_18-3-34.png

    It works correctly for all the Unity classes, but it's kind of annoying when that information isn't available for System classes. I installed the .NET package in Visual Studio Installer, but still no difference.
    Any ideas?
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,719
    This may help you with intellisense and possibly other Visual Studio integration problems:

    Sometimes the fix is as simple as doing Assets -> Open C# Project from Unity. Other times it requires more.

    Other times it requires you also nuke the userprefs and .vsconfig and other crufty low-value high-hassle files that Visual Studio tends to slowly damage over time, then try the above trick.

    Barring all that, move on to other ideas:

    https://forum.unity.com/threads/intellisense-not-working-with-visual-studio-fix.836599/

    Also, try update the VSCode package inside of Unity: Window -> Package Manager -> Search for Visual Studio Code Editor -> Press the Update button

    Also, this: https://forum.unity.com/threads/no-suggestions-in-vscode.955197/#post-6227874
     
  3. maxim6394

    maxim6394

    Joined:
    Feb 24, 2015
    Posts:
    9
    Unfortunately none of the above methods helped. I tried installing the latest beta version Unity 2022.2.0b3 using Visual Studio 2022, but there the Unity packages aren't being recognized. Also, unity hub always displays Visual Studio as not installed every time I re-open it. Also tried uninstalling and reinstalling it from unity hub, didn't help.

    edit: inside VS I clicked reload projects, then it seems to show the intellisense for the unity packages, but still the same problem where I don't have intellisense texts for .Net System classes.

    upload_2022-8-1_19-17-32.png
     
    Last edited: Aug 1, 2022
  4. Frizzil

    Frizzil

    Joined:
    Aug 3, 2022
    Posts:
    5
    Other Discord users appear to lack access to .NET documentation via Intellisense as well. The closest solution I could find was this SO post, which explains that the appropriate XMLs are not included with the .NET DLLs provided by Unity. And while I recall this fix having worked at some point last year (with some tinkering), I don't seem to be having any luck this time around.

    Unity - could you please get the .NET documentation working with Intellisense? Trying to learn any .NET API is basically impossible without googling every completion Intellisense presents. Not only is this extremely hostile toward beginners, but it makes new technologies like async/await inaccessible as well. I'm shocked that Unity has been in this state for so long.
     
  5. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,380
    I don't know about getting Unity to include it in the install... that's on them.

    But I know how you could hack that stuff in.

    So... the folders will vary from version to version, but this is the basics.

    1) First locate the folder in which the .net libraries are installed. For my system specifically and the version of .Net I'm on it's located at:
    C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2
    (that last v#.#.# will vary depending on your version. If these can't be found... are you sure you installed the .net framework when you installed Visual Studio?)

    2) locate the folder in your current version of Unity where it stores all the managed .net libraries. I'm currently on 2021.3.31f1 and it's located:
    C:\Program Files\Unity\Hub\Editor\2021.3.21f1\Editor\Data\UnityReferenceAssemblies\unity-4.8-api

    If you're having trouble finding it, you can load up your project, open Visual Studio from your project, and in the 'Assembly-CSharp' project under References just select one of the .net libs... mscorlib should be a good one since that's where things like List are (OPs image). The 'Path' in the Properties window is where it's located:
    upload_2023-5-2_22-49-5.png

    3) Now... for any libs you want the documentation to show up for just copy its corresponding .xml file from the .NetFramework\v... folder into this folder.

    For example here I've copied the mscorlib.xml into mine:
    upload_2023-5-2_22-50-14.png

    And I get the documentation in my intellisense:
    upload_2023-5-2_22-50-48.png

    NOTE - you may have to close and relaunch Visual Studio.

    NOTE 2 - I don't necessarily know if the mscorlib.dll from Unity 100% matches the one found in your .NETFramework folder. As a result it might not have the documentation for ALL members if the xml file you copied just happens to not have it for that specific type.
     
  6. Frizzil

    Frizzil

    Joined:
    Aug 3, 2022
    Posts:
    5
    I'm still not getting this to work. I am on .NET Standard 2.1 however, not .NET Framework (under Project Settings -> Player -> Other Settings -> Api Compatibility Level). Following the DLL path under References gives me
    C:\Program Files\Unity\Hub\Editor\2022.2.17f1\Editor\Data\NetStandard\compat\2.1.0\shims\netfx\mscorlib.dll
    , but transferring XMLs from various places accomplishes nothing (testing with
    List.Add
    ).

    I've tried transferring from the place you mentioned,
    C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\7.0.5\ref\net7.0
    , and other places that I tried yesterday (I tried the first two just now), all to no avail. Any tips here would be appreciated. It may simply be a matter of finding the right source.

    Note: my .csproj actually indicates v4.7.1, not v4.7.2, but neither XML source under Reference Assemblies makes a difference. The actual XMLs appear to mostly redirect to folder v4.X anyway, and don't obviously contain any version information.

    Also note: I'm currently on Unity 2022.2.17f1 (the most recent non-LTS build), which may explain discrepancy in solutions working for others and not me, though I'm uncertain why.

    Note again:
    C:\Program Files\dotnet\packs\NETStandard.Library.Ref\2.1.0\ref\netstandard2.1
    is really close to what I think I need, with only one really large netstandard.xml file. The reason this is because the Unity "netfx" file is adjacent to a "netstandard" file that clearly corresponds to it - however, I have no "netfx2.1" or similar near that source directory. Perhaps I need to download it from somewhere...
     
    Last edited: May 4, 2023
  7. antsy1992

    antsy1992

    Joined:
    Jan 8, 2021
    Posts:
    3
    My man, i found this solution

    "you are missing the necessary .xml files in your unity editor installation. This can be easily solved hacked by providing files manually -- just copy the netstandard.xml file from your dotnet installation to .../Unity/Editor/2021.2.8f1/Editor/Data/NetStandard/ref/2.1.0/netstandard.xml Why the xmls are not shipped is beyond me though..."

    https://www.reddit.com/r/Unity3D/comments/o24439/missing_c_xml_documents/