diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 49bc09a8..c4559ec4 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -76,6 +76,7 @@ Agents discover servers from #file:'.mcp.json'; these are only hints on when to * When casting sequence items use `Seq.cast` instead of `Seq.map (fun item -> item :> TargetType)`. * When concatenating two sequences or lists, prefer `seq { yield! xs; yield! ys }` (or `[ yield! xs; yield! ys ]` for lists) over the `@` operator or `Seq.append`. * When pipe operators are used on a materializable collection multiple times in a row, prefer `Seq` module for the chain and materialize at the end. +* Keep a pipeline in harmony: when consecutive steps can come from one module, take them from that module, the conversion at the end included – `xs |> Seq.filter isValid |> Seq.sort |> Seq.toArray`, not `… |> Seq.sort |> Array.ofSeq`, and `items |> List.map _.Id |> List.toArray`, not `… |> Array.ofList`. Change the module only where the steps that follow need the other collection. ### Functions, Lambdas and Strings diff --git a/tests/Cosmos.Tests/IterationExtensionsTests.fs b/tests/Cosmos.Tests/IterationExtensionsTests.fs index 352cd7d2..eac66657 100644 --- a/tests/Cosmos.Tests/IterationExtensionsTests.fs +++ b/tests/Cosmos.Tests/IterationExtensionsTests.fs @@ -33,7 +33,7 @@ type IterationExtensionsIntegrationTests () = Assert.HasCount (2, iteratedItems, "FeedIterator.AsAsyncEnumerable should return exactly the seeded items.") CollectionAssert.AreEquivalent ( expectedIds, - iteratedItems |> List.map _.id |> Array.ofList, + iteratedItems |> List.map _.id |> List.toArray, "FeedIterator.AsAsyncEnumerable should iterate seeded items without duplicates or omissions." ) } @@ -59,7 +59,7 @@ type IterationExtensionsIntegrationTests () = Assert.HasCount (2, iteratedItems, "IQueryable.AsAsyncEnumerable should return exactly the seeded items.") CollectionAssert.AreEquivalent ( expectedIds, - iteratedItems |> List.map _.id |> Array.ofList, + iteratedItems |> List.map _.id |> List.toArray, "IQueryable.AsAsyncEnumerable should iterate seeded items without duplicates or omissions." ) }