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

RCS1235 results into recursive call #1053

Closed
nvmkpk opened this issue Mar 15, 2023 · 0 comments · Fixed by #1054
Closed

RCS1235 results into recursive call #1053

nvmkpk opened this issue Mar 15, 2023 · 0 comments · Fixed by #1054
Assignees

Comments

@nvmkpk
Copy link

nvmkpk commented Mar 15, 2023

Product and Version Used:
Visual studio extension version 4.2.0

Steps to Reproduce:
Define code like below:

class MyCollection : Collection<Class1>
{
    public void Add(Class2 item)
    {
        this.Add(item.ToClass1()));
    }

    public void AddRange(IEnumerable<Class2> data)
    {
        foreach (var item in data)
        {
            this.Add(item); // RCS1235 is reported here
        }
    }
}

Actual Behavior:
No RCS1235 should be reported (but does not report this on RemoveRange implementation.

Expected Behavior:
Below refactor is suggested but it results into recursive call.

class MyCollection : Collection<Class1>
{
    public void Add(Class2 item)
    {
        this.Add(item.ToClass1()));
    }

    public void AddRange(IEnumerable<Class2> data)
    {
        this.AddRange(data); // Recursive call
    }
}
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