xoofx / zio

A cross-platform abstract/virtual filesystem framework with many built-ins filesystems for .NET
BSD 2-Clause "Simplified" License
806 stars 61 forks source link

Why create a new enumerator type instead of returning collection? #56

Closed shmuelie closed 3 years ago

shmuelie commented 3 years ago

In the MemoryFileSystem, when enumerating paths, the contents of the SortedSet<UPath> are returned using a foreach with a yield instead of simply returning the SortedSet<UPath> itself. Any reason for this?

xoofx commented 3 years ago

Yes, that's because SortedSet<UPath> is valid for a single folder, and we can visit all folders:

https://github.com/xoofx/zio/blob/87c7172ff63f4fb4785af2f0437485be7043c80e/src/Zio/FileSystems/MemoryFileSystem.cs#L770

shmuelie commented 3 years ago

Ah yes, I missed where the loop was happening, thought it was outside the while. Thanks!