Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Feature Requests
 automatic delegate head

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
blq Posted - Jul 15 2008 : 12:32:22 PM
Hi,
Consider this case (C#):
myObject.OnMyEvent += delegate(..*automatic argument decl here!*)
Would it be possible for the intellisense to detect the signature of "OnMyEvent" and automatically insert the appropriate type+name arguments header when writing "delegate"?

Regards
// Fredrik
7   L A T E S T    R E P L I E S    (Newest First)
scottbilas Posted - Feb 17 2009 : 11:45:22 AM
Add my vote to this feature as well. I use delegates quite a bit for small event handlers so I can do things inline. Only when they get bigger, or needing to be near the setup code isn't an issue will I move them out to a full separate function.

Would be awesome if I could just go "Loaded += delegate TAB" and have it stick the correct param types and names and an empty function block. Same as if it were an out-of-line function that VAX does now.
blq Posted - Aug 25 2008 : 11:53:59 AM
I'm using VS2005 & VS2008 on WinXP Pro, VAX 1647. As said, I don't get any suggestions on parameter names inside a delegate.

Thanks for looking into this.

P.S Sorry for the extreeemly slow answer, during my vacation I simply forgot about this thread.
feline Posted - Jul 25 2008 : 4:19:26 PM
This is an interesting idea. I have put in a feature request for VA to suggest / insert the correct parameters for the anonymous method:

case=18740

So far I am not seeing any problems with the parameters not being suggested. They are suggested quite happily for me in my tests.

Can you tell me which IDE and version of VA you are using, and also post a code sample that shows the problem you are seeing?
blq Posted - Jul 21 2008 : 07:33:33 AM
No, my case/example wasnt intended to be specific. Could have been 'OnIncomingFax', 'OnDoorOpen' etc. Point was that you currently dont get any int.sense, i.e a perfect case for VA enhancement :) If nothing else the second case I mentioned about no param detection inside a delegate could be addressed.
//Fredrik
feline Posted - Jul 18 2008 : 1:38:15 PM
What IDE are you using?
What type is the variable "myButton"?

I am not seeing any sign of "OnClick" in VS2005 for the standard type "Button".

Turning to the code, how common are the parameters object sender, EventArgs arg? Off the top of my head all of the examples I see tend to look like this. You could simply define a VA snippet for this. In fact Uniwares has posted a possible snippet here:

http://forum.wholetomato.com/forum/topic.asp?TOPIC_ID=7953
blq Posted - Jul 16 2008 : 8:04:57 PM
A comparison with C# 1 and C# 2.0 should clarify I hope:

* Here's how you "traditionally" connect an eventhandler in C# 1:
myButton.OnClick += new ClickEventHandler(m_clickHandlerMethod); 
...
m_clickHandlerMethod(object sender, EventArgs arg)
{
    MessageBox.Show("Clicked");
}
----------
* In C# 2.0, with the advent of anonymous methods, you can now write the above like this:
myButton.OnClick += delegate(object sender, EventArgs arg) 
{
    MessageBox.Show("Clicked");
};
----------
Only the first, "traditional", case above is handled by VS default intellisense. As soon as you write "+=" it suggest the correct "new ClickEventHandler(m_clickHandlerMethod)" code and even offers to create the "m_clickHandlerMethod(object sender, EventArgs arg)" stub.
But, in the C# 2.0 case we sadly don't get any help with generating the argument list. My idea is that as soon as I've written "+= delegate" the appropriate arguments should be offered by VA-intellisense (i.e "delegate(object sender, EventArgs arg) { .. }" ).

- Secondly, it also seems like neither VS nor VA intellisense senses the arguments once I'm writing code inside the anonymous method. In the example above the intellisense doesn't offer to insert "sender" or "arg" when writing "se" or "ar" for example as it would have done in an ordinary method arguments. (If I spell them out fully it will find members inside the argument-objects correctly though).

(See here for examples regarding C# 2.0 delegates etc http://msdn.microsoft.com/en-us/magazine/cc163970.aspx)

Hope the above makes sense. I think this would be a great addition, since nowadays I (and I assume other people too) are using anonoymous methods/delegates (they're actually closures too) more and more.

Regards
// Fredrik
feline Posted - Jul 16 2008 : 2:38:02 PM
I do not really understand. Are you asking for a listbox showing class members that would be valid parameters for this function call?

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