Sunday, March 18, 2018

.net - stylecop exclude event handlers from casing



I have just discovered sylecop and am running it through my projects, I have disabled certain rules such as usings must be within the namespace. However visual studio auto generated event handlers for say a button click are in the form btnOk_Click(....



This as I understand it doesn't conform to stylecop default settings as they should start with an upper case letter as with any method. But it has always appeared to be standard to me in code examples and so on. I am also used to this format for event handlers so is there a way to exclude event handlers from this validation but leave other methods being validated?


Answer



The problem you’ll find with StyleCop is that the rules are not entirely consistent with either the Visual Studio defaults or much of the Microsoft code you’ll find. You’ve really only got two options with StyleCop:




  1. Turn rules off as you’ve already

    mentioned

  2. Write your own rules



Unfortunately there is no mechanism in the current version of StyleCop to make rules conditional.


No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...