Skip to content

PreferOptionals param for XmlProvider #649

@lasandell

Description

@lasandell

I've come across a couple situations where I've wanted to treat all primitive values in the XML document as strings rather than relying on type inference to figure this out. I was thinking about about adding some settings to the type provider for this; I already have some of them working locally. They would be as follows:

  • ForceStrings - Infer all primitive values as strings, regardless of content.
  • UseEmptyStrings - If a string is not always present, use an empty string to represent its absence rather than inferring the string option type for the value.

Additionally, I'd like it to infer empty elements as strings, similar to what it currently does with attributes. Right now, it infers an empty class type for an empty element. I don't know if this should be another option (TreatEmptyElementAsString?) or if it should just be the standard behavior.

If we decide these should be added, I can also try to include similar behavior in the JSON and CSV providers. However, those are a little different since they have unquoted values; so should the ForceStrings setting apply to all values or just quoted ones? I'm thinking the former. Or we could have an enumeration, e.g. type ForceString = Always | Never | WhenQuoted.

Please let me know your thoughts on these potential features. I think it is useful to have more control over the projection; however, I wouldn't want to add a bunch of stuff in that nobody else would use.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions