Closed Hosch250 closed 8 years ago
Can you clarify with an example?
For example, suppose I have the following code:
public void Something()
{
_somethingElse.Event += (sender, e) =>
{
[...]
}
}
I'd like to be able to extract the content of that handler to a method with the signature provided just before the =>
operator. I don't want it to try to figure out the types--I'll just have to handle that, if necessary. Putting event handlers inline like that is a memory leak, and they can't ever be unsubscribed from, and in codebases with a lot of them, it would save arm-strain when handling the mouse (well, if your arm is already hurting).
Something like:
public void Something()
{
_somethingElse.Event += _somethingElseEventHandler;
}
private void _somethingElseEventHandler(object sender, EventArgs e)
{
[...]
}
It would probably be best for VSD if this was just an analyzer without a code fix--I'd just make a personal code-fix for myself.
So.. #591 ?
Oh, yeah.
This is basically going to be a sort of Extract Method. I'm not sure how we could handle the use of variables/parameters in the parent method--perhaps we should just ignore those?