Conversation
…e-dashoffset Co-authored-by: thomhurst <30480171+thomhurst@users.noreply.github.com>
|
@copilot your image of the "fix" isn't right. The green would then account for an50% pass rate. And 25% is grey implying not run. |
…erted colors Co-authored-by: thomhurst <30480171+thomhurst@users.noreply.github.com>
You're right, the sign removal was wrong. The real root cause is locale-dependent decimal formatting — Fixed in 007ad90 by adding |
There was a problem hiding this comment.
Review: Fix inverted colors in HTML report ring chart due to locale-dependent decimal formatting
This is a correct and targeted fix for a genuine locale-sensitivity bug. The root cause analysis is accurate: ToString("F2") without CultureInfo.InvariantCulture produces comma as the decimal separator on many locales (e.g., Italian, French, German), which breaks SVG stroke-dasharray and stroke-dashoffset attribute parsing since SVG uses commas as value separators.
Correctness
The fix is correct. All five numeric formatting call sites that produce SVG/CSS attribute values are addressed:
passRate.ToString("F0", CultureInfo.InvariantCulture)— ring center percentage label (line 224)len.ToString("F2", CultureInfo.InvariantCulture)— stroke-dasharray segment length (line 256)(circumference - len).ToString("F2", CultureInfo.InvariantCulture)— stroke-dasharray gap (line 258)offset.ToString("F2", CultureInfo.InvariantCulture)— stroke-dashoffset (line 260)FormatDurationreturns viastring.Create(CultureInfo.InvariantCulture, ...)for all three branches (lines 372, 377, 380)
Minor Observations (not blocking)
1. FormatDuration — inconsistent approach vs. AppendRingSegment
The AppendRingSegment method uses .ToString("F2", CultureInfo.InvariantCulture) directly on double, while FormatDuration uses string.Create(CultureInfo.InvariantCulture, $"..."). Both are correct, but mixing styles across the same file is slightly inconsistent. For what it's worth, string.Create with an interpolated string handler avoids a format string allocation and is the more modern idiom — so if anything, the FormatDuration style is the better pattern.
2. FormatDuration output is used as display text, not SVG attribute values
The duration string is rendered inside an HTML <span> (line 243: sb.Append(FormatDuration(totalDurationMs))), not as an SVG numeric attribute. This means locale-dependent decimals here would not break SVG parsing — but they would cause visual inconsistency in the HTML text (e.g., "1,50s" vs "1.50s"), so fixing it here is still the right call for a consistent user experience.
3. Integer ToString() calls (lines 232–236) are locale-safe
The summary.Total.ToString(), summary.Passed.ToString(), etc. are integer types — ToString() on integers never uses a decimal separator, so these are safe to leave as-is.
4. passRate.ToString("F0", ...) — "F0" rounds to integer
"F0" produces no decimal point regardless of locale (it rounds to the nearest whole number), so the original passRate.ToString("F0") was already locale-safe. Adding CultureInfo.InvariantCulture here is harmless and makes the intent explicit, which is fine.
Summary
The fix is correct, minimal in scope, and directly addresses the reported bug. No unrelated changes are included. The approach is idiomatic for .NET locale-safe number formatting. Ready to merge.
|
@copilot failing pr checks |
…atDuration Co-authored-by: thomhurst <30480171+thomhurst@users.noreply.github.com>
Head branch was pushed to by a user without write access

The SVG ring chart in the HTML test report renders pass/fail segment colors in the wrong positions on systems using a non-English locale (e.g. Italian, French, German) where the decimal separator is a comma instead of a period.
Root cause:
ToString("F2")withoutCultureInfo.InvariantCultureproduces comma-separated decimals on non-English locales (e.g. Italian:254,47instead of254.47). SVG parsers interpret commas as value separators, so:stroke-dasharray="254,47 84,82"→ parsed as 4 values[254, 47, 84, 82]instead of 2stroke-dashoffset="-254,47"→ truncated to-254This causes the ring segments to render with completely wrong sizes and positions.
Fix: Added
CultureInfo.InvariantCultureto all numericToStringcalls that produce SVG/CSS attribute values, ensuring period decimal separators regardless of system locale. Also fixed theFormatDurationmethod for the same reason.Left: Bug (comma decimals from Italian locale) — ring segments broken. Right: Fix (period decimals) — green correctly covers 75%, red covers 25%.
Original prompt
💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.