Fix Seq.empty rendering as "EmptyEnumerable" in serializers#19317
Open
apoorvdarshan wants to merge 3 commits intodotnet:mainfrom
Open
Fix Seq.empty rendering as "EmptyEnumerable" in serializers#19317apoorvdarshan wants to merge 3 commits intodotnet:mainfrom
apoorvdarshan wants to merge 3 commits intodotnet:mainfrom
Conversation
Contributor
❗ Release notes required
|
901cdaf to
60f568f
Compare
Member
|
Please see #19322 (comment) . I think both are attempting the same thing, but we need to be a lot more cautious and pro-active in detecting breaking changes. |
…7864) Seq.empty used a custom DU type EmptyEnumerable<'T> that serializers detected as an F# union, rendering "EmptyEnumerable" instead of []. - Change Seq.empty to delegate to System.Linq.Enumerable.Empty<'T>() - Update concat optimization from :? EmptyEnumerable<'T> to :? ICollection<'T> when Count = 0 for broader empty detection - Add tests verifying Seq.empty is not a DU type and concat still works
bdc35a9 to
a1522ec
Compare
Author
|
@T-Gro Thanks for the feedback. Unlike #19322, this PR keeps the EmptyEnumerable type unchanged for backward compat — only the Seq.empty binding and the concat optimization are updated. Happy to target this for .NET 11 instead and add cross-compat test coverage for the equality/versioning scenarios you mentioned. |
3 tasks
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.
Summary
Fixes #17864
Seq.emptyused a custom DU typeEmptyEnumerable<'T>that serializers detected as an F# union, rendering"EmptyEnumerable"instead of[]Seq.emptyto delegate toSystem.Linq.Enumerable.Empty<'T>(), which returns a standard .NET typeSeq.concatoptimization from:? EmptyEnumerable<'T>to:? ICollection<'T> when Count = 0for broader empty collection detectionEmptyEnumerable<'T>type is kept unchanged for backward compatibilityTest plan
Seq.emptyis not a discriminated union type (FSharpType.IsUnionreturns false)Seq.concatwith empty elements still produces correct results