Build / Build (push) Successful in 33s
- Every number shown on a page goes through NumbersExtensions: counts, percentages, the nerd readouts and the values written into a style. - A failure the client builds itself (offline, timeout, retries run out, an answer it can't read) is a 400 that names its kind; only a server's own 5XX passes through. - Login, sign-up, recovery and password confirmations leave autocomplete to the browser, so it can offer the saved login. - The Daisy components start with empty lists and attributes, and a decorative image still renders alt="". - Arasaka.HouseRules.Analyzers checks all of this in every build, together with PrivaPub.ClientModels. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W4YtEJrgxG12Pc39Fai8Bd
34 lines
1.5 KiB
C#
34 lines
1.5 KiB
C#
using System.Globalization;
|
|
|
|
namespace decePubClient.Extensions;
|
|
|
|
public static class NumbersExtensions
|
|
{
|
|
public static string ToDefaultCount(this int value) => value.ToString("N0", CultureInfo.CurrentCulture);
|
|
|
|
public static string ToDefaultCount(this long value) => value.ToString("N0", CultureInfo.CurrentCulture);
|
|
|
|
public static string ToDefaultCount(this double value) => value.ToString("N0", CultureInfo.CurrentCulture);
|
|
|
|
public static string Compact(this int count) => count switch
|
|
{
|
|
< 1000 => count.ToString(CultureInfo.CurrentCulture),
|
|
< 10_000 => (count / 1000d).ToString("0.#", CultureInfo.CurrentCulture) + "k",
|
|
< 1_000_000 => (count / 1000).ToString(CultureInfo.CurrentCulture) + "k",
|
|
_ => (count / 1_000_000d).ToString("0.#", CultureInfo.CurrentCulture) + "M"
|
|
};
|
|
|
|
public static string ToDefaultPercent(this double percent) => percent.ToString("0.#", CultureInfo.CurrentCulture) + "%";
|
|
|
|
public static string ToWholePercent(this double percent) => percent.ToString("0", CultureInfo.CurrentCulture) + "%";
|
|
|
|
public static string ToSignedPercent(this double percent) => percent.ToString("+0.0;-0.0;0.0", CultureInfo.InvariantCulture) + "%";
|
|
|
|
public static string ToCssNumber(this double value) => value.ToString("0.#", CultureInfo.InvariantCulture);
|
|
|
|
public static string ToReadout(this double value) => value.ToString("0.###", CultureInfo.InvariantCulture);
|
|
|
|
public static string ToFixed(this double value, int decimals) =>
|
|
value.ToString("F" + decimals.ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture);
|
|
}
|