Hello @m-gallesio, and thank you for reporting this to us.
Could you please provide us with a minimal code reproducer that uses system libraries?
I used my colleague’s example from the post you linked above, and S1172 does not raise for me as well.
Which MSBuild version do you use to build the project?
I am using Visual Studio 2022 with the default .NET 7.0 SDK.
After some more testing, I found out this problem only happens for private methods:
using System.Collections.Generic;
using System.Linq;
namespace Test;
public class Test
{
private void BuildSectionPrivate(
IReadOnlyDictionary<int, string> items, // <- triggers the rule
IEnumerable<int> values
)
{
var groups = values.Select(items.GetValueOrDefault);
}
public void BuildSectionPublic(
IReadOnlyDictionary<int, string> items, // <- does not trigger the rule
IEnumerable<int> values
)
{
var groups = values.Select(items.GetValueOrDefault);
}
}
I noticed that the FP is only raised when the parameter is used as a method group specifically in a private method. For example, if we change GetValueOrDefault for ContainsKey it’s not raised anymore.