Wednesday, August 5, 2009

Code Generation Popup

One feature I always wanted to have is the code generation pop up. I'm currently working on the refactoring part of MonoDevelop and I take the chance implementing the code generation popup.
This is a real time saver, if you know how to use it.
What can it do for you ? It can:
  • Create constructors and initialize members
  • Create properties
  • Create event OnXXX methods
  • Create ToString() method
  • Create Equals & HashCode
See the Quick Code Generation entry in the mono develop wiki for more details on that feature.

3 comments:

Dykam said...

Plans to provide a Threadsafety switch? To let the tool generate the repetive lock and lockroot objects for events.

Simon said...

@Dykam : Good idea

@Mike : Default implementation for some design patterns, for example particular Singleton/Multiton (maybe, many variants depending on needs such as thread safety). I know most patterns cannot be applied "as is" but supplying may variants for each could be still helpfull.

Dykam said...

Maybe better idea, make it easy to plug in your own edits. Make a simple template format, a.k.a. flashdevelop's code generation, which is currently:

ImplementHeader $(Boundary)\n\n/* INTERFACE {0} */
ImplementPart \n\n{0}$(CSLB){{\n\t{1}\n}}
Function {0}$(CSLB){{\n\t\n}}
Variable {0}$(EntryPoint);
Delegate {0} function {1}():{2} $(CSLB){{\n\t$(EntryPoint)\n}}
EventHandler {0} function {1}(event:{2}):{3} $(CSLB){{\n\t$(EntryPoint)\n}}
Getter {0} function get {1}():{2} $(CSLB){{\n\t$(EntryPoint)return {3};\n}}
Setter {0} function set {1}(value:{2}):{4} $(CSLB){{\n\t$(EntryPoint){3} = value;\n}}
MethodOverride ({0}):{1} $(CSLB){{\n\t$(EntryPoint){2}\n}}