Jef*_*hao 6 c# resharper static-analysis
在我们的代码中,我们有自己的注入框架来启用依赖注入,例如:
public class MyClass {
[Component("ComponentName1")] // means [NotNull]
public MyType NotNullComponent{ get; set; }
[OptionalComponent("ComponentName2")] // means [CanBeNull]
public MyType CanBeNullComponent { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我们不希望再次添加[CanBeNull]或[NotNull]在任何地方添加,因为它具有[Component]与[OptionalComponent]属性重复的语义.
是否有可能让Resharper知道自定义属性的语义来帮助进行静态分析?
现在,您可以通过在“代码检查”->“设置”中启用“隐式”,在所有内容上隐式使用 [NotNull]
除非您指定 [CanBeNull],否则所有内容都将被假定不允许为 null。
| 归档时间: |
|
| 查看次数: |
1220 次 |
| 最近记录: |