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 开发者_StackOverflow中文版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.
精彩评论