Skip to content

Commit

Permalink
Guard.Range now uses invariant culture for error message
Browse files Browse the repository at this point in the history
  • Loading branch information
Driedas committed Oct 19, 2022
1 parent 6d6222f commit b505d89
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/OpenTelemetry.Api/Internal/Guard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

using System;
using System.Diagnostics;
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Threading;

Expand Down Expand Up @@ -198,7 +199,13 @@ private static void Range<T>(T value, string? paramName, T min, T max, string? m
{
var minMessage = minName != null ? $": {minName}" : string.Empty;
var maxMessage = maxName != null ? $": {maxName}" : string.Empty;
var exMessage = message ?? $"Must be in the range: [{min}{minMessage}, {max}{maxMessage}]";
var exMessage = message ?? string.Format(
CultureInfo.InvariantCulture,
"Must be in the range: [{0}{1}, {2}{3}]",
min,
minMessage,
max,
maxMessage);
throw new ArgumentOutOfRangeException(paramName, value, exMessage);
}
}
Expand Down

0 comments on commit b505d89

Please sign in to comment.