Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resharper "Cannot resolve symbol" when the code well-compiled

enter image description here

I believe, the error message not related to Serilog specifically, but is rather because of the code/assembly/package specific structure/modifiers etc.

So, the issue is that Resharper shows the error (and the code (from assembly referenced) is not accessible for navigation to) when Visual Studio navigates (by Go to Definition command) to metadata and compiles the code well (including, showing the method description successfully as well).

The method is defined in assembly as follows:

namespace Serilog
{
    public static class Log
    {
        public static ILogger ForContext<TSource>();

My current version of Visual Studio: 2017 (15.4.4) Resharper: 2017.2.2

Generally, everything works well for me, but because of "lost" definition, my object defined (Logger) indicated as unresolved through the whole code, so all my scrolling bar is red with error notes, which is quite confusing.

Any thoughts?

like image 867
Agat Avatar asked Feb 07 '18 02:02

Agat


1 Answers

This following seems to work for me most of the time

Solution 1

Tools->Options->ReSharper 
  • Suspend Now
  • Resume

It refreshes the cache and/or some other dark magic


Solution 2

You could try clearing the ReSharper cache implicitly

ReSharper->Options->Environment->General 
  • Clear Caches.

Solution 3

You can also try unloading and then reloading the project.

Solution Explorer->Right Click
  • Unload Project
  • Reload Project

Solution 4

As a last resort you can try to delete the solution cache manually

%LOCALAPPDATA%\JetBrains\Transient\ReSharperPlatformVsXX\vXX\SolutionCaches\
like image 144
TheGeneral Avatar answered Nov 05 '22 13:11

TheGeneral