[Repo Assist] Add UseOriginalNames parameter to XmlProvider#1629
[Repo Assist] Add UseOriginalNames parameter to XmlProvider#1629github-actions[bot] wants to merge 4 commits intomainfrom
Conversation
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>
|
✅ Pull request created: #1629 |
|
✅ Commit pushed: |
…names-42eda4f9851807b6
|
/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>
|
✅ Commit pushed: |
|
🤖 This is an automated update from Repo Assist. Done! I've extended Changes
|
🤖 This is an automated draft PR from Repo Assist, an AI assistant.
Summary
Adds a new
UseOriginalNamesstatic parameter toXmlProvider. WhenUseOriginalNames=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.fsalways appliesNameUtils.nicePascalNameto element/attribute names when generating property names, andNameUtils.niceCamelNamefor constructor parameters. There was no way to opt out of this normalization.Fix
UseOriginalNames: boolfield toXmlGenerationContextXmlGenerationContext.Createto acceptuseOriginalNames: booland store itmakeUniquegenerators inXmlGenerator.fsto use identity instead ofnicePascalNamewhenUseOriginalNames = trueniceCamelNameconstructor parameter generation similarlyUseOriginalNamesstatic parameter toXmlProvider.fs(index 11, defaultfalse)Example
Trade-offs
NameUtils.uniqueGeneratorhandles name-clash deduplication with the new identity transform)NameUtils.pluralizeis still applied to collection element names (this preserves grammatical sensibility for array properties)UseOriginalNamesflagTest Status
FSharp.Data.Testspassfantomasformatting applied and build re-verified