Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RCS1080 not being flagged for custom lists #983

Closed
dylanvdmerwe opened this issue Nov 10, 2022 · 0 comments · Fixed by #986
Closed

RCS1080 not being flagged for custom lists #983

dylanvdmerwe opened this issue Nov 10, 2022 · 0 comments · Fixed by #986

Comments

@dylanvdmerwe
Copy link

If you implement a class that inherits from List, RCS1080 does not get flagged when it should.

Product and Version Used:
Visual Studio 2022 17.4.0
Roslynator 2022 v4.1.2

Steps to Reproduce:

image

class Program
{
    static void Main(string[] args)
    {
        List<User> userList = new List<User>();
        UserCollection userCollection = new UserCollection();
        UserCollection2 userCollection2 = new UserCollection2();

        if (userList.Any())
        {
            Console.WriteLine("");
        }

        if (userCollection.Any())
        {
            Console.WriteLine("");
        }

        if (userCollection2.Any())
        {
            Console.WriteLine("");
        }
    }
}

public class UserCollection : List<User>
{

}

public class UserCollection2 : IList<User>
{
    public User this[int index] { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }

    public int Count => throw new NotImplementedException();

    public bool IsReadOnly => throw new NotImplementedException();

    public void Add(User item)
    {
        throw new NotImplementedException();
    }

    public void Clear()
    {
        throw new NotImplementedException();
    }

    public bool Contains(User item)
    {
        throw new NotImplementedException();
    }

    public void CopyTo(User[] array, int arrayIndex)
    {
        throw new NotImplementedException();
    }

    public IEnumerator<User> GetEnumerator()
    {
        throw new NotImplementedException();
    }

    public int IndexOf(User item)
    {
        throw new NotImplementedException();
    }

    public void Insert(int index, User item)
    {
        throw new NotImplementedException();
    }

    public bool Remove(User item)
    {
        throw new NotImplementedException();
    }

    public void RemoveAt(int index)
    {
        throw new NotImplementedException();
    }

    IEnumerator IEnumerable.GetEnumerator()
    {
        throw new NotImplementedException();
    }
}

public class User
{
    public string UserName { get; set; }    public string EmailAddress { get; set; }
}

There could be other analysers around list checks that I have not highlighted here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants