How to ignore unassigned new in ReSharper?

孤街浪徒 提交于 2020-03-01 05:32:09

问题


(Using ReSharper Ultimate 2017.1.3.)

In my code I have something like this:

new someClass(null);

It is not assigned to any variable and it should stay like this. (It may look weird but it is used in a specific test case.)

ReSharper warning says:

Possible unassigned object create by 'new' expression

The menu doesn't suggest to auto-write the comment so I'm looking for the syntax.

What is the ReSharper comment to ignore this?

After some search I already tried:

// ReSharper disable once

// ReSharper disable once UnassignedField

// ReSharper disable once UnassignedField.Compiler

回答1:


If you place this line directly above the unassigned new, you can disable the warning once.

// ReSharper disable once ObjectCreationAsStatement


来源:https://stackoverflow.com/questions/51838070/how-to-ignore-unassigned-new-in-resharper

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