MoaidHathot / Dumpify

Adding `.Dump()` extension methods to Console Applications, similar to LinqPad's.
MIT License
959 stars 40 forks source link

Support for progress bar #17

Open latop2604 opened 10 months ago

latop2604 commented 10 months ago

It would be very nice if this lib have an extensions method for enumerable that display a dynamic progressbar.

var list = new List<int> {1,2,3,4};
foreach(var i un list.WithProgess("Caption"))
{
    // Do slow stuff
}
MoaidHathot commented 10 months ago

Hi @latop2604, thanks for the suggestion! :)

"Live" controls are in my roadmap, but I think I'll need some time (and suggestions from the community) while tinkering with Progress Bars for Dumpify.

For example, IEnumerable<T> and IAsyncEnumerable<T> don't have a notion of Count, therefore I wouldn't be able to know the current status. Also, we could have infinite IEnumerable<T> and IAsyncEnumerable<T>, without us knowing about it beforehand. We could though implement it for everything ICollection<T> which does have a Count property, but ICollection<T> is not lazy, so I'm not sure that this feature is needed in that situation.

What do you think? :)

latop2604 commented 10 months ago

On my side I still use IEnumerable but throw when we don't have the size.

They are many ways to get it from an IEnumerable. They more or less listed in the linq Count extension method (see screenshot below).

We can aslo use the extension method TryGetNonEnumeratedCount. But only for net 6+

The concern I have for this feature is where the progressbar will be displayed. I'm used to LinqPad where you can have many progressbar active and you can scroll the view to see each of them. But I don't know if it's possible with spectre.

image

For not countable list or asyncenumerable we can use undeterminated state progressbar. But I don't see the value of having it.

MoaidHathot commented 10 months ago

Sorry for the delay in my response. Using a Progress Bar requires Live Display. Those are in the roadmap, I have a few ideas for Live Display as well, and your idea about Progress can be part of them. Let's discuss this Issue when we reach that point, I'm planning to do under the hood changes that will help us integrate Live Display.