refactor(binder): rename complex AsOptional to AsOptionalReference - #180
Merged
Conversation
ComplexPropertyConverter.AsOptional was constrained `where TProperty : class` and returned an OptionalReferenceField — the reference-optional semantics the scalar side already exposes as AsOptionalReference. Under the name AsOptional it was a dead end: a future value-type variant could not reuse the name (two methods differing only by a class vs struct constraint do not overload, CS0111), forcing an inconsistent third name or a breaking rename after the API freeze. Rename it to AsOptionalReference, matching the scalar AsOptionalReference / AsOptionalValue split and keeping AsOptionalValue free for a future value-type nested object. The three list converters' AsOptional are intentionally left alone: they are `notnull` and mean "absent list binds an empty list", with no reference/value split to disambiguate. The library is 0.1.0-preview.1 with no published consumers, so the rename is free now and needs no ADR. Updated the call sites (all in tests) and the binder reference docs (EN + FR). Refs: #146 Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015HzQtszd156kmTp86rfsQR
Reefact
force-pushed
the
claude/issue-146-rename-asoptionalreference
branch
from
July 18, 2026 11:57
173265b to
9ca2d94
Compare
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
Rename the reference-constrained
ComplexProperty.AsOptionaltoAsOptionalReference(issue #146, request binder review finding 10/19), matching the scalar side and keepingAsOptionalValuefree for a future value-type nested object — a free rename now, while the library is0.1.0-preview.1with no published consumers.Type of change
Changes
ComplexPropertyConverter.AsOptional— constrainedwhere TProperty : class, returningOptionalReferenceField<T>— toAsOptionalReference, matching the scalarAsOptionalReference/AsOptionalValuesplit, and update its XML doc. Under the old name a future value-type variant could not reuseAsOptional(two methods differing only by aclassvsstructconstraint do not overload, CS0111).ComplexPropertyBindingTests,BookingEndToEndTests,BindingContractTests.RequestBinder.en.md+RequestBinder.fr.md).AsOptionalare intentionally left unchanged: they arenotnulland mean "an absent list binds an empty list", with no reference/value split to disambiguate — so they carry no CS0111 dead end.Testing
dotnet build FirstClassErrors.slndotnet test FirstClassErrors.slnFirstClassErrors.Analyzers.UnitTests)Full suite green: 980 tests, 0 failures, 0 warnings.
Documentation
doc/updated (RequestBinder.en.md)RequestBinder.fr.md)Architecture decisions
Proposed: ADR-____Per the maintainer's call: the library is
0.1.0-preview.1, so this pre-preview naming alignment needs no ADR.Related issues
Closes #146
Generated by Claude Code