Delete Option extensions and tests that nothing else depends on#38
Closed
Delete Option extensions and tests that nothing else depends on#38
Conversation
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>
Owner
Author
|
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. |
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.
Follow-up to #36. Strips everything Option-related that isn't actually load-bearing.
Option<T>itself stays becauseTry_Oldstill exposesOption<TSuccess>/Option<TError>on its public surface and everyCoproduct_Oldproperty returnsOption<T>— a full migration offOptionhas to wait untilTryandCoproductget 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()returningOption<V>; only consumer wasDictionaryTests_Old.Library (trimmed in place):
IEnumerableExtensions_Options_Oldkeeps onlyFlatten<IEnumerable<Option<T>>>(used byTry_Old.Aggregate).SafeMax/SafeMin/First/Last/SingleOptiononIEnumerable<T>gone — only _Old tests called them.IEnumerableExtensions_ReadOnlyList_OldlosesSingleOption/FirstOption/LastOption. The non-Option helpers (IsMultiple,Single,First,Second…Fifth,Last,ElementAt,IndexOf) stay.ObjectExtensions_Generic_Oldloses.As<A>()and bothToOption<A>overloads.object as Ais the modern substitute forAs<A>;ToOptionis redundant given Maybe.Option_Old.True/False/Unitnow useOption.Valued(...)directly instead of the deletedvalue.ToOption()extension..GetOrDefault()/.ToOption()call sites inside_Old(IEnumerableExtensions_Emptiness_Old,IEnumerableExtensions_Try_Old) now useOption.Valued(...)/option.Valuedirectly.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_OldandINonEmptyEnumerable_Old/Option_CreateAndCreateFlatTests_Old.IEnumerableExtensionsTests_Olddrops theFirstOptioncase;PartitionMatchandAggregatetests stay withOption.Valuedreplacing.ToOption().NonEmptyStringEqualityTests_OlddropsOptionEqualityTest; the non-OptionEqualityTeststays as the only dedicated coverage ofNonEmptyString's equality operators.OptionAssert_Oldkept but slimmed to three methods — still needed byExceptionsAggregateTests_Old,AsNonEmptyTests_Old,NonEmptyEnumerableTypeIssuesTests_Oldwhich assert overOption<T>results from non-deleted APIs.Numbers
Interaction with #36
Independent. The #36
maybe-typebranch removed the Option-returningSafeMax/SafeMinoverloads fromIEnumerableExtensions_Options_Oldto 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