ReSharper的约定事件处理程序的名称 [英] ReSharper conventions for names of event handlers
问题描述
当我添加新的事件处理程序,任何情况下,VS创建像 object_Click
方法。
但ReSharper的强调这种方法为警告,因为所有的方法不应该有任何定界符,如_。
When I add new event handler for any event, VS creates method like object_Click
.
But ReSharper underlines this method as Warning, because all methods should not have any delimeters such as "_".
我如何自定义ReSharper的规则,以便它不强调这样的方法呢?或者,可能是我应该重命名这些方法?
How can I customize rules of ReSharper so that it doesn't underline such methods? Or may be I should rename such methods?
先谢谢了。
推荐答案
就个人而言,我建议重命名的方法。一般来说,我觉得VS自带了两个控制和事件可怕的名字。
Personally, I'd suggest renaming the methods. Generally I think VS comes up with terrible names for both controls and events.
我preFER使一个方法名说什么的确实的,不是调用它。促进重用为好。诚然,事件处理程序的签名往往是不理想的再利用 - 我要说的却是经常的lambda前pression调用一个方法,更合理的参数将是有益的:
I prefer to make a method name say what it does, not what calls it. That promotes reuse as well. Admittedly the signature of an event handler is often not ideal for reuse - I'd argue that often a lambda expression calling a method with more sensible parameters would be useful:
button.Click += (sender, args) => SaveCurrentDocument();
但显然设计者不支持:(
but obviously the designer doesn't support that :(
当然,重命名所有的方法将是更多的工作不仅仅是改变R#设置,如果你能找到一些工作......
Of course, renaming all the methods is going to be more work than just changing the R# settings, if you can find some that work...
这篇关于ReSharper的约定事件处理程序的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!