Resharper gotchas [closed]

扶醉桌前 提交于 2019-12-05 00:14:36

When I run across preprocessor directives that use #ifs to do conditional compilation, and the current configuration is set so that a block of code is hidden, it doesn't seem to see the #if'd code and will recommend yanking out a variable that block of code uses, thinking it's never called.

You can mark such properties by UsedImplicitly attribute and ReSharper will not suggest to remove it.

We have used file-wide conditional compilation in the past, and Resharper goes completely nuts about those. It has no idea the conditions even exist, and loads of conflicts and errors can appear if both files declare the same constants and methods.

<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' Or '$(Configuration)|$(Platform)' == 'Release|x64'">
    <Compile Include="SomeFileFor.x64.cs">
        <SubType>Code</SubType>
    </Compile>
</ItemGroup>
<ItemGroup Condition=" !('$(Configuration)|$(Platform)' == 'Debug|x64' Or '$(Configuration)|$(Platform)' == 'Release|x64')">
    <Compile Include="SomeFileFor.x32.cs">
        <SubType>Code</SubType>
    </Compile>
</ItemGroup>

Resharper is either ignoring completely or has quite different implementation of handling Warning As Errors project build switch. Additionally, last time when I checked, it ignored "Suppress warnings" block in project configuration when used in conjunction with Warnings as errors.

user3182788

The conditional compilation was added to ReSharper 8. Just get the last version.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!