Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Roslyn Analyzers - Reimporting doesn't trigger them

Discussion in 'Experimental Scripting Previews' started by TheRobWatling, Jun 24, 2022.

  1. TheRobWatling

    TheRobWatling

    Joined:
    Feb 18, 2013
    Posts:
    45
    Hi,

    I've got Roslyn Analyzers setup, they're working pretty great but the documentation Unity provides says reimporting scripts should trigger them but this doesn't seem to happen. If I modify a script and it recompiles they show but if I just reimport nothing happens.

    Any solutions for this? Having to modify a script that's using the ruleset to see the issues is quite frustrating.

    Cheers.
     
  2. HaraldNielsen

    HaraldNielsen

    Unity Technologies

    Joined:
    Jun 8, 2016
    Posts:
    139
    Hi @TheRobWatling
    What version of Unity?
    Also what are you reimporting? If you are reimporting a *.cs file that should then trigger a recompilation for that assembly.
     
    TheRobWatling likes this.
  3. TheRobWatling

    TheRobWatling

    Joined:
    Feb 18, 2013
    Posts:
    45
    Hi, @HaraldNielsen I'm running 2021.3.4f1.
    If I reimport a single CS file it works.
    It also seems that if I right-click a folder and reimport, it doesn't trigger but selecting multiple CS files and right-click reimport it does. I would have expected a reimport of a folder to reimport the contents of that folder but is that not the case?

    Thanks.
     
  4. HaraldNielsen

    HaraldNielsen

    Unity Technologies

    Joined:
    Jun 8, 2016
    Posts:
    139
    @TheRobWatling sadly not, we do special case the reimport of *.cs file to retrigger a compilation+domain reload. We would actually have liked not to have that functionality and only compile+domain reload when actually needed (Only when something in the compilation graph has changed on disk)
     
    TheRobWatling likes this.
  5. HaraldNielsen

    HaraldNielsen

    Unity Technologies

    Joined:
    Jun 8, 2016
    Posts:
    139
    Hope that clarifies it a bit :) Out of curiosity, in what cases do you want to retrigger compilation and domain reload, without file changes?
     
    TheRobWatling likes this.
  6. TheRobWatling

    TheRobWatling

    Joined:
    Feb 18, 2013
    Posts:
    45
    Hi, @HaraldNielsen thank you for taking the time to explain, I appreciate it.
    The desire here was to be able to see warnings from the analyzers on demand e.g. I've just checked out a branch and the warnings show when I enter the editor if I then clear them the only way to get them back is to modify a file and save it. It's not a big issue, just a small annoyance to make a change, save recompile then revert it.