You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We’ve run into an issue in Hangfire versions 1.8.15 and higher, where the CultureInfo settings for worker threads are being modified unexpectedly. Specifically, the PercentDecimalDigits and NumberDecimalDigits properties are altered from their default values (2) to 3, even when the current culture is explicitly set to en-US or another culture where these values are typically 2. This is being seen when a decimal with 4 digits of precision is run through value.ToString("N"). On 1.8.14 and lower, this resulted in 2 digits of precision on the string. Now it appears to be 3.
This behavior is not present in Hangfire version 1.8.14 and below, where the culture settings remain consistent with the application’s global culture configuration.
I can circumvent this by explicitly setting a culture, however I'm wondering if this is a known issue, or if there's a more appropriate way to resolve.
public class SetCultureFilter : IServerFilter
{
public void OnPerforming(PerformingContext context)
{
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;
}
public void OnPerformed(PerformedContext context)
{
}
}
The text was updated successfully, but these errors were encountered:
Thanks for reporting this! There was a change in 1.8.15 that caused Hangfire to use CultureInfo.GetCultureInfo method instead of creating a CultureInfo instances based on its constructor. However, their semantics are different, because GetCultureInfo does not respect user-overridden values set on the OS level:
We’ve run into an issue in Hangfire versions 1.8.15 and higher, where the CultureInfo settings for worker threads are being modified unexpectedly. Specifically, the PercentDecimalDigits and NumberDecimalDigits properties are altered from their default values (2) to 3, even when the current culture is explicitly set to en-US or another culture where these values are typically 2. This is being seen when a decimal with 4 digits of precision is run through value.ToString("N"). On 1.8.14 and lower, this resulted in 2 digits of precision on the string. Now it appears to be 3.
This behavior is not present in Hangfire version 1.8.14 and below, where the culture settings remain consistent with the application’s global culture configuration.
I can circumvent this by explicitly setting a culture, however I'm wondering if this is a known issue, or if there's a more appropriate way to resolve.
The text was updated successfully, but these errors were encountered: