epitka
epitka

Reputation: 17637

Resharper - private vs backing field

Is there a way to tell R# to apply different naming strategy for property backing fields (_camelCase) vs class instance fields (camelCase)?

Reason: I want my dependencies to be named just a any other variable. Especially if the type of the field is the same as the field name. For example

private readonly MetaService metaService;

Upvotes: 0

Views: 369

Answers (2)

Robert Harvey
Robert Harvey

Reputation: 180787

The naming convention for a property backing field should be the same as that for a class instance field. The only difference between the two is that one can be manipulated or accessed from the outside.

If you feel the need to make a distinction, add a comment.

Upvotes: 1

John Saunders
John Saunders

Reputation: 161773

No, I don't know of a way to do this.

Frankly, I don't understand the distinction.

  1. A private instance field may later be used as the backing field for a property. Would you then feel it necessary to change the name of that field?
  2. The property may become disused and may then be removed. Do you then want to rename the field? It would no longer be a backing field.

Upvotes: 2

Related Questions