The coding standard in my organization is for private fields to be lowerCamelCase but backing fields used by properties to be prefixed with an underscore (_
). Is there a way to add a rule just for backing fields in the Resharper Naming Style tool.
Here's the Naming Rule Editor:
I'd rather this error not show up for local variables
Examples in VB and C#:
VB:
<!-- language: lang-vb -->Public Class Employee
'Should be lowerCamelCase
Private useCode As String = "NEW"
'should be _lowerCamelCase
Private _name As String
Public Property Name() As String
Get
Return _name
End Get
Set(ByVal value As String)
_name = value
End Set
End Property
End Class
C#:
<!-- language: lang-cs -->public class Employee
{
//Should be lowerCamelCase
private string useCode = "NEW";
//should be _lowerCamelCase
private string _name;
public string Name {
get { return _name; }
set { _name = value; }
}
}
Whether you agree or not with this naming convention, is there a way to ask reshaper to enforce this?