Skip to content

Delete Option extensions and tests that nothing else depends on#38

Closed
KaliCZ wants to merge 1 commit intomainfrom
remove-option-legacy
Closed

Delete Option extensions and tests that nothing else depends on#38
KaliCZ wants to merge 1 commit intomainfrom
remove-option-legacy

Conversation

@KaliCZ
Copy link
Copy Markdown
Owner

@KaliCZ KaliCZ commented Apr 19, 2026

Follow-up to #36. Strips everything Option-related that isn't actually load-bearing. Option<T> itself stays because Try_Old still exposes Option<TSuccess>/Option<TError> on its public surface and every Coproduct_Old property returns Option<T> — a full migration off Option has to wait until Try and Coproduct get rewritten.

What got deleted

Library:

  • src/StrongTypes/Option_Old/IOptionExtensions_Old.cs — the whole user-facing extension surface (Map/FlatMap/Select/SelectMany/Where/Is/GetOr*/OrElse/Flatten/ToNullable/MapAsync/FlatMapAsync/MatchAsync/ToTry).
  • src/StrongTypes/Option_Old/IOptionExtensions_CollectionsFlattening_Old.cs.
  • src/StrongTypes/Option_Old/IOptionExtensions_CollectionsGetting_Old.cs — whole file was already [Obsolete].
  • src/StrongTypes/Extensions_Old/IReadOnlyDictionaryExtensions_Old.cs.Get() returning Option<V>; only consumer was DictionaryTests_Old.

Library (trimmed in place):

  • IEnumerableExtensions_Options_Old keeps only Flatten<IEnumerable<Option<T>>> (used by Try_Old.Aggregate). SafeMax/SafeMin/First/Last/SingleOption on IEnumerable<T> gone — only _Old tests called them.
  • IEnumerableExtensions_ReadOnlyList_Old loses SingleOption/FirstOption/LastOption. The non-Option helpers (IsMultiple, Single, First, SecondFifth, Last, ElementAt, IndexOf) stay.
  • ObjectExtensions_Generic_Old loses .As<A>() and both ToOption<A> overloads. object as A is the modern substitute for As<A>; ToOption is redundant given Maybe.
  • Option_Old.True/False/Unit now use Option.Valued(...) directly instead of the deleted value.ToOption() extension.
  • Two small .GetOrDefault()/.ToOption() call sites inside _Old (IEnumerableExtensions_Emptiness_Old, IEnumerableExtensions_Try_Old) now use Option.Valued(...) / option.Value directly.

Tests:

  • Options_Old/ in full (22 files).
  • Dictionary_Old/DictionaryTests_Old.cs (tested a deleted extension).
  • Generative_Old/OptionGenerators_Old, OptionShrinkers_Old, Shrinkers_Old (Shrinkers only exposed OptionShrinkers), GeneratorHelpers_Old (SometimesEmpty + unused ToList).
  • Collections_Old/First/Last/Single/FlattenTests_Old and INonEmptyEnumerable_Old/Option_CreateAndCreateFlatTests_Old.
  • IEnumerableExtensionsTests_Old drops the FirstOption case; PartitionMatch and Aggregate tests stay with Option.Valued replacing .ToOption().
  • NonEmptyStringEqualityTests_Old drops OptionEqualityTest; the non-Option EqualityTest stays as the only dedicated coverage of NonEmptyString's equality operators.
  • OptionAssert_Old kept but slimmed to three methods — still needed by ExceptionsAggregateTests_Old, AsNonEmptyTests_Old, NonEmptyEnumerableTypeIssuesTests_Old which assert over Option<T> results from non-deleted APIs.

Numbers

  • 4,700 lines deleted, 22 added.
  • Unit-test count: 716 → 365, all still passing. The deleted tests exercised code that no longer exists.

Interaction with #36

Independent. The #36 maybe-type branch removed the Option-returning SafeMax/SafeMin overloads from IEnumerableExtensions_Options_Old to clear the collision with Maybe's replacements — this PR deletes the same two methods (plus much more). Whichever merges first, the other rebases cleanly onto the result.

Test plan

  • Full build clean (0 warnings, 0 errors).
  • Unit tests green (365/365).
  • CI pipeline green (monitoring).

Option<T> itself stays — Try_Old and Coproduct_Old still expose it in
their public surface (Try.Success/Error are Option<T>; every
Coproduct_Old property returns Option<T>). A full migration off Option
has to wait until Try and Coproduct are rewritten.

Deleted from the library:
 - src/StrongTypes/Option_Old/IOptionExtensions_Old.cs — Map/FlatMap
   extensions, Select/SelectMany, Where/Is, GetOr* family, OrElse,
   Flatten, ToNullable, MapAsync/FlatMapAsync/MatchAsync, ToTry.
 - src/StrongTypes/Option_Old/IOptionExtensions_CollectionsFlattening_Old.cs
 - src/StrongTypes/Option_Old/IOptionExtensions_CollectionsGetting_Old.cs
   (whole file was already marked obsolete).
 - src/StrongTypes/Extensions_Old/IReadOnlyDictionaryExtensions_Old.cs —
   .Get() returning Option; only consumer was DictionaryTests_Old.

Trimmed in place:
 - IEnumerableExtensions_Options_Old keeps only Flatten<IEnumerable<Option<T>>>,
   which Try_Old.Aggregate still uses. SafeMax/SafeMin and First/Last/
   SingleOption on IEnumerable<T> were only consumed by Options_Old tests.
 - IEnumerableExtensions_ReadOnlyList_Old loses SingleOption/FirstOption/
   LastOption. The non-Option helpers (IsMultiple/IsSingle/Single/First/
   Second/…/Last/ElementAt/IndexOf) stay.
 - ObjectExtensions_Generic_Old loses .As<A>() and both ToOption<A>
   overloads. `object as A` is the modern substitute for As<A>; ToOption
   is redundant now that Maybe ships, and nothing else in the library
   called them.
 - Option_Old's own True/False/Unit constants stop going through
   value.ToOption() (now deleted) and use Option.Valued directly.
 - IEnumerableExtensions_Emptiness_Old.AsNonEmpty on an INonEmptyEnumerable
   and IEnumerableExtensions_Try_Old.Partition use Option's internal
   members directly (Option.Valued, option.Value) instead of the deleted
   extension methods.

Tests deleted:
 - Options_Old/ in its entirety (all 22 files).
 - OptionAssert_Old kept but slimmed — still needed by
   ExceptionsAggregateTests_Old, AsNonEmptyTests_Old, and
   NonEmptyEnumerableTypeIssuesTests_Old, which assert against Option
   results from Aggregate/AsNonEmpty.
 - Dictionary_Old/DictionaryTests_Old (tested the dict extension that's gone).
 - Generative_Old/OptionGenerators_Old + OptionShrinkers_Old +
   Shrinkers_Old (Shrinkers only exposed OptionShrinkers) +
   GeneratorHelpers_Old (SometimesEmpty for Option + unused ToList).
 - Collections_Old/First/Last/Single/FlattenTests_Old and
   INonEmptyEnumerable_Old/Option_CreateAndCreateFlatTests_Old.
 - IEnumerableExtensionsTests_Old drops the FirstOption case; PartitionMatch
   and the Aggregate-over-exceptions tests stay with Option.Valued in place
   of the deleted .ToOption() extension.
 - NonEmptyStringEqualityTests_Old loses OptionEqualityTest; the non-Option
   EqualityTest stays as the only dedicated coverage of NonEmptyString's
   equality operators.

Net: 4,700 lines deleted, 22 added; unit-test count drops from 716 →
365 (all still passing) — the deleted tests exercised code that no
longer exists.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@KaliCZ KaliCZ self-assigned this Apr 19, 2026
@KaliCZ
Copy link
Copy Markdown
Owner Author

KaliCZ commented Apr 19, 2026

Closing for now — this cleanup only makes sense once Try and Coproduct have Result and OneOf replacements. Until then Option's extensions are borderline useless but the type itself still needs to stay as Try/Coproduct surface, which leaves an awkward middle state.

@KaliCZ KaliCZ closed this Apr 19, 2026
@KaliCZ KaliCZ deleted the remove-option-legacy branch April 19, 2026 17:38
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