dotnet / roslynator

Roslynator is a set of code analysis tools for C#, powered by Roslyn.
https://josefpihrt.github.io/docs/roslynator
Other
3.06k stars 256 forks source link

"Expand property and add backing field" - Backing field name should match naming rule #91

Open richayrich opened 7 years ago

richayrich commented 7 years ago

Visual Studio allows backing fields to be named in a specific manner (Options -> Text Editor -> C# -> Code Style -> Naming -> Specification = Private or Internal field).

When using the "Expand property and add backing field" option, the backing field name should respect the naming convention defined from that menu.

This would match the rename functionality provided by VS itself (IDE1006), and essentially combine the two actions.

example: Private or Internal field specification is set to Prefix = "m_" with "camel Case Name". public Collection<MyClass> MyCollection { get; } = new Collection<MyClass>(); Use "Expand property and add backing field" action private Collection<MyClass> m_myCollection = new Collection<MyClass>(); public Collection<MyClass> MyCollection { get { return m_myCollection; } }

josefpihrt commented 7 years ago

As far as I know, it is not possible to access these code style settings from third party tools such as Roslynator.

jpozo20 commented 7 years ago

Actually, it's doable. Visual Studio provides the DTE object which lets you access the options on the Options dialog box.

See https://msdn.microsoft.com/en-us/library/bb165648(v=vs.140).aspx