Refactoring
MonoDevelop has support for some refactoring operations.
Rename
The rename operation can be found in the context menu of the text editor when the item to rename is clicked or simply activated by the F2 (default settings) key.
In MonoDevelop when a refactoring changes more than just the current source file a preview dialog can be shown that contains all changes done by that refactoring:
The operations are shown as diffs (like in the version control dialog):
Extract Method
Extract method can be found in the context menu when selecting a part of the text.
Create Method
Create method creates a method definition out of a method call.
First write down your method call:
Open the context menu and select “Create method” gives you:
Create Class
Create class (or struct) is almost the same as CreateMethod. Just do a “new” operation and let MonoDevelop create the type (in a new file) for you.
Declare Local
Declare local declares a local variable out of an expression.
This function can really speed up development. First type the initializer for your local variable. See this example with “GetName()
”:
Now select “Declare Local” from the context menu or hit Control+^ (default key) which gives you a correct local variable declaration and selecting the name for you:
Introduce Constant
Introduce constant is a fast way to define a constant out of a magic number (or string).
See this example:
In this method a constant is used. Now this constant should be given a better name. Select the constant, open the context menu and hit “Introduce Constant”. A dialog appears where you could give the new constant a name. After you named the constant the source should look like:
Integrate Temporary Variable
[TODO]