Skip to content
Open
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 docs/release-notes/.FSharp.Core/10.0.300.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Fix tuple/multi-value projections in queries to use Queryable.Select instead of Enumerable.Select when the source is IQueryable, preserving query composition and enabling async operations like ToListAsync() in Entity Framework Core. ([Issue #3782](https://github.com/dotnet/fsharp/issues/3782), [Issue #15133](https://github.com/dotnet/fsharp/issues/15133))
* Fix EvaluateQuotation to handle Sequential expressions, void method calls (unit return), and other patterns that were previously throwing NotSupportedException. Also properly handles unit-returning expressions by using Action delegates instead of Func delegates. ([Issue #19099](https://github.com/dotnet/fsharp/issues/19099))
* Fix query conditionals without else branch (if-then only) that were causing type mismatch errors. Now properly extracts element type from IQueryable for creating empty sequences. ([Issue #3445](https://github.com/dotnet/fsharp/issues/3445))
* Fix `Seq.empty` rendering as `"EmptyEnumerable"` in serializers by delegating to `System.Linq.Enumerable.Empty<'T>()` instead of using a custom DU type. ([Issue #17864](https://github.com/dotnet/fsharp/issues/17864), [PR #19317](https://github.com/dotnet/fsharp/pull/19317))

### Added

Expand Down
2 changes: 1 addition & 1 deletion src/FSharp.Core/seq.fs
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ module Seq =
mkUnfoldSeq generator state

[<CompiledName("Empty")>]
let empty<'T> = (EmptyEnumerable :> seq<'T>)
let empty<'T> = System.Linq.Enumerable.Empty<'T>()

[<CompiledName("InitializeInfinite")>]
let initInfinite initializer =
Expand Down
4 changes: 2 additions & 2 deletions src/FSharp.Core/seqcore.fs
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,9 @@ module RuntimeHelpers =
let rec takeOuter() =
if outerEnum.MoveNext() then
let ie = outerEnum.Current
// Optimization to detect the statically-allocated empty IEnumerables
// Optimization to detect empty IEnumerables without calling GetEnumerator
match box ie with
| :? EmptyEnumerable<'T> ->
| :? ICollection<'T> as c when c.Count = 0 ->
// This one is empty, just skip, don't call GetEnumerator, try again
takeOuter()
| _ ->
Expand Down
4 changes: 2 additions & 2 deletions tests/AheadOfTime/Trimming/check.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ function CheckTrim($root, $tfm, $outputfile, $expected_len, $callerLineNumber) {
$allErrors = @()

# Check net9.0 trimmed assemblies
$allErrors += CheckTrim -root "SelfContained_Trimming_Test" -tfm "net9.0" -outputfile "FSharp.Core.dll" -expected_len 311296 -callerLineNumber 66
$allErrors += CheckTrim -root "SelfContained_Trimming_Test" -tfm "net9.0" -outputfile "FSharp.Core.dll" -expected_len 310784 -callerLineNumber 66

# Check net9.0 trimmed assemblies with static linked FSharpCore
$allErrors += CheckTrim -root "StaticLinkedFSharpCore_Trimming_Test" -tfm "net9.0" -outputfile "StaticLinkedFSharpCore_Trimming_Test.dll" -expected_len 9169408 -callerLineNumber 69
$allErrors += CheckTrim -root "StaticLinkedFSharpCore_Trimming_Test" -tfm "net9.0" -outputfile "StaticLinkedFSharpCore_Trimming_Test.dll" -expected_len 9168384 -callerLineNumber 69

# Check net9.0 trimmed assemblies with F# metadata resources removed
$allErrors += CheckTrim -root "FSharpMetadataResource_Trimming_Test" -tfm "net9.0" -outputfile "FSharpMetadataResource_Trimming_Test.dll" -expected_len 7609344 -callerLineNumber 72
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1523,4 +1523,17 @@ type SeqModule() =

let choice = seq |> Seq.randomSampleBy (fun () -> 1.0) 0

Assert.AreEqual(0, choice |> Seq.length)
Assert.AreEqual(0, choice |> Seq.length)

[<Fact>]
member _.``Seq.empty is not a discriminated union type``() =
let empty = Seq.empty<int>
let ty = empty.GetType()
let isUnion = Microsoft.FSharp.Reflection.FSharpType.IsUnion(ty)
Assert.False(isUnion, "Seq.empty should not be a discriminated union type")

[<Fact>]
member _.``Seq.concat with empty elements works``() =
let result = Seq.concat [ Seq.empty; seq { 1; 2 }; Seq.empty; seq { 3 }; Seq.empty ]
let expected = [| 1; 2; 3 |]
Assert.AreEqual(expected, result |> Seq.toArray)
Loading