{"record":{"id":"e76529382f7b019d","repo":"stride3d/stride","slug":"expecting-value-1","errorCode":null,"errorMessage":"Expecting value >= 1","messagePattern":"Expecting value >= 1","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core/Diagnostics/ProgressStatusEventArgs.cs","lineNumber":32,"sourceCode":"    public ProgressStatusEventArgs(string message)\n    {\n        ArgumentNullException.ThrowIfNull(message);\n        Message = message;\n        StepCount = 1;\n        HasKnownSteps = false;\n    }\n\n    /// <summary>\n    /// Initializes a new instance of the <see cref=\"ProgressStatusEventArgs\"/> class.\n    /// </summary>\n    /// <param name=\"message\">The message.</param>\n    /// <param name=\"currentStep\">The current step.</param>\n    /// <param name=\"stepCount\">The step count.</param>\n    public ProgressStatusEventArgs(string message, int currentStep, int stepCount)\n    {\n        ArgumentNullException.ThrowIfNull(message);\n        if (currentStep < 0) throw new ArgumentOutOfRangeException(nameof(currentStep), \"Expecting value >= 0\");\n        if (stepCount < 1) throw new ArgumentOutOfRangeException(nameof(stepCount), \"Expecting value >= 1\");\n        Message = message;\n        CurrentStep = currentStep;\n        StepCount = stepCount;\n        HasKnownSteps = true;\n    }\n\n    /// <summary>\n    /// Gets or sets the message associated with the progress.\n    /// </summary>\n    /// <value>The message.</value>\n    public string Message { get; }\n\n    /// <summary>\n    /// Gets or sets a value indicating whether this instance has known steps (<see cref=\"CurrentStep\"/> and \n    /// <see cref=\"StepCount\"/> are valid).\n    /// </summary>\n    /// <value><c>true</c> if this instance has known steps; otherwise, <c>false</c>.</value>\n    public bool HasKnownSteps { get; }","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core/Diagnostics/ProgressStatusEventArgs.cs#L14-L50","documentation":"The same ProgressStatusEventArgs constructor requires stepCount >= 1 when step-based progress is used; passing 0 or a negative stepCount throws ArgumentOutOfRangeException('Expecting value >= 1'). A stepCount < 1 would make percentage computation (currentStep/stepCount) undefined.","triggerScenarios":"new ProgressStatusEventArgs(msg, current, 0) — e.g. total computed from an empty collection's Count, or a division/parse result of zero.","commonSituations":"Progress over an empty work list (total = items.Count == 0); config-driven total that defaults to 0; using 0 to mean 'indeterminate' — that is only valid for stepCount when it stays >= 1 or via the message-only path.","solutions":["Pass a positive total; skip the event when the work list is empty","Compute stepCount as Math.Max(1, total) only when work exists, otherwise don't fire the event","Use the indeterminate-progress path (no steps) instead of stepCount = 0"],"exampleFix":"// before\nnew ProgressStatusEventArgs(\"Loading\", i, items.Count); // 0 when empty\n// after\nif (items.Count > 0)\n    new ProgressStatusEventArgs(\"Loading\", i, items.Count);","handlingStrategy":"validation","validationCode":"if (items.Count > 0)\n    OnProgress(new ProgressStatusEventArgs(message, i, items.Count));","typeGuard":"bool isValidStepCount(int total) => total >= 1;","tryCatchPattern":"try { return new ProgressStatusEventArgs(msg, current, total); }\ncatch (ArgumentOutOfRangeException) { return new ProgressStatusEventArgs(msg, current, Math.Max(1, total)); }","preventionTips":["Skip progress events for empty work sets","Never use 0 as 'indeterminate' stepCount; use the message-only path","Validate totals parsed from config before use"],"tags":["progress","argumentoutofrange","events","validation"],"backgroundTag":"argument-out-of-range","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}