xsdata icon indicating copy to clipboard operation
xsdata copied to clipboard

Generate wrapper

Open couling opened this issue 1 year ago • 1 comments

📒 Description

Adds new feature to code generation to detect wrapped lists and unwrap them in dataclasses, using the wrapped feature.

Resolves #927

🔗 What I've Done

  • Added an output config option to unwrap wrapped lists.
  • Added an attribute to Attr for wrapper, indicating the wrapper element name.
  • Added a processor in Translate (Flatten) which
    • places the list wrapper's local_name into the wrapper of the wrapped list
    • optionally changes the name of the wrapped list to match the wrapper
    • replaces the wrapper attribute with the wrapped attribute
    • replaces the inner for the wrapper with the inner for the wrapped

💬 Comments

This is currently in draft and needs unit tests / doc changes etc.

Am creating this as a draft now to allow @tefra to comment on the approach, before I work on documentation and unit tests.

One major decision here was whether code should be trigged through the ClassContainer or should be entirely encoded into the dataclass writer. On balance it seemed simpler to embed this and unit test this in the ClassContainer.

🛫 Checklist

couling avatar Jan 31 '24 23:01 couling

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

1 New issue
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

sonarqubecloud[bot] avatar Jan 31 '24 23:01 sonarqubecloud[bot]

This is on my immediate todo list, I will close this one for now

tefra avatar Mar 10 '24 10:03 tefra