Reach the last element, apply the alpha, seed the nested sources - #10
Merged
Conversation
Another sweep of the same family of bugs as the inclusive integer ranges, taken now because 6.0 already breaks the sequences once. Off by one: RandomStringSource never used the last character of its allowed set, UrlSource never used the last top level domain. Both indexed with Random.Next(0, length - 1). Exclusive maximum: ColorSource, RandomTextSource and RandomUtfTextSource used Random.Next(min, max), so a channel range of 0 to 255 never gave 255 and a text source asked for 3 to 6 paragraphs never gave 6. ColorSource dropped the alpha of SetColorRange(alpha, ...) because it called Color.FromArgb(r, g, b); every colour came back opaque. Nested sources: UrlSource builds its host with a RandomStringSource that kept the default seed, so UseSeed and CreateSession(limit, seed) changed only the top level domain and every session produced the same hosts. That is a hole in the seed guarantee of 6.0. ExtendedEmailAddressSource passed one seed to both its name sources, so first and last name followed the same draws and repeated the same pairs. NestedSource in Util derives a stream per nested source, in a session and standalone. TimeSpanSource stays broken on purpose, it needs a rewrite rather than a fix. 856 tests per framework. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A second sweep of the same family of bugs as the inclusive integer ranges in #9, taken now because 6.0 already breaks the generated sequences once. Doing it after the release would cost a second break in 6.1.
Off by one
RandomStringSourcenever used the last character of its allowed set,UrlSourcenever used the last top level domain. Both indexed withRandom.Next(0, length - 1).Exclusive maximum
ColorSource,RandomTextSourceandRandomUtfTextSourceusedRandom.Next(min, max), sonew ColorSource(0, 255)never produced 255 and a text source asked for 3 to 6 paragraphs never produced 6.Dropped alpha
ColorSourcecalledColor.FromArgb(r, g, b), so the alpha ofSetColorRange(alpha, ...)was silently discarded and every colour came back opaque.Nested sources ignored the seed
The one that matters most.
UrlSourcebuilds its host with a nestedRandomStringSourcethat kept the default seed, so the session seed reached only the top level domain:That is a hole in the headline seed feature of 6.0.
ExtendedEmailAddressSourcepassed one seed to both its name sources, so first and last name followed the same sequence of draws and repeated the same pairs (Daniel.Knighttwice in the first ten).NestedSourceinUtilnow derives a stream per nested source, inside a session and standalone, so both paths agree.Not in here
TimeSpanSourceis broken (maxTicks - minTicksoverflowslongon the default range, andwhile (ticks < Min) ticks *= Random.Next(1, 3)can spin onticks == 0). It needs a rewrite with its own contract decision, not a one line fix, so it stays parked.DoubleSource's infinite default range stays parked too;NumberSource<double>is the answer there.Verification
dotnet build -c Releasezero warnings, 856 tests per framework on net8/9/10, 2568 total, all green. The stable sequences ofRandomStringSource,UrlSourceandExtendedEmailAddressSourcechanged and were regenerated; eleven new tests pin the fixed behaviour.🤖 Generated with Claude Code