Skip to content

Comments

[Repo Assist] Add UseOriginalNames parameter to XmlProvider#1629

Open
github-actions[bot] wants to merge 4 commits intomainfrom
repo-assist/fix-issue-1432-xml-use-original-names-42eda4f9851807b6
Open

[Repo Assist] Add UseOriginalNames parameter to XmlProvider#1629
github-actions[bot] wants to merge 4 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.

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