Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Feature Requests
 Generate ctors

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
Uniwares Posted - Nov 12 2008 : 11:52:46 AM
Just realized that there is no way to generate ctors for a class (C#/C++), although there are some other add-ins out there that do it.

Would be a really nice feature to be able to create ctors depending on properties and base classes

example:
public class someBase
{
  public someBase(int val)
  { ... }
}
public class someClass : someBase
{
  private String _memberName;
}


creating the ctors for someClass could allow to create the following:

public class someClass : someBase
{
  private String _memberName;

  public someClass(int val) : base(val)
  {}

  public someClass(String memberName, int val) : base(val)
  { 
    _memberName = memberName; 
  }
}


Sure it gets a bit hairy when you have multiple base classes (C++ and C# 4.0 ?) but I am sure that this can be solved too.
2   L A T E S T    R E P L I E S    (Newest First)
Uniwares Posted - Nov 16 2008 : 1:00:31 PM
For the most part the mapping of parameters can be done automatically, not too hard; at least for C# and single inheritance C++, multiple inheritance gets more complicated but even then its not THAT impossible.

I think that VA could generate a list of possible ctors, from the parameters required by the base and the properties existing in the class. Then simply select the ones needed.
Or as a quick and dirty way to do the most common used, offer them as context menu entries.

context menu -> VA Refactor -> Implement Contructor -> list of ctors for class under caret

Spinning the thread further, one could even imagine recursive ctors (add new properties and then implement the ctors in the current class + base class(es) passing the properties down to them)

Some of the addins on codeplex offer quite nice features already on that. But they are mostly too unhandy or redundant to VA overall to actually use them.
accord Posted - Nov 16 2008 : 11:08:02 AM
How do you imagine this feature? First, you fill in the parameters. But the second step can be difficult. One possible solution is that you select the parameters to pass to the base class. Another solution is to pair up the parameters, but there can be more then one possible solution, if there are more constructors in the base class.

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000