Information
- OS: Ubuntu 24.04
- Version: main (current branch)
- Terminal: GNOME Terminal
Describe the issue
While exploring the progress API, I noticed that AddTask accepts a negative maxValue without any validation.
For example:
using Spectre.Console;
AnsiConsole.Progress()
.Start(ctx =>
{
var task = ctx.AddTask("Loading World Map", true, -1);
while (!ctx.IsFinished)
{
task.Increment(1);
Thread.Sleep(50);
}
});
The task completes immediately and the progress output appears inconsistent.
While looking through the implementation, I noticed that GetPercentage() explicitly handles MaxValue == 0, but there doesn't seem to be any validation preventing negative values from being passed.
I'm not sure whether accepting negative values is intentional or if they should be rejected (for example by throwing ArgumentOutOfRangeException).
Expected behavior
If negative MaxValue values are not supported, it might be better to validate the argument early instead of allowing the task to enter an inconsistent state.
If this is considered a bug and the proposed direction makes sense, I'd be happy to work on a PR.
Information
Describe the issue
While exploring the progress API, I noticed that
AddTaskaccepts a negativemaxValuewithout any validation.For example: