SOFAgh / CADability

CADability is a pure .net class library for modeling and analyzing 3d data, both with your code and interactively. It comes with an optional Windows.Forms user interface, which can be adopted to other environments. It does not refer to other 3d modeling libraries. For data exchange you can use STEP, STL or DXF files.
https://sofagh.github.io/CADability/CADabilityDoc/articles/general.html
MIT License
95 stars 33 forks source link

Simplify GetEnumerator #154

Closed stefan-tb closed 1 year ago

stefan-tb commented 1 year ago

This change will also avoid inconsistent behavior between the different Enumerator interfaces

SOFAgh commented 1 year ago

I don't think we can merge this: this iterator allows modification of the underlying list while iterating. If we use the underlying list iterator, this would not be possible. We would have to check the code, whether there is no iteration with modification. I know, it is not the standard behavior of iterators to allow changes, but I don't want to break existing code.

stefan-tb commented 1 year ago

Hmm. I see. But it then depends on the type of enumeration (IEnumerable<> or IEnumerable) if modification is allowed inside the enum loop or not? And simple foreaches become quite "expensive". The consumer can easily fix this by using foreach(var item in list.ToArray()) or so.

Anyway, Ill cancel the PR.