ReSharper

ReSharper 4.5 complains about my private fields.

I just downloaded ReSharper 4.5.  I probably will blog more about my experience with it.

The first thing I noticed after upgrading to R# 4.5 is that I got a lot of complains (blue underlines) about my naming of non public fields. 

RS_privateFields

Like many developers I like to prefix my private variables with an underscore.  I know for the fact that I’m not alone that what Jeff Prosie says:

As a matter of personal preference, I typically prefix the names of private fields with an underscore (for example, _connection).  When I read the code back after a time away, this makes it obvious to me which fields are not intended for public consumption.  This conventions is used quite a lot in the .NET Framework – for example, in System.NET.HttpWebRequest and System.Web.HttpContext – but it is not used throughout.

Next thing I did is to check what controls this blue lines.  I went to ReSharper/Options/Naming Style.

RS_NamingStyle_Dialog

To satisfy my naming style I click on Edit button to open an Edit “Instance fields (non public)” Rule Settings… window and typed an underscore (_) in Name Prefix text box:

RS_privateFields_Fixed 

After modifying “Instance fields (not public)” rule, ReSharper will not complain when we  add underscore to our private, internal, and protected fields.  But what if we want this rule for private fields only.  Well, in this case we need to define our own rule.  Naming Style window has two list boxes, the second one (User defined naming rules) allows us to define our own rule.

RS_ExstendedNamingRule

kick it on DotNetKicks.com

2 thoughts on “ReSharper 4.5 complains about my private fields.

Leave a comment