Skip to content

Comments

[Repo Assist] Add UseOriginalNames parameter to XmlProvider, CsvProvider, JsonProvider#1629

Merged
dsyme merged 9 commits intomainfrom
repo-assist/fix-issue-1432-xml-use-original-names-42eda4f9851807b6
Feb 24, 2026
Merged

[Repo Assist] Add UseOriginalNames parameter to XmlProvider, CsvProvider, JsonProvider#1629
dsyme merged 9 commits intomainfrom
repo-assist/fix-issue-1432-xml-use-original-names-42eda4f9851807b6

Conversation

@github-actions
Copy link
Contributor

🤖 This is an automated draft PR from Repo Assist, an AI assistant.

Summary

Adds a new UseOriginalNames static parameter to XmlProvider. When UseOriginalNames=true, XML element and attribute names are used verbatim for generated property and constructor parameter names, instead of being normalized to PascalCase/camelCase.

Addresses #1432 (endorsed by @dsyme in 2022-03-28).

Root Cause

XmlGenerator.fs always applies NameUtils.nicePascalName to element/attribute names when generating property names, and NameUtils.niceCamelName for constructor parameters. There was no way to opt out of this normalization.

Fix

  • Added UseOriginalNames: bool field to XmlGenerationContext
  • Modified XmlGenerationContext.Create to accept useOriginalNames: bool and store it
  • Changed the two local makeUnique generators in XmlGenerator.fs to use identity instead of nicePascalName when UseOriginalNames = true
  • Changed niceCamelName constructor parameter generation similarly
  • Added UseOriginalNames static parameter to XmlProvider.fs (index 11, default false)
  • Updated XML doc for the new parameter

Example

// Default (PascalCase normalization)
type T = XmlProvider<"(root fault_code='123' /)">
// T.Root.FaultCode

// With UseOriginalNames=true
type T2 = XmlProvider<"(root fault_code='123' /)", UseOriginalNames=true>
// T2.Root.fault_code

Trade-offs

  • Generated names may not be valid F# identifiers if the XML name contains special characters (though NameUtils.uniqueGenerator handles name-clash deduplication with the new identity transform)
  • NameUtils.pluralize is still applied to collection element names (this preserves grammatical sensibility for array properties)
  • Internal generated type names (for heterogeneous/choice types) still use the unique-name generator, which now respects the UseOriginalNames flag

Test Status

  • ✅ Build succeeded (0 errors, pre-existing warnings only)
  • ✅ All 253 FSharp.Data.Tests pass
  • fantomas formatting applied and build re-verified

Generated by Repo Assist

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

When UseOriginalNames=true, XML element and attribute names are used
as-is for generated property and constructor parameter names, instead
of being normalized to PascalCase/camelCase.

Addresses #1432 (dsyme endorsed 2022-03-28).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Contributor Author

✅ Pull request created: #1629

@github-actions
Copy link
Contributor Author

✅ Commit pushed: c78dadb

Add missing UseOriginalNames field to XmlProviderArgs record and include
it in the args array passed to XmlProvider in TypeProviderInstantiation.fs,
as requested by @dsyme in issue #1432.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dsyme dsyme marked this pull request as ready for review February 23, 2026 15:34
@dsyme
Copy link
Contributor

dsyme commented Feb 23, 2026

/repo-assist Update this PR to add this same UseOriginalNames parameter to CsvProvider and JsonProvider if it makes sense for those.

- CsvProvider: UseOriginalNames=true preserves column header names verbatim
  instead of capitalizing the first letter
- JsonProvider: UseOriginalNames=true preserves JSON property names verbatim
  instead of normalizing to PascalCase

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Contributor Author

✅ Commit pushed: e05ee6c

@github-actions
Copy link
Contributor Author

🤖 This is an automated update from Repo Assist.

Done! I've extended UseOriginalNames to CsvProvider and JsonProvider. Here's a summary:

Changes

CsvProvider (UseOriginalNames=true)

CSV column headers are used verbatim as property names, bypassing the default first-letter capitalization.

// Default: "fault_code" header → property "Fault_code"
type T = CsvProvider<"fault_code\n123">

// With UseOriginalNames=true: header used as-is
type T2 = CsvProvider<"fault_code\n123", UseOriginalNames=true>
// T2.Row.fault_code

JsonProvider (UseOriginalNames=true)

JSON property names are used verbatim, bypassing PascalCase normalization.

// Default: "fault_code" key → property "FaultCode"
type T = JsonProvider<"""{"fault_code": 123}""">

// With UseOriginalNames=true: key used as-is
type T2 = JsonProvider<"""{"fault_code": 123}""", UseOriginalNames=true>
// T2.Root.fault_code

Test Status

  • ✅ Build succeeded (0 errors, pre-existing warnings only)
  • ✅ All 253 FSharp.Data.Tests pass
  • fantomas formatting applied and build re-verified

Generated by Repo Assist for issue #1629

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

@dsyme
Copy link
Contributor

dsyme commented Feb 24, 2026

/repo-assist Add tests for all three type providers

…ider

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Contributor Author

Commit pushed: 30af451

Generated by Repo Assist

@github-actions
Copy link
Contributor Author

🤖 Repo Assist here.

Done! I've added 6 tests covering UseOriginalNames=true and the default normalisation behaviour for all three type providers:

  • XmlProvider: verifies fault_code attribute is exposed as fault_code (original) vs FaultCode (default PascalCase via nicePascalName)
  • CsvProvider: verifies lower_col header is exposed as lower_col (original) vs Lower_col (default capitalised first letter)
  • JsonProvider: verifies first_name property is exposed as first_name (original) vs FirstName (default PascalCase via nicePascalName)

All 6 tests pass ✅ and fantomas format check is clean.

Generated by Repo Assist for issue #1629

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

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Contributor Author

Commit pushed: ceadc48

Generated by Repo Assist

@dsyme dsyme merged commit 73f6dfe into main Feb 24, 2026
0 of 2 checks passed
@dsyme dsyme deleted the repo-assist/fix-issue-1432-xml-use-original-names-42eda4f9851807b6 branch February 24, 2026 19:27
@dsyme dsyme changed the title [Repo Assist] Add UseOriginalNames parameter to XmlProvider [Repo Assist] Add UseOriginalNames parameter to XmlProvider, CsvProvider, JsonProvider Feb 24, 2026
github-actions bot added a commit that referenced this pull request Feb 24, 2026
… list syntax

After PR #1629 (UseOriginalNames) was merged into main, the DtdProcessing branch
had a merge conflict residue in XmlProvider.fs:

1. Both dtdProcessing and useOriginalNames were assigned from args.[11]
   - dtdProcessing should be args.[11] (DtdProcessing param, index 11)
   - useOriginalNames should be args.[12] (UseOriginalNames param, index 12)

2. The static parameters list had two closing brackets causing a syntax
   error that Fantomas could not parse.

3. The helpText had a duplicate triple-quote after the DtdProcessing param doc.

Build verified (0 errors), Fantomas clean.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
dsyme added a commit that referenced this pull request Feb 24, 2026
#1632) (#1635)

* Add DtdProcessing static parameter to XmlProvider

Allow users to control DTD handling via XmlProvider<..., DtdProcessing="Ignore">
to support XML files with DTD declarations (Nmap scan output, XHTML, etc.).

- Default is "Prohibit" (preserves existing security posture — throws on DTD)
- "Ignore" silently skips DTD processing (safe for most real-world cases)
- "Parse" enables full DTD entity expansion (use with caution)

XmlElement.Create/CreateList now have dtdProcessing overloads; the no-arg
overloads delegate to "Prohibit" for backward compatibility.
Design-time sample parsing also respects the new parameter.

Addresses #1632. Closes #1634.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Change DtdProcessing default to Ignore (opt-out instead of opt-in)

Users who want strict DTD prohibition can opt-out via DtdProcessing="Prohibit".
Update snapshot files and test defaults to reflect new default.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Fix build: add missing 'open System.Xml' and fix CreateList to use XmlReader

- Add 'open System.Xml' so DtdProcessing, XmlReaderSettings and XmlReader
  are resolved (fixes FS0039 build errors on Windows and Linux CI).
- Fix CreateList to parse via XmlReader.Create with the XmlReaderSettings,
  so the DtdProcessing setting is actually respected (previously the
  xmlReaderSettings variable was created but then ignored by XDocument.Parse).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* ci: trigger CI checks

* Fix: update remaining signature snapshots for DtdProcessing parameter

The 9 snapshot files that use network-loaded XML samples (tomasp.net RSS feed)
and XSD schema files (IncludeFromWeb.xsd) were not updated in the previous
snapshot regeneration run. Update them to include the new DtdProcessing
argument in all XmlElement.Create calls.

All 486 DesignTime tests pass.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* ci: trigger CI checks

* Fix merge conflict residue in XmlProvider.fs: correct arg indices and list syntax

After PR #1629 (UseOriginalNames) was merged into main, the DtdProcessing branch
had a merge conflict residue in XmlProvider.fs:

1. Both dtdProcessing and useOriginalNames were assigned from args.[11]
   - dtdProcessing should be args.[11] (DtdProcessing param, index 11)
   - useOriginalNames should be args.[12] (UseOriginalNames param, index 12)

2. The static parameters list had two closing brackets causing a syntax
   error that Fantomas could not parse.

3. The helpText had a duplicate triple-quote after the DtdProcessing param doc.

Build verified (0 errors), Fantomas clean.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* ci: trigger CI checks

* fix: WorldBank API 400 Bad Request from empty date= parameter

The WorldBank v2 API started returning 400 Bad Request when the 'date'
query parameter is present but empty (date=). Remove the empty date
parameter from GetDataAsync so the API returns all available years by
default (omitting 'date' entirely has the same meaning as passing an
empty one, but the API now rejects the latter).

Also update WorldBankProvider test exception handlers to mark tests
as Inconclusive on 400 errors, providing belt-and-suspenders resilience
against future API changes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* ci: trigger CI checks

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Repo Assist <repo-assist@github.com>
Co-authored-by: Don Syme <dsyme@users.noreply.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.

1 participant