templates - 更改生成的代码 'Check if parameter is null'

标签 templates resharper

有没有办法更改 resharper 为上下文操作“检查参数是否为空”生成的代码。 我想将其更改为

if (item == null) throw new ArgumentNullException("item");

Contract.Requires(item != null)

最佳答案

我找到了the Reference "Add_Edit_Highlighting_Pattern" 。这似乎是唯一可以做到的方法。您生成默认代码,然后添加新的模式规则以将该代码更改为断言。您实际上无法更改原始生成的代码 - 或者看起来如此。

另一篇文章“From ArgumentException to CodeContracts using Resharper”中描述的过程

关于templates - 更改生成的代码 'Check if parameter is null',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8429295/

相关文章:

c++ - 在 resharper C++ 中检查 "Non-reclaimed resource acquisition"

混合模板类和模板方法时出现 C++ 错误

C++ 函数嵌套模板

c# - 为什么我不能引用我的类库?

visual-studio - Resharper "go to file"和 "go to implementation"功能的替代方案

visual-studio-2010 - 从 VS 2010 卸载 ReSharper 后上下文菜单项丢失

c# - d :DesignInstance with an interface type

c++ - 如何为STL容器指定模板函数?

c++ - 在递归模板中通过引用传递模板函数

django - 编写 eclipse 模板