Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions release-notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Release notes:

1.0.0
- fixes: TaskSeq.insertAt, insertManyAt, removeAt, removeManyAt, updateAt now raise ArgumentNullException (not NullReferenceException) when given a null source; insertManyAt also validates the values argument
- refactor: simplify lengthBy and lengthBeforeMax to use while! and remove the redundant mutable 'go' and initial MoveNextAsync
- adds TaskSeq.distinctUntilChangedWith and TaskSeq.distinctUntilChangedWithAsync, #345
- adds TaskSeq.withCancellation, #167
Expand Down
12 changes: 12 additions & 0 deletions src/FSharp.Control.TaskSeq.Test/TaskSeq.InsertAt.Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ open FSharp.Control
exception SideEffectPastEnd of string

module EmptySeq =
[<Fact>]
let ``Null source is invalid`` () =
assertNullArg <| fun () -> TaskSeq.insertAt 0 99 null

assertNullArg
<| fun () -> TaskSeq.insertManyAt 0 TaskSeq.empty null

[<Fact>]
let ``Null values argument is invalid for insertManyAt`` () =
assertNullArg
<| fun () -> TaskSeq.insertManyAt 0 null (TaskSeq.ofList [ 1 ])

[<Theory; ClassData(typeof<TestEmptyVariants>)>]
let ``TaskSeq-insertAt(0) on empty input returns singleton`` variant =
Gen.getEmptyVariant variant
Expand Down
6 changes: 6 additions & 0 deletions src/FSharp.Control.TaskSeq.Test/TaskSeq.RemoveAt.Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ open FSharp.Control
exception SideEffectPastEnd of string

module EmptySeq =
[<Fact>]
let ``Null source is invalid`` () =
assertNullArg <| fun () -> TaskSeq.removeAt 0 null

assertNullArg <| fun () -> TaskSeq.removeManyAt 0 1 null

[<Theory; ClassData(typeof<TestEmptyVariants>)>]
let ``TaskSeq-removeAt(0) on empty input raises`` variant =
fun () ->
Expand Down
3 changes: 3 additions & 0 deletions src/FSharp.Control.TaskSeq.Test/TaskSeq.UpdateAt.Tests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ open FSharp.Control
exception SideEffectPastEnd of string

module EmptySeq =
[<Fact>]
let ``Null source is invalid`` () = assertNullArg <| fun () -> TaskSeq.updateAt 0 99 null

[<Theory; ClassData(typeof<TestEmptyVariants>)>]
let ``TaskSeq-updateAt(0) on empty input should throw ArgumentException`` variant =
fun () ->
Expand Down
9 changes: 9 additions & 0 deletions src/FSharp.Control.TaskSeq/TaskSeqInternal.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1369,6 +1369,12 @@ module internal TaskSeqInternal =

/// InsertAt or InsertManyAt
let insertAt index valueOrValues (source: TaskSeq<_>) =
checkNonNull (nameof source) source

match valueOrValues with
| Many values -> checkNonNull "values" values
| One _ -> ()

raiseCannotBeNegative (nameof index) index

taskSeq {
Expand All @@ -1394,6 +1400,7 @@ module internal TaskSeqInternal =
}

let removeAt index (source: TaskSeq<'T>) =
checkNonNull (nameof source) source
raiseCannotBeNegative (nameof index) index

taskSeq {
Expand All @@ -1411,6 +1418,7 @@ module internal TaskSeqInternal =
}

let removeManyAt index count (source: TaskSeq<'T>) =
checkNonNull (nameof source) source
raiseCannotBeNegative (nameof index) index

taskSeq {
Expand All @@ -1429,6 +1437,7 @@ module internal TaskSeqInternal =
}

let updateAt index value (source: TaskSeq<'T>) =
checkNonNull (nameof source) source
raiseCannotBeNegative (nameof index) index

taskSeq {
Expand Down
Loading