Conversation
Implements the PreferOptionals static parameter for XmlProvider and JsonProvider, following the same pattern already used by CsvProvider and HtmlProvider. - JsonProvider: defaults to true (preserving existing behavior of using option types). When set to false, missing/null string fields use empty string and missing/null float fields use NaN. - XmlProvider: defaults to true (preserving existing behavior). When set to false, absent string attributes/elements use empty string and absent float attributes/elements use NaN. Also adds allowEmptyValues parameter to JsonInference.inferType so it is threaded through to inferCollectionType for JSON arrays. Closes #649 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
11 tasks
github-actions bot
added a commit
that referenced
this pull request
Feb 26, 2026
* Add PreferOptionals parameter to XmlProvider and JsonProvider Implements the PreferOptionals static parameter for XmlProvider and JsonProvider, following the same pattern already used by CsvProvider and HtmlProvider. - JsonProvider: defaults to true (preserving existing behavior of using option types). When set to false, missing/null string fields use empty string and missing/null float fields use NaN. - XmlProvider: defaults to true (preserving existing behavior). When set to false, absent string attributes/elements use empty string and absent float attributes/elements use NaN. Also adds allowEmptyValues parameter to JsonInference.inferType so it is threaded through to inferCollectionType for JSON arrays. Closes #649 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * ci: trigger CI checks * update build * update build --------- Co-authored-by: Repo Assist <repo-assist@github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Don Syme <dsyme@github.com>
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.
🤖 This is an automated pull request from Repo Assist.
Implements the
PreferOptionalsstatic parameter forXmlProviderandJsonProvider, as requested in #649 and per the maintainer instruction.Background
PreferOptionalsalready exists inCsvProviderandHtmlProvider. This PR adds the same capability to the remaining two type providers.Changes
src/FSharp.Data.Json.Core/JsonInference.fsallowEmptyValues: boolparameter toinferType, threaded through toinferCollectionTypeand recursive calls.src/FSharp.Data.DesignTime/Json/JsonProvider.fsPreferOptionalsstatic parameter (default =trueto preserve existing behavior — JSON/XML already defaulted to option types).not preferOptionalsasallowEmptyValuesto inference.src/FSharp.Data.Xml.Core/XmlInference.fsJsonInference.inferType(for inline JSON in XML) to passallowEmptyValues = false.src/FSharp.Data.DesignTime/Xml/XmlProvider.fsPreferOptionalsstatic parameter (default =true).not preferOptionalsasallowEmptyValuestoXmlInference.inferTypeand fold.tests/FSharp.Data.DesignTime.Tests/TypeProviderInstantiation.fsPreferOptionals: booltoXmlProviderArgsandJsonProviderArgs(defaulttrue).tests/FSharp.Data.DesignTime.Tests/InferenceTests.fsJsonInference.inferTypecalls with the newallowEmptyValuesparameter (passingfalsefor backward-compatible test behavior).tests/FSharp.Data.Tests/JsonProvider.fsandXmlProvider.fsBehavior
PreferOptionals=true(default)string option(None)float option(None)PreferOptionals=falsestring(empty string"")float(NaN)The default
truepreserves existing behavior for XML/JSON, which already used option types.Test Status
✅ Build succeeded
✅ 487 design-time tests passed
✅ 274 integration tests passed
✅ Fantomas formatting check passed
Closes #649