You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Wrong message about using IReadOnlyCollection interface instead of IReadOnlyList if collection items are accessed by index:
Consider using more general type 'System.Collections.Generic.IReadOnlyCollection' instead of 'System.Collections.Generic.IReadOnlyList'.
Repro steps
public static long ParseNonNegativeLong(this IReadOnlyList<string> arguments, int index, string name)
{
if (arguments == null || index < 0 || index >= arguments.Count)
throw new JobArgumentException(index, name);
if (!long.TryParse(arguments[index], out long result))
throw new JobArgumentException(index, name, "Expected number.");
return result;
}
Expected behavior
No message.
Actual behavior
There is the message from the analyzer:
Consider using more general type 'System.Collections.Generic.IReadOnlyCollection' instead of 'System.Collections.Generic.IReadOnlyList'.
Related information
SonarC# 6.4.1.3596
Visual Studio 15.3.5
The text was updated successfully, but these errors were encountered:
antrv
changed the title
Wrong message about using IReadOnlyCollection<T> interface instead of IReadOnlyList<T> if collection items is accessed by index
Wrong message about using IReadOnlyCollection<T> interface instead of IReadOnlyList<T> if collection items are accessed by index
Oct 9, 2017
Hi @antrv ,
Thanks for the feedback! This is indeed a wrong suggestion and we will try to fix it soon.
Evangelink
changed the title
Wrong message about using IReadOnlyCollection<T> interface instead of IReadOnlyList<T> if collection items are accessed by index
Fix S3242: Do not suggest IReadOnlyCollection<T> interface instead of IReadOnlyList<T> if collection items are accessed by index
Oct 13, 2017
Description
Wrong message about using IReadOnlyCollection interface instead of IReadOnlyList if collection items are accessed by index:
Consider using more general type 'System.Collections.Generic.IReadOnlyCollection' instead of 'System.Collections.Generic.IReadOnlyList'.
Repro steps
Expected behavior
No message.
Actual behavior
There is the message from the analyzer:
Consider using more general type 'System.Collections.Generic.IReadOnlyCollection' instead of 'System.Collections.Generic.IReadOnlyList'.
Related information
The text was updated successfully, but these errors were encountered: