History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: RSRP-46928
Type: New Feature New Feature
Status: Open Open
Priority: Normal Normal
Assignee: Ilya Ryzhenkov
Reporter: Krzysztof Koźmic
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
ReSharper

Access field via property

Created: 07 Aug 07 14:51   Updated: 30 Aug 07 18:13
Component/s: Refactorings
Fix Version/s: Future Versions
Security Level: Everybody (All jira users)

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown


 Description  « Hide
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



 All   Comments   Work Log   Change History      Sort Order:
There are no comments yet on this issue.