2017-08-04 28 views
0

我是NDpend的新客户,所以请原谅我的问题是愚蠢的...我希望有一个规则,当我有一个构造函数显示我有一个特定的行码。考虑这个例子NDpend CQLinq信号代码规则

public StatusViewModel 
{ 
    this.userService = ServiceLocator.Default.ResolveType<IUserService>(); 
} 

这可能吗?考虑到我有它在构造函数中定义,并需要有一个参考ServiceLocator.Default.ResolveType

感谢

回答

1

如果要强制执行的构造函数访问

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