我是 NDpend 的新客户,所以请原谅我的问题很愚蠢......我希望有一个规则来告诉我,当我有一个构造函数时,我有一个特定的代码行。考虑那个例子
public StatusViewModel
{
this.userService = ServiceLocator.Default.ResolveType<IUserService>();
}
可能吗?考虑到我要在构造函数中定义它并且需要引用 ServiceLocator.Default.ResolveType
谢谢
如果要强制构造函数正在访问
ServiceLocator.Default.ResolveType<IUserService>()
规则应该看起来像
warnif count > 0
from m in Application.Methods
where m.IsConstructor
&& !m.IsUsing("Microsoft.Practices.ServiceLocation.ServiceLocator.get_Default()")
&& !m.IsUsing("Microsoft.Practices.ServiceLocation.ServiceLocator.ResolveType<T>()")
select m