mono/sharpen

Automatic convert setters and getters to properties

Opened this issue · 2 comments

Sharpen should have a feature which is able to automatic identify setters and getters and convert them to properties.

Following rules apply:

  • If a method name is starting with "get" or "is"; and it returns something; and it does not have any arguments then it is a getter
  • If a method name starts with "set" or "is"; and it does not return anything; and it accepts one argument then it is a setter
  • The property name will be a method name without leading "is", "get" or "set"

Agreed. That would be a great addition!

I would add 2 more conditions:

  1. Both Get and Set are of the same data type (before merging them into a single property)
  2. We don't do this for Set methods if they call external functions. Explicit Set methods are good for things that have side effects or throw exceptions.