如何忽略ReSharper中未分配的新内容? [英] How to ignore unassigned new in ReSharper?
问题描述
(使用ReSharper Ultimate 2017.1.3。)
(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警告说:
ReSharper warning says:
可能通过'new'表达式创建未分配的对象
Possible unassigned object create by 'new' expression
菜单不建议自动编写注释,所以我在寻找语法。
The menu doesn't suggest to auto-write the comment so I'm looking for the syntax.
忽略此内容的ReSharper注释是什么?
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
推荐答案
如果将此行直接放置在未分配的新行上方,则可以禁用一次警告。
If you place this line directly above the unassigned new, you can disable the warning once.
// ReSharper disable once ObjectCreationAsStatement
这篇关于如何忽略ReSharper中未分配的新内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!