Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Pretty-printed intrinsic-value elements are split across multiple lines #295

Copy link
Copy link

Description

@weppos
Issue body actions

When an element stores its text content via the empty-string CodingKey (""), XMLEncoder pretty printing splits the intrinsic value onto its own line instead of keeping the element inline.

Minimal example:

struct Measurement: Codable {
    @Attribute var ref: String?
    var value: Double

    enum CodingKeys: String, CodingKey {
        case ref
        case value = ""
    }
}

let encoder = XMLEncoder()
encoder.outputFormatting = [.prettyPrinted]
encoder.prettyPrintIndentation = .spaces(4)

Actual output:

<measurement ref="sensor-1">
    120000.0
</measurement>

Expected output:

<measurement ref="sensor-1">120000.0</measurement>

This also affects the same intrinsic-value shape when the element has no attributes.

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.