I found myself today refactoring a bit of code that looked like this
while (reader.MoveToNextAttribute())
{
if (reader.Name == "tuid")
_translationUnitId = reader.Value;
else if (reader.Name == "o-encoding")
_originalEncoding = Encoding.GetEncoding((reader.Value));
else if (reader.Name == "datatype")
_dataType = reader.Value;
...and so on
the issue with this code is that it assigns values directly to fields, whereas I needed to refactor it to assign to properties, that had validation logic in setters.
In case like this it would be nice if ReSharper could change calls to fields that have properties to calls to its properties.
I'd see 4 new refactorings here:
1. when cursor is on assigment to/from field with respectively setter/getter (or both) "Access field via property" - would substitute call to field with call to property
2. when cursor is on assigment to/from field with either setter/getter (or both) "Access everywhere via property" - would substitute ALL direct calls to field with property
3. when cursor is on a block of code with assigments to/from fields with respectively setter/getter (or both)" "Access fields via properties" - would give an option of selecting for which fields a user want to substitute direct calls with calls through properties.
4. when cursor is on a block of code with assigments to/from fields with respectively setter/getter (or both)" "Access fields everywhere via properties" - would give an option of selecting for which fields a user want to substitute direct calls with calls through properties. And change ALL calls, not only those within this block of code.
Thank you