B. *_*non 5 resharper enums combobox datasource automated-refactoring
我有这些枚举:
private enum FontSizeType
{
XSmall, //9
Small, //12
Medium, //18
Large, //24
XLarge, //36
XXLarge //47
}
private enum AlignOptions
{
Left,
Center,
Right
}
private enum ValueType
{
Text,
Barcode
}
Run Code Online (Sandbox Code Playgroud)
Resharper的检查告诉我所有人"Enum会员'XSmall'[等]从未使用过"
然而我在我的组合框中使用它们,如下所示:
comboBoxType1.DataSource = Enum.GetNames(typeof(ValueType));
Run Code Online (Sandbox Code Playgroud)
......为什么Resharper被骗了?或者是吗?
ReSharper不检测隐式用法.您可以使用[UsedImplicitly]告诉它隐式使用您的类型成员,然后它应该停止抱怨.
要在代码中使用UsedImplicitlyAttribute,您应该包含对JetBrains.Annotations.dll的引用或在项目中包含一些复制粘贴的源代码,请参阅http://www.jetbrains.com/resharper/webhelp/Code_Analysis__Annotations_in_Source_Code.html详情.
您应该在每个枚举值上添加[UsedImplicitly].