Search Unity

Bug Unity/Omnisharp - Some classes from a packages seem to be not recognised by Omnisharp.

Discussion in 'Scripting' started by mohrcore, Jan 14, 2021.

  1. mohrcore

    mohrcore

    Joined:
    May 18, 2018
    Posts:
    2
    So let me save some of your time and just straight up say this:
    I did try regenerateing .csproj files.

    With this in mind, here's what happens to me:

    I'm trying to use SpriteShapeController in my script. Unfortunately Omnisharp seems to be absolutely convinced that SpriteShapeController is not in UnityEngine.U2D namespace, even tho exploring sources for SpriteShape (Library/PackageCache/com.unity.2d.spriteshape@4.1.3/Runtime/) package proves that SpriteShapeController is indeed declared as a class in UnityEngine.U2D namespace and most importantly, Unity has no problem compiling my scripts. The .csproj file used for Sprite Shape package has the following line that seems to be referencing the file with file with SpriteShapeController definition:
    Code (csharp):
    1. <Compile Include="Library\PackageCache\com.unity.2d.spriteshape@4.1.3\Runtime\SpriteShapeController.cs" />
    Yet it seems that only the classes defined in Library/PackageCache/com.unity.2d.spriteshape@4.1.3/Runtime/SpriteShape.cs are being recognised by Omnisharp.

    I'm not sure if it's Unity messing up something I'm missing in the project files, or is it just Omnisharp being a sloppy mess as usual.

    Below is some info about versions of software I'm using:

    OS: Gentoo Linux
    Unity: 2020.1.8f1
    Mono: 6.6.0.161
    VS Code: 1.52.1
    VS Code C# Extension: 1.23.8 (Omnisharp: 1.37.5, Roslyn: 3.9.0-2.20570.24)
     
  2. mohrcore

    mohrcore

    Joined:
    May 18, 2018
    Posts:
    2
    Ok, I think I found the source of the problem.

    The project references in Assembly-CSharp.csproj file have the following lines:

    https://github.com/OmniSharp/omnisharp-vscode/issues/4247


    Changing false tot true fixes this issue.

    Here's a relevant gitbhub issue: https://github.com/OmniSharp/omnisharp-vscode/issues/4247. The devs claim the issue has been solved with 1.2.3 version of VS Code package, but it's not true for me. Was it fixed just on Windows?