【发布时间】:2019-02-26 21:26:49
【问题描述】:
每当我为调试配置定义条件编译符号时,当我从调试配置切换到发布配置时,编辑器视图会保留相同部分的活动代码。但是在运行时它会按预期运行。
我的 csproj 文件:
<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>
还有我的代码:
public static void Main()
{
#if STACKOVERFLOW
Console.WriteLine("Hello World!");
#else
Console.WriteLine("Salve Mundi!");
#endif
Console.ReadKey();
}
当我切换到发布配置时,Resharper 会忽略我代码的 else 分支。
如何强制 Resharper 考虑正确的编译符号?
环境:
- Windows 10 专业版 (1803)
- Visual Studio 2017 (15.9.7)
- 锐器 (2018.2.3)
【问题讨论】:
标签: c# .net resharper conditional-compilation