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.
Please sign in to leave a comment.
Hello Gerrod,
actually, ReSharper is right, as you can write simply
Regards,
Dmitry Shaporenkov
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
Cool, I didn't know that! Thanks!
Lucky I checked in the forums before lodging a bug report :)
>>
> 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.
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!"
>>
> 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.
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?
>> 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.
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!"
>> 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.
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!"
>> 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.
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!"
>> 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.