Switched names to match with AV1738.#45
Conversation
|
Actually, it does follow that guideline, but it also adds the corresponding object involved. This is also how Visual Studio generates them, e.g. |
|
I did some testing and found that Visual Studio generates events like So I assumed that's the pattern you recommend. If you switched to a different pattern, that's fine too of course. I would just like to know your suggested naming convention to implement bkoelman/CSharpGuidelinesAnalyzer#32. (updated link to correct issue) |
|
Hmm, so my guideline works against Visual Studio and R#? |
AV1738 says: "It is good practice to prefix the method that handles an event with On. For example, a method that handles the Closing event can be named OnClosing."
|
I'm a bit lost on what's going on, actually. Whatever R# settings I specify in v2016.2.2 (Code Editing, C#, Naming Style, Advanced, Event subscriptions on fields/this), it always suggests the following while typing: this.Click += OnClick;
_okButton.Click += OkButtonOnClick;So it takes the target object (changing the format from _camelCase to PascalCase) + "On" + Event name. If the target object is In my last post I pointed to the wrong issue. It should be: bkoelman/CSharpGuidelinesAnalyzer#32. I believe the analyzer rule definition should be fine with the above. I've rebased this PR after merge conflicts. Feel free to let me know what's blocking you from accepting this PR. If time permits, I'll see how the latest EAP handles this at a later time... |
|
Hmm, I still disagree with the chance, but the fact that the tooling doesn't agree with me makes me doubt. |
|
Perhaps you misunderstood my point: Your example in AV1706 is contradicting with the text of your rule AV1738. I would be fine with any convention, but I just need clarity. So what exactly do you not agree about? |
|
Ah, then I prefer |
|
Thanks, I'll use that for now. We may want to revisit this topic at a later time once more people have had a chance to see how this works out in practice. |
AV1738 says: "It is good practice to prefix the method that handles an event with On. For example, a method that handles the Closing event can be named OnClosing."
Since the example in AV1706 refers to the Click event, its handler name should be something with "OnClick" in it.