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
Rule S3242 triggers for types with indexer, base types of which don't have one. In case described below IList has indexer and ICollection doesn't.
Repro steps
public class Foo
{
public void MethodOne(IList list)
{
if (list.Count > 0)
{
Console.WriteLine(list[0]);
}
}
public void MethodTwo(IList<Foo> list)
{
if (list.Count > 0)
{
Console.WriteLine(list[0]);
}
}
}
Expected behavior
Rule should not trigger.
Actual behavior
Rule triggers with following messages:
For 'MethodOne':
"Consider using more general type 'System.Collections.ICollection' instead of 'System.Collections.IList'."
For 'MethodTwo':
"Consider using more general type 'System.Collections.Generic.ICollection<MyProject.Foo>' instead of 'System.Collections.Generic.IList<MyProject.Foo>'."
Related information
SonarC# Version: v6.2.0.2536
Visual Studio Version: VS2015, VS 2017
The text was updated successfully, but these errors were encountered:
Description
Rule S3242 triggers for types with indexer, base types of which don't have one. In case described below IList has indexer and ICollection doesn't.
Repro steps
Expected behavior
Rule should not trigger.
Actual behavior
Rule triggers with following messages:
For 'MethodOne':
For 'MethodTwo':
Related information
The text was updated successfully, but these errors were encountered: