Anonymous method signature is never used


In the above code block, ReSharper warns "Anonymous method signature is never
used" on the arguments to the anonymous delegate. Though technically that's
correct, there's nothing you can do about it if you're implementing a delegate,
so I think the warning is incorrect.


7 comments
Comment actions Permalink

Hello Gerrod,

actually, ReSharper is right, as you can write simply


Regards,
Dmitry Shaporenkov
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

 EventHandler handler = delegate(object sender, EventArgs args) {
> // do something that doesn't use sender or args
> };
> ]]>

In the above code block, ReSharper warns "Anonymous method signature
is never used" on the arguments to the anonymous delegate. Though
technically that's correct, there's nothing you can do about it if
you're implementing a delegate, so I think the warning is incorrect.



0
Comment actions Permalink

Cool, I didn't know that! Thanks!

Lucky I checked in the forums before lodging a bug report :)

Hello Gerrod,

actually, ReSharper is right, as you can write simply

 EventHandler handler = delegate {
> // do something that doesn't use sender or args
> };
> ]]>

Regards,
Dmitry Shaporenkov
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

>>

> EventHandler handler = delegate(object sender, EventArgs args) {
>> // do something that doesn't use sender or args
>> };
>> ]]>

>> In the above code block, ReSharper warns "Anonymous method signature
>> is never used" on the arguments to the anonymous delegate. Though
>> technically that's correct, there's nothing you can do about it if
>> you're implementing a delegate, so I think the warning is incorrect.


0
Comment actions Permalink

IMO this warning is useless. Moreover the code produced by ReSharper's Ctrl-Shift-Space
when delegate is expected is immediately highlighted. Not good IMO. I suggest
to drop the warning.

Valentin Kipiatkov
Chief Scientist, Vice President of Product Development
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

Hello Gerrod,

actually, ReSharper is right, as you can write simply

 EventHandler handler = delegate {
> // do something that doesn't use sender or args
> };
> ]]>

Regards,
Dmitry Shaporenkov
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

>>

> EventHandler handler = delegate(object sender, EventArgs args) {
>> // do something that doesn't use sender or args
>> };
>> ]]>

>> In the above code block, ReSharper warns "Anonymous method signature
>> is never used" on the arguments to the anonymous delegate. Though
>> technically that's correct, there's nothing you can do about it if
>> you're implementing a delegate, so I think the warning is incorrect.


0
Comment actions Permalink

I think the warning is fair enough, given that there is a more concise way
of implementing the delegate. The trouble is not knowing what that more concise
way is.

I can understand resharper generating the code WITH the arguments though
- if you use the arguments in your implementation then the warning will go
away.

Maybe the warning should be more suggestive, e.g. it should somehow suggest
you remove the parameters since you're not using them?

IMO this warning is useless. Moreover the code produced by ReSharper's
Ctrl-Shift-Space when delegate is expected is immediately highlighted.
Not good IMO. I suggest to drop the warning.

Valentin Kipiatkov
Chief Scientist, Vice President of Product Development
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

>> Hello Gerrod,
>>
>> actually, ReSharper is right, as you can write simply
>>
>>

> EventHandler handler = delegate {
>> // do something that doesn't use sender or args
>> };
>> ]]>

>> Regards,
>> Dmitry Shaporenkov
>> JetBrains, Inc
>> http://www.jetbrains.com
>> "Develop with pleasure!"
>>>

>> EventHandler handler = delegate(object sender, EventArgs args) {
>>> // do something that doesn't use sender or args
>>> };
>>> ]]>

>>> In the above code block, ReSharper warns "Anonymous method signature
>>> is never used" on the arguments to the anonymous delegate. Though
>>> technically that's correct, there's nothing you can do about it if
>>> you're implementing a delegate, so I think the warning is incorrect.


0
Comment actions Permalink

Hello Valentin,

I don't see why it's any more useless than other similar warnings. As to
CtrlShiftSpace, why can't it produce a more concise code?


Regards,
Dmitry Shaporenkov
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

IMO this warning is useless. Moreover the code produced by ReSharper's
Ctrl-Shift-Space when delegate is expected is immediately highlighted.
Not good IMO. I suggest to drop the warning.

Valentin Kipiatkov
Chief Scientist, Vice President of Product Development
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

>> Hello Gerrod,
>>
>> actually, ReSharper is right, as you can write simply
>>
>>

> EventHandler handler = delegate {
>> // do something that doesn't use sender or args
>> };
>> ]]>

>> Regards,
>> Dmitry Shaporenkov
>> JetBrains, Inc
>> http://www.jetbrains.com
>> "Develop with pleasure!"
>>>

>> EventHandler handler = delegate(object sender, EventArgs args) {
>>> // do something that doesn't use sender or args
>>> };
>>> ]]>

>>> In the above code block, ReSharper warns "Anonymous method signature
>>> is never used" on the arguments to the anonymous delegate. Though
>>> technically that's correct, there's nothing you can do about it if
>>> you're implementing a delegate, so I think the warning is incorrect.


0
Comment actions Permalink

As
to CtrlShiftSpace, why can't it produce a more concise code?


What do you mean? What exactly should it produce?

Valentin Kipiatkov
Chief Scientist, Vice President of Product Development
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

Hello Valentin,

I don't see why it's any more useless than other similar warnings. As
to CtrlShiftSpace, why can't it produce a more concise code?

Regards,
Dmitry Shaporenkov
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

>> IMO this warning is useless. Moreover the code produced by
>> ReSharper's Ctrl-Shift-Space when delegate is expected is immediately
>> highlighted. Not good IMO. I suggest to drop the warning.
>>
>> Valentin Kipiatkov
>> Chief Scientist, Vice President of Product Development
>> JetBrains, Inc
>> http://www.jetbrains.com
>> "Develop with pleasure!"
>>> Hello Gerrod,
>>>
>>> actually, ReSharper is right, as you can write simply
>>>
>>>

>> EventHandler handler = delegate {
>>> // do something that doesn't use sender or args
>>> };
>>> ]]>

>>> Regards,
>>> Dmitry Shaporenkov
>>> JetBrains, Inc
>>> http://www.jetbrains.com
>>> "Develop with pleasure!"
>>>>

>>> EventHandler handler = delegate(object sender, EventArgs args) {
>>>> // do something that doesn't use sender or args
>>>> };
>>>> ]]>

>>>> In the above code block, ReSharper warns "Anonymous method
>>>> signature
>>>> is never used" on the arguments to the anonymous delegate. Though
>>>> technically that's correct, there's nothing you can do about it if
>>>> you're implementing a delegate, so I think the warning is
>>>> incorrect.


0
Comment actions Permalink

Maybe the warning should be more suggestive, e.g. it should somehow
suggest you remove the parameters since you're not using them?


We'll add a quickfix to do that.

Valentin Kipiatkov
Chief Scientist, Vice President of Product Development
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

I think the warning is fair enough, given that there is a more concise
way of implementing the delegate. The trouble is not knowing what that
more concise way is.

I can understand resharper generating the code WITH the arguments
though - if you use the arguments in your implementation then the
warning will go away.

Maybe the warning should be more suggestive, e.g. it should somehow
suggest you remove the parameters since you're not using them?

>> IMO this warning is useless. Moreover the code produced by
>> ReSharper's Ctrl-Shift-Space when delegate is expected is immediately
>> highlighted. Not good IMO. I suggest to drop the warning.
>>
>> Valentin Kipiatkov
>> Chief Scientist, Vice President of Product Development
>> JetBrains, Inc
>> http://www.jetbrains.com
>> "Develop with pleasure!"
>>> Hello Gerrod,
>>>
>>> actually, ReSharper is right, as you can write simply
>>>
>>>

>> EventHandler handler = delegate {
>>> // do something that doesn't use sender or args
>>> };
>>> ]]>

>>> Regards,
>>> Dmitry Shaporenkov
>>> JetBrains, Inc
>>> http://www.jetbrains.com
>>> "Develop with pleasure!"
>>>>

>>> EventHandler handler = delegate(object sender, EventArgs args) {
>>>> // do something that doesn't use sender or args
>>>> };
>>>> ]]>

>>>> In the above code block, ReSharper warns "Anonymous method
>>>> signature
>>>> is never used" on the arguments to the anonymous delegate. Though
>>>> technically that's correct, there's nothing you can do about it if
>>>> you're implementing a delegate, so I think the warning is
>>>> incorrect.


0

Please sign in to leave a comment.