feat(justdummies): guard public/internal arguments against null - #322
Merged
Conversation
Every public or internal member — constructor or method — now rejects a null non-nullable reference-type argument with an ArgumentNullException naming the parameter. The class, not the assembly, is the trust boundary: a member validates what crosses it (including the internal Create factories and constructors the public API can never route a null through), and trusts what a validating member already accepted, so a null fails fast instead of surfacing later as a NullReferenceException far from its cause. Exception-type constructors are exempt: they run on the error-handling and logging path, where throwing over a null message would mask the original failure. A reflection-driven convention test (NullArgumentGuardConventionTests) enforces this across the whole surface and holds new members to it automatically. Verifying the internal boundary requires internal access, so InternalsVisibleTo is opened to the contract suite, deliberately relaxing the previously black-box test posture. ReproduciblyAsync now validates its body synchronously rather than deferring the guard into the returned task. Decision recorded in ADR-0045 (Proposed). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KR3opZZYgSiomTKWvC11q8
The maintainer accepted the null-argument guard convention; flip ADR-0045 (and its French translation and the index) from Proposed to Accepted. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KR3opZZYgSiomTKWvC11q8
Reefact
pushed a commit
that referenced
this pull request
Jul 27, 2026
Reconcile the out-of-order-disposal fix with ADR-0045 (guard public and internal arguments against null), which landed on main via #322. * AmbientState constructor: main added a null guard on `random`; this branch added a `parent` parameter to the same constructor — keep both. * SeedScope: bring its new internal constructor under the same convention by guarding its non-nullable `frame` argument, matching the guard #322 applied to AmbientState. The reflection-driven NullArgumentGuardConventionTests added by #322 passes against the merged code.
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.
Summary
Every
public/internalmember ofJustDummiesnow rejects anullnon-nullable reference-type argument with anArgumentNullExceptionnaming the parameter, so anullfails fast at the boundary instead of surfacing later as aNullReferenceException. A reflection-driven convention test enforces this across the whole surface and holds new members to it automatically.Type of change
Changes
if (x is null) { throw new ArgumentNullException(nameof(x)); }) to everypublic/internalconstructor and method taking a non-nullable reference-type parameter, across all ofJustDummies.privatemembers are trusted (their inputs are guarded at thepublic/internalboundary they enter through, e.g. theCreate(RandomSource)factories); value-type and nullable (?) parameters are left as-is (a?parameter's contract permitsnull).nullmessage would mask the original failure.Any.ReproduciblyAsyncnow validatesbodysynchronously instead of deferring the guard into the returned task.NullArgumentGuardConventionTests: a reflection test that enumerates the wholepublic/internalsurface and asserts each non-nullable reference parameter throwsArgumentNullException; it covers new members automatically and fails loudly on any parameter it cannot exercise. Excluded from the net472 floor (it usesNullabilityInfoContext, a .NET 6+ API); the guards themselves remain netstandard2.0.InternalsVisibleTo) so the convention can verify the internal boundary the public API can never route anullthrough.Testing
dotnet build FirstClassErrors.sln— 0 warnings / 0 errors.dotnet test FirstClassErrors.sln— not run in full; the suites below were run instead.FirstClassErrors.Analyzers.UnitTests) — not run.Suites actually run (all green):
dotnet test JustDummies.UnitTests— 556 passed (including the new convention test).dotnet test JustDummies.PropertyTests— 220 passed.dotnet test FirstClassErrors.Testing.UnitTests— 8 passed (consumer via ADR-0026).dotnet test JustDummies.Xunit.UnitTests— 14 passed.EnableNet472Floor=true(JustDummies.UnitTests+JustDummies.PropertyTests) — 0 / 0.Documentation
asyncis an implementation detail).doc/updated — ADR-0045 added (EN + FR) and indexed.doc/handwritten/for-users/README.fr.md) — not needed (no user-facing README behavior change).Architecture decisions
InternalsVisibleTo, deliberately relaxing the previously black-box test posture recorded in the 2026-07-20 audit §9.3).Related issues
None.
🤖 Generated with Claude Code
https://claude.ai/code/session_01KR3opZZYgSiomTKWvC11q8
Generated by Claude Code