Skip to content

Reach the last element, apply the alpha, seed the nested sources - #10

Merged
holonsoftFounder merged 1 commit into
mainfrom
feature/source-correctness
Sep 11, 2026
Merged

Reach the last element, apply the alpha, seed the nested sources#10
holonsoftFounder merged 1 commit into
mainfrom
feature/source-correctness

Conversation

@holonsoftFounder

Copy link
Copy Markdown
Member

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

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 new ColorSource(0, 255) never produced 255 and a text source asked for 3 to 6 paragraphs never produced 6.

Dropped alpha

ColorSource called Color.FromArgb(r, g, b), so the alpha of SetColorRange(alpha, ...) was silently discarded and every colour came back opaque.

Nested sources ignored the seed

The one that matters most. UrlSource builds its host with a nested RandomStringSource that kept the default seed, so the session seed reached only the top level domain:

before                             after
seed 1337:  www.pdutnrt.ua         www.varh.ua
seed 4711:  www.pdutnrt.am         www.mcwbaoetos.am
seed 99999: www.pdutnrt.es         www.cystzmfxq.es

That is a hole in the headline seed feature of 6.0. ExtendedEmailAddressSource passed one seed to both its name sources, so first and last name followed the same sequence of draws and repeated the same pairs (Daniel.Knight twice in the first ten). NestedSource in Util now derives a stream per nested source, inside a session and standalone, so both paths agree.

Not in here

TimeSpanSource is broken (maxTicks - minTicks overflows long on the default range, and while (ticks < Min) ticks *= Random.Next(1, 3) can spin on ticks == 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 Release zero warnings, 856 tests per framework on net8/9/10, 2568 total, all green. The stable sequences of RandomStringSource, UrlSource and ExtendedEmailAddressSource changed and were regenerated; eleven new tests pin the fixed behaviour.

🤖 Generated with Claude Code

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>
@holonsoftFounder
holonsoftFounder merged commit 19fe026 into main Sep 11, 2026
2 checks passed
@holonsoftFounder
holonsoftFounder deleted the feature/source-correctness branch September 11, 2026 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant