I'm not sure of the cause, but I'm seeing this on net472 using alpha 53 and Microsoft.NETCore.App.Ref 3.0.0:
void M(IEnumerable<string?> values)
{
// CS8620 Argument of type 'StringComparer' cannot be used for parameter 'comparer' of type
// 'IEqualityComparer<string?>' in 'IEnumerable<string?> Enumerable.Distinct<string?>(
// IEnumerable<string?> source, IEqualityComparer<string?> comparer)' due to differences in
// the nullability of reference types.
// ↓
values.Distinct(StringComparer.CurrentCultureIgnoreCase);
}
StringComparer does in fact implement IEqualityComparer<string?>, not IEqualityComparer<string>. If I target netcoreapp3.0, the warning goes away.
I'm not sure of the cause, but I'm seeing this on net472 using alpha 53 and Microsoft.NETCore.App.Ref 3.0.0:
StringComparerdoes in fact implementIEqualityComparer<string?>, notIEqualityComparer<string>. If I targetnetcoreapp3.0, the warning goes away.