Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Style cop says name of function/method should be start with Capital character(proper case)

I have given TextBox control name txtName.
On Keydown event I am doing some coding stuff.

So my event is like

C#
private void txtName_KeyDown(object sender, KeyEventArgs e)
       {
//      Coding  
        }



StyleCop consider it as Method and throw warning Mathod names begin with an upper case letter


if I put TextBox name like TextName
then StyleCop throw warning variable names must starts with a lower case letter

any suggestion is appreciated

:)
Posted

Khaniya wrote:
TextBox control name txtName

Khaniya wrote:
I put TextBox name like TextName

Stylecop is just forcing the rules that has been put into it as a coding standard.
Try:

1. textbox name as txtName and
2. textboxKeyDown event as TxtName_KeyDown
Just make sure, while binding the event, you use proper method name.

It's not necessary that you have to start your event name as your control name.
 
Share this answer
 
v2
Comments
Khaniya 10-Jun-10 3:24am    
Hi sandeep
Thanks for your reply
I know what you are saying but for that I have to chnage all events name manually
As in the above answer, Stylecop is just enforcing the ruleset that you are running against.

You can change the rules that it will run to ignore certain errors

http://blogs.msdn.com/b/sourceanalysis/archive/2008/05/25/enabling-or-disabling-source-analysis-rules.aspx[^]

I'm sure there's one you can change for this, I can't remember which one it is though, have a look through your rules
 
Share this answer
 
StyleCop is wasting your time. Just do it the way you want to, and get on with the project.
 
Share this answer
 
Comments
Sandeep Mewara 10-Jun-10 10:53am    
Actually he is wasting his time with StyleCop!
Khaniya 11-Jun-10 1:21am    
hi All
I thing it is not completely true
1) stylecop helps to improve coding style of beginner programmer and
2) It improves compilation perfomance
3) It helps to remove unnecessary code

So many others

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900