Skip to content

[Repo Assist] Add PreferOptionals parameter to XmlProvider and JsonProvider#1660

Merged
dsyme merged 5 commits intomainfrom
repo-assist/fix-issue-649-prefer-optionals-xml-json-437b1fa1ff587b4d
Feb 25, 2026
Merged

[Repo Assist] Add PreferOptionals parameter to XmlProvider and JsonProvider#1660
dsyme merged 5 commits intomainfrom
repo-assist/fix-issue-649-prefer-optionals-xml-json-437b1fa1ff587b4d

Conversation

@github-actions
Copy link
Contributor

🤖 This is an automated pull request from Repo Assist.

Implements the PreferOptionals static parameter for XmlProvider and JsonProvider, as requested in #649 and per the maintainer instruction.

Background

PreferOptionals already exists in CsvProvider and HtmlProvider. This PR adds the same capability to the remaining two type providers.

Changes

src/FSharp.Data.Json.Core/JsonInference.fs

  • Added allowEmptyValues: bool parameter to inferType, threaded through to inferCollectionType and recursive calls.

src/FSharp.Data.DesignTime/Json/JsonProvider.fs

  • Added PreferOptionals static parameter (default = true to preserve existing behavior — JSON/XML already defaulted to option types).
  • Passes not preferOptionals as allowEmptyValues to inference.

src/FSharp.Data.Xml.Core/XmlInference.fs

  • Updated call to JsonInference.inferType (for inline JSON in XML) to pass allowEmptyValues = false.

src/FSharp.Data.DesignTime/Xml/XmlProvider.fs

  • Added PreferOptionals static parameter (default = true).
  • Passes not preferOptionals as allowEmptyValues to XmlInference.inferType and fold.

tests/FSharp.Data.DesignTime.Tests/TypeProviderInstantiation.fs

  • Added PreferOptionals: bool to XmlProviderArgs and JsonProviderArgs (default true).

tests/FSharp.Data.DesignTime.Tests/InferenceTests.fs

  • Updated all JsonInference.inferType calls with the new allowEmptyValues parameter (passing false for backward-compatible test behavior).

tests/FSharp.Data.Tests/JsonProvider.fs and XmlProvider.fs

  • Added integration tests verifying the new parameter.

Behavior

Parameter value Missing/null string Missing/null float
PreferOptionals=true (default) string option (None) float option (None)
PreferOptionals=false string (empty string "") float (NaN)

The default true preserves 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

Generated by Repo Assist for issue #649

To install this workflow, run gh aw add githubnext/agentics/workflows/repo-assist.md@f2c5cf1e4af58e09a93ba0703c6bf084711b265f. View source at https://github.com/githubnext/agentics/tree/f2c5cf1e4af58e09a93ba0703c6bf084711b265f/workflows/repo-assist.md.

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>
@dsyme dsyme marked this pull request as ready for review February 25, 2026 22:07
@dsyme dsyme merged commit ff1df2a into main Feb 25, 2026
2 checks passed
@dsyme dsyme deleted the repo-assist/fix-issue-649-prefer-optionals-xml-json-437b1fa1ff587b4d branch February 25, 2026 22:07
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PreferOptionals param for XmlProvider

1 participant