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

Make fixer for CS0535 smarter when implementing IEnumerable<T> #67023

Closed
DoctorKrolic opened this issue Feb 23, 2023 · 3 comments · Fixed by #76044
Closed

Make fixer for CS0535 smarter when implementing IEnumerable<T> #67023

DoctorKrolic opened this issue Feb 23, 2023 · 3 comments · Fixed by #76044
Labels
Area-IDE Feature Request help wanted The issue is "up for grabs" - add a comment if you are interested in working on it
Milestone

Comments

@DoctorKrolic
Copy link
Contributor

DoctorKrolic commented Feb 23, 2023

Given code like:

class MyClass : IEnumerable<int>
{
    
}

Th fixer for CS0535 currently doesn't treat this case as some kind of special, so applying it just creates method declarations for non-implemented members:

using System.Collections;

class MyClass : IEnumerable<int>
{
    public IEnumerator<int> GetEnumerator()
    {
        throw new NotImplementedException();
    }

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

However, implementation for non-generic enumerator in 99.99% cases would be then changed by user to

IEnumerator IEnumerable.GetEnumerator()
{
    return GetEnumerator();
}

I think, considering that, fixer for CS0535 can be made smarter in this specific case and produce code like this in the first place:

using System.Collections;

class MyClass : IEnumerable<int>
{
    public IEnumerator<int> GetEnumerator()
    {
        throw new NotImplementedException();
    }

    IEnumerator IEnumerable.GetEnumerator()
    {
        return GetEnumerator();
    }
}
@jaredpar jaredpar added the untriaged Issues and PRs which have not yet been triaged by a lead label Feb 27, 2023
@mavasani mavasani added Need Design Review The end user experience design needs to be reviewed and approved. and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Oct 19, 2023
@mavasani mavasani added this to the 17.10 milestone Oct 19, 2023
@mavasani
Copy link
Contributor

Assigning to @CyrusNajmabadi to review/triage the feature request.

@CyrusNajmabadi
Copy link
Member

Yes. This would be nice to do.

@CyrusNajmabadi CyrusNajmabadi removed their assignment Oct 26, 2024
@CyrusNajmabadi CyrusNajmabadi added help wanted The issue is "up for grabs" - add a comment if you are interested in working on it and removed Need Design Review The end user experience design needs to be reviewed and approved. labels Oct 26, 2024
@CyrusNajmabadi CyrusNajmabadi modified the milestones: 17.10, Backlog Oct 26, 2024
@github-project-automation github-project-automation bot moved this to InQueue in Small Fixes Oct 26, 2024
@CyrusNajmabadi
Copy link
Member

We woudl take a targeted user pr here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Feature Request help wanted The issue is "up for grabs" - add a comment if you are interested in working on it
Projects
Status: Complete
Status: Completed
Development

Successfully merging a pull request may close this issue.

4 participants