Go to Options -> TextEditor -> C# -> Advanced. Under Editor Help, disable "show diagnostics" for closed files. This option disables the analyzers from running on all closed files in the solution and the analysis is performed only on the Open/Active files in VS.