Using VS2010 and ReSharper 5
I have a method which returns a System.Action
private Action ExtractFile()
{
return delegate
{
MessageBox.Show("Test");
};
}
ReSharper, for some reason, tends to show me a correction that the return type of the method should be mapped to System.Action<T>
or one of its variants. It seems that it won't recognize the non-generic version! VS complies and doesn't complain about this!
When I mouse over the red curly line, the tooltip shown says
Incorrect number of type parameters.
Candidates are: void System.Action(T)
void System.Action(T1, T2) ...
... and the list continues until T1-T16
Any ideas?
Seems to me that you need to update ReSharper to the latest version, which is version 5.1. If you have items that are not loaded by ReSharper (i.e., check your excluded items list), then it will mark them as unknown, even if your code is legal and references the items.
You may try Clear Cache, or reset default settings.
Your screenshot did not show a curly line under "delegate", but with default settings it should suggest you to rewrite the code as follows (but this is not necessarily better):
private Action ExtractFile()
{
return () => MessageBox.Show("Test");
}
If all fails, click the little lightbulb on the left (or hit Alt+Enter). Select "Inspection options for ..." and change the severity or select ignore.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With