Search code examples
c#.netresharperconditional-compilation

How to force Resharper to take into account conditional compilation symbols


Whenever I define a conditional compilation symbol for the debug configuration, the editor view keeps the same portion of active code when I switch from debug to Release configuration. However at runtime it runs as expected.

My csproj file:

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.1</TargetFramework>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <DefineConstants>STACKOVERFLOW</DefineConstants>
  </PropertyGroup>
</Project>

And my code:

public static void Main()
{
    #if STACKOVERFLOW
    Console.WriteLine("Hello World!");
    #else
    Console.WriteLine("Salve Mundi!");
    #endif
    Console.ReadKey();
}

When I switch to Release configuration Resharper ignores the else branch of my code.

How can I force Resharper to consider the right compilation symbols?

Environment:

  • Windows 10 Pro (1803)
  • Visual Studio 2017 (15.9.7)
  • Resharper (2018.2.3)

Solution

  • Reloading(unload and reload project in visual studio) the project makes Resharper reconsider the view and will make the right portion of code active.