[MonoDevelop] RefactoringCommands: Encapsulate Fields initial implementation

Miguel Ángel Pérez mangelp at gmail.com
Tue Apr 24 07:40:54 EDT 2007

Hello all!

I have been doing some coding with the encapsulate field command and i have
got an initial implementation that generates the code for the property and
changes the visibility for the field if its public or protected to private.

To do the code generation I've created an internal helper class named
CodeGeneratorHelper in the class CodeRefactorer (
Monodevelop.Ide.Projects.CodeGeneration namespace) that implements it.
I don't know if there is already some class that can generate CodeDom
namespace objects from an IMember so i have implemented something.

What i haven't done is renaming the references to the property, since is a
thing that Lluis must know better than nobody, can you suggest how it could
be done?

I've also done some changes to BaseRefactorer class to allow a parameter
with the buffer to modify so the change is done to the editor buffer instead
of the file in disk. This makes necessary to call the methods with an
unboxing instead of using the interface IRefactorer.
It's look like this class could be improved with changes like this that
helps in the operations needed to implement more refactoring commands.

I also did a change to avoid a null exception that i was getting when
creating a new property because a BodyRegion property was null.

Attached is the diff against svn 76173. file with my initial implementation.
Please Lluis and everyone review and comment about it.

-- Best regards --
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/monodevelop-list/attachments/20070424/0486219d/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: RefactorCommands-EncapsulateFields-initial.diff
Type: text/x-patch
Size: 21980 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/monodevelop-list/attachments/20070424/0486219d/attachment-0001.bin 

More information about the Monodevelop-list mailing list