Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Feature Requests
 Generate ctors
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Uniwares
Tomato Guru

Portugal
2322 Posts

Posted - Nov 12 2008 :  11:52:46 AM  Show Profile  Reply with Quote
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.

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Nov 16 2008 :  11:08:02 AM  Show Profile  Reply with Quote
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.

Edited by - accord on Nov 16 2008 11:21:33 AM
Go to Top of Page

Uniwares
Tomato Guru

Portugal
2322 Posts

Posted - Nov 16 2008 :  1:00:31 PM  Show Profile  Reply with Quote
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.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000