CoreOffice / XMLCoder

Easy XML parsing using Codable protocols in Swift
https://coreoffice.github.io/XMLCoder/
MIT License
800 stars 112 forks source link

Make TopLevelEncoder implementation overridable #182

Closed kkebo closed 4 years ago

kkebo commented 4 years ago

TopLevelEncoder implementation was added by #175. However, its method cannot be overridden. If it can be, we can use custom root key, root attributes, or header even when we use Combine-style like this:

final class MyEncoder: XMLEncoder {
    override func encode<T>(_ value: T) throws -> Data where T : Encodable {
        try self.encode(value, withRootKey: "foo", rootAttributes: nil, header: XMLHeader(version: 1.0, encoding: "UTF-8"))
    }
}

So, I proposed the solution.

codecov[bot] commented 4 years ago

Codecov Report

Merging #182 into master will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #182   +/-   ##
=======================================
  Coverage   73.32%   73.32%           
=======================================
  Files          43       43           
  Lines        2332     2332           
=======================================
  Hits         1710     1710           
  Misses        622      622           
Impacted Files Coverage Δ
Sources/XMLCoder/Decoder/XMLDecoder.swift 76.29% <ø> (-0.35%) :arrow_down:
Sources/XMLCoder/Encoder/XMLEncoder.swift 85.61% <100.00%> (+0.21%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update ac411bd...18282b5. Read the comment docs.

kkebo commented 4 years ago

@MaxDesiatov It seems that danger-lint has failed in XMLDecoder, but I didn't change XMLDecoder at all. Do you have any ideas?

MaxDesiatov commented 4 years ago

No worries, that seems like a SwiftLint bug 🙂