From edb0820a7c920f9b9ffc13910a6f8d59133e953d Mon Sep 17 00:00:00 2001 From: XperiAndri Date: Sat, 10 Oct 2026 13:40:45 +0200 Subject: [PATCH 1/2] refactor: return voption and struct tuples from the collection functions FSharp.Core's Seq, List and Array functions that look an element up return an option, and zip returns reference tuples: one heap object per result. src/Shared/ValueCollections.fs shadows them with functions of the same names and meaning that return a voption or struct tuples: tryHead, tryLast, tryItem, tryExactlyOne, tryFind, tryFindBack, tryFindIndex, tryFindIndexBack, tryPick, whose chooser returns a voption too, and zip. Seq.zip is Enumerable.Zip. Every F# project under src and tests compiles the file first, through the root Directory.Build.props, and gets an internal copy. The module opens itself in the namespace FSharp.Azure.Cosmos, so the shadows are in effect in the code of that namespace and in every file that opens it, while a function that only FSharp.Core has resolves to it as before. A file in another namespace opens FSharp.Azure.Cosmos to get them, and so does one in a child namespace such as FSharp.Azure.Cosmos.Tests: a child namespace does not open the modules of its parent. The build project is left out, because its scripts were generated against the functions of FSharp.Core. The two places that used such a function follow: the first item of a feed page in Read.fs and a zip in the ExistsAsync concurrency test. Co-Authored-By: Claude Opus 5.5 --- Directory.Build.props | 10 + src/Cosmos/Read.fs | 4 +- src/Shared/ValueCollections.fs | 269 ++++++++++++++++++ .../FSharp.Azure.Cosmos.Tests.fsproj | 1 + tests/Cosmos.Tests/ReadExtensionsTests.fs | 2 +- tests/Cosmos.Tests/TestCategories.fs | 8 + tests/Cosmos.Tests/ValueCollectionsTests.fs | 237 +++++++++++++++ 7 files changed, 528 insertions(+), 3 deletions(-) create mode 100644 src/Shared/ValueCollections.fs create mode 100644 tests/Cosmos.Tests/ValueCollectionsTests.fs diff --git a/Directory.Build.props b/Directory.Build.props index c9619ce2..d1cdebeb 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -43,6 +43,16 @@ See https://learn.microsoft.com/en-us/visualstudio/msbuild/customize-by-director + + + + +