Sometimes when using ReSharper and Visual studio, you will notice that there
is a lot of unresolved code or absence of ReSharper inspections in some files.
This is because of corrupted cache files of ReSharper. ReSharper caches a lot of
its data like results of Code Analysis, so that it can quickly load things and
need not rescan everything again. It stores the cache in the solution folder or
in a temp folder which is usually the local app data folder.
In such a case of unresolved code and inspection errors int ReSharper, one can
use the ReSharper menu to clear the cache.
After clearing the cache you need to
reopen your solution and wait a little while ReSharper rebuilds the cache.
Usually this will solve the problem. But sometimes even this doesn't help.
In such a situation, only option is to locate the ReSharper caches directory and
remove the content and restart visual studio. The location of the cache is in
the app data folder :
Only thing that will differ would be the version number of ReSharper in the
above path. In the past few days, I have been doing this a lot and it was time
consuming enough to bother me. So I wrote a bat file to do this for me...
is a lot of unresolved code or absence of ReSharper inspections in some files.
This is because of corrupted cache files of ReSharper. ReSharper caches a lot of
its data like results of Code Analysis, so that it can quickly load things and
need not rescan everything again. It stores the cache in the solution folder or
in a temp folder which is usually the local app data folder.
In such a case of unresolved code and inspection errors int ReSharper, one can
use the ReSharper menu to clear the cache.
ReSharper | Options | Environment | General
After clearing the cache you need to
reopen your solution and wait a little while ReSharper rebuilds the cache.
Usually this will solve the problem. But sometimes even this doesn't help.
In such a situation, only option is to locate the ReSharper caches directory and
remove the content and restart visual studio. The location of the cache is in
the app data folder :
%LOCALAPPDATA%\JetBrains\ReSharper\v8.2\SolutionCaches\
Only thing that will differ would be the version number of ReSharper in the
above path. In the past few days, I have been doing this a lot and it was time
consuming enough to bother me. So I wrote a bat file to do this for me...
rem @echo off set tasklist=%windir%\System32\tasklist.exe set taskkill=%windir%\System32\taskkill.exe set procName=devenv.exe :STOPPROC set wasStopped=0 set procFound=0 set notFound_result=ERROR: for /f "usebackq" %%A in (`%taskkill% /IM %procName%`) do ( if NOT %%A==%notFound_result% (set procFound=1) ) if %procFound%==0 ( echo The process was not running. goto :DELETE ) set wasStopped=1 set ignore_result=INFO: :CHECKDEAD "%windir%\system32\timeout.exe" 3 /NOBREAK for /f "usebackq" %%A in (`%tasklist% /nh /fi "imagename eq %procName%"`) do ( if not %%A==%ignore_result% (goto :CHECKDEAD) ) goto :DELETE :DELETE set folder="%LOCALAPPDATA%\JetBrains\ReSharper\v8.2\SolutionCaches" cd /d %folder% for /F "delims=" %%i in ('dir /b') do (rmdir "%%i" /s/q || del "%%i" /s/q) START "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe" "<path to your sln file>" pause goto :EOF call :STOPPROC
Now whenever I find such ReSharper problems, all I have to do is to run
this bat file. This even works when there are multiple instances of visual
studio running, it kills all the instances.
Do let me know if you have a better solution ....
No comments:
Post a Comment