[219] QuickFix create local variable in anonymous delegate

Hi,

in the following code I use a variable errorText that is not defined.
Cursor is in variable (see "|").



public void ValidationHandlerIsCalled() {
int count = 0;

grid.ValidateCell += delegate(object sender, ValidateCellEventArgs e)
{
count++;
e.ErrorText = errorTe|xt;
}
}



The quick fix "Create local variable 'errorText' will create the
variable in the anonymous delegate, but I would like to have it one
level up in the method scope so that I can set the value outside of the
delegate.

I'm not sure if we need two quick fixes here, one to introduce the
variable, and one to move it up in scope?


Sincerely,
Stefan Lieser

1 comment
Comment actions Permalink

Put a good word for this request: http://www.intellij.net/tracker/resharper/viewSCR?publicId=5114
It's exactly what you're looking for.

\> Hi,


in the following code I use a variable errorText that is not defined.
Cursor is in variable (see "|").


public void ValidationHandlerIsCalled() {
int count = 0;
grid.ValidateCell += delegate(object sender, ValidateCellEventArgs
e)
{
count++;
e.ErrorText = errorTe|xt;
}
}
The quick fix "Create local variable 'errorText' will create the
variable in the anonymous delegate, but I would like to have it one
level up in the method scope so that I can set the value outside of
the delegate.

I'm not sure if we need two quick fixes here, one to introduce the
variable, and one to move it up in scope?

Sincerely,
Stefan Lieser



0

Please sign in to leave a comment.