csharp_style_prefer_method_group_conversion / IDE0200 not working correctly in Visual Studio 17.8.3

117 Views Asked by At

I have a single .editorconfig placed in the root of the solution and added as a solution item with the following content:

[*.cs]
...
dotnet_style_prefer_collection_expression = true:suggestion
csharp_style_prefer_method_group_conversion = false:suggestion

Then I have 2 pieces of code with 2 IDE suggestions in the error list:

internal delegate int GetRowsCountDelegate();
...
int[] array = new int[] { 1, 2, 3 }; // Use collection expression for array (IDE0300)
GetRowsCountDelegate getRowsCount =
    () => rowsDeletedParameter.Value.As<int>(); // Remove unnecessary lambda expression (IDE0200)

I understand where the first one comes from: the first setting in the .editorconfig enables it. By changing it to false:suggestion and seeing the suggestion go away I can verify that Visual Studio knows about and makes use of my .editorconfig.

The second warning is what the question is about. The .editorconfig tells to NOT prefer method groups over lambdas, but VS still gives me a suggestion nevertheless.

I know I can fix it on the place with a #pragma warning disable or via SuppressMessageAttribute, but I don't want to do it every single time I'm writing a lambda.

So I'm basically asking if I'm overlooking something or maybe there is someone else who also encountered it, so I can confirm it's a VS bug and provide feedback on it.

Remove unnecessary lambda expression (IDE0200) MSDN

0

There are 0 best solutions below