Skip to content

[Proposal]: Change return types of methods that return List<> to IEnumerable<> #8

@MechWarrior99

Description

@MechWarrior99

Summary

Change the return type of methods that return List<> to IEnumerable<>.

Motivation

Manipulating the lists that returns from the methods have no effect on the actual BMesh, as such there is really no reason you ever should or would need to add/remove items to the List<>s. It also does not clearly communicate the purpose and use of the returned collection when it is a List<>.
Where as IEnumerable<> more clearly communicates the intent behind the method.
Returning a List<> does not follow the C# design guidelines. An added benefit of returning IEnumerable<> is that the methods can make uses of yield return for potentially slightly better performance.

Drawbacks

This is a breaking changing if people use any of the List<> methods such as Add() Remove() or Contains(), or for people that declare the variable type when assigning the returned value List<Edge> edges = vertex.NeighborEdges().

Alternatives

One option is to return IReadOnlyList<> instead so people still have access to the indexer and Count property. However this makes it less generic and can no longer use yield return.

I would be happy to make a PR for this change if desired after any further discussion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions