Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question Rider do not analyze code, for Packages folder (embedded packages)

Discussion in 'Code Editors & IDEs' started by yanard18, Apr 10, 2024.

  1. yanard18

    yanard18

    Joined:
    Jul 27, 2019
    Posts:
    13
    Hey, I was trying to learn creating custom packages, and I moved my code from Assets folder to Packages folder. After this transfer, I realized that Rider is not analyzing the code.

    upload_2024-4-10_15-11-49.png

    Even if I try to enable the highlight, it just shown lots of error, as cannot resolve Unity

    upload_2024-4-10_15-12-45.png


    The fact that, in my other Unity project, I set analyzing on, in my other Unity project but ah... I don't remember how I achieved that. So what's the solution for this?

    Also as shown, CircularUI (which is the code that I'm working on) inside of the packages folder
    upload_2024-4-10_15-14-29.png
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    6,629
    In project settings or preferences find either the external editor section and tick the checkbox for packages. Or perhaps simply recreate the csproj files and restart rider.
     
  3. yanard18

    yanard18

    Joined:
    Jul 27, 2019
    Posts:
    13
    Now I enabled all boxes but still in same situation, also I believe I should only tick embedded packages box. And I regenerated project files, but still rider not analyzing the code in Packages folder.
    upload_2024-4-10_15-40-24.png
     
  4. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    6,629
    The package compiles in Unity without errors? And its listed in Unity under Packages respectively Package Manager?

    If it's an embedded package (located under PackageCache) move it to its own folder separate from the project and pick the "add from disk" option. That way you can use it in multiple project and put it under source control. Not sure if this changes the behaviour though, but that's the recommended workflow.

    Manually deleting the .csproj and .sln as well as the .idea folder might also help.
     
  5. yanard18

    yanard18

    Joined:
    Jul 27, 2019
    Posts:
    13
    Yes there are no compilation error. I can not add the project from disk, because I still work on the project, if I add it this way some of the assets will be not editable, however even when I add the package this way, still analyzing is disabled.

    I'm not home right now, tonight I will try to copy the .idea folder of the project which aı telled that in other project analyze works, so if it related with rider settings it may work.

    And for removing .csproj and .sln, I haven't tried .sln, but not working for .csproj.
     
  6. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    6,629
    How come?
    "by disk" packages are not read-only and if you can't select the assets in the package you only need to change the package visibility (select package.json in project view, visibility is a dropdown in Inspector)

    I wouldn't copy the .idea folder from elsewhere, this contains project specific settings. Backup the folder and delete it, let Rider recreate it, and if that doesn't fix it close Rider again and restore the previous .idea folder so you don't lose any settings.

    I do remember having had the occassional issue like yours but it was usually only a single file, not an entire project. Haven't had this issue for a while, definitely not in 2023.3 and it was always fixed either by restarting Rider or re-enabling the anaylsis setting.

    Perhaps there is a setting that turns off analysis completely for a given .csproj? Did you try clicking the "OFF" label in your first screenshot?
     
  7. van800

    van800

    JetBrains Employee

    Joined:
    May 19, 2016
    Posts:
    73
    Hey! Try to follow the following steps:
    1. set the default settings
    upload_2024-4-10_16-28-40.png
    2. Close Unity
    3. Remove all csproj, sln files
    4. Make sure your package is in the Packages folder
    5. Start Unity, call Assets->Open CSharp projects
    Rider should start with the solution
    6. You may switch to the Solution view instead of Unity view. Check that project for your package is generated.
    upload_2024-4-10_16-31-30.png
     

    Attached Files:

  8. yanard18

    yanard18

    Joined:
    Jul 27, 2019
    Posts:
    13
    God! I finally solved the issue, I thank you both for helping. The problem caused because I didn't create assembly definition for my code. Ahh it's a silly mistake...