This project is read-only.

IndexOutOfRangeException in NumberProperty.InitializeNumberCharDictionary


An IndexOutOfRangeException is thrown on line 89 of NumberProperty.cs due to the fact that there are 2 identical ranges in the expectedRanges parameter from what appears to be a bug with clearing the cached 'range' state in StringFactory.
This unit test fails, highlighting the issue:
public void ChangingStringPropertiesResetsCachedStringFactoryState()
var properties = new StringProperties
        MinNumberOfCodePoints = 10,
        MaxNumberOfCodePoints = 30
var s1 = StringFactory.GenerateRandomString(properties, 1234);
properties = new StringProperties()
        MinNumberOfCodePoints = 10,
        MaxNumberOfCodePoints = 30,
        HasNumbers = true
s1 = StringFactory.GenerateRandomString(properties, 1234);
Moving the ranges.Clear() call in StringFactory.InitializeProperties before the conditional fixes this problem, since it appears to reset the chached state correctly.
However, I'd even say further the design of this class is suspect, since cached static state prevents any concurrency. Why is StringFactory static? Why not create a StringFactory per properties as an instance, which would allow the desired caching without the global state which causes these kinds of problems?