Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make value intrinsic smarter #89

Merged
merged 8 commits into from
Apr 8, 2019
Merged

Make value intrinsic smarter #89

merged 8 commits into from
Apr 8, 2019

Conversation

MaxDesiatov
Copy link
Collaborator

@MaxDesiatov MaxDesiatov commented Apr 7, 2019

Note: This PR depends on and includes #88.

Recent addition of value intrinsic allows XMLCoder to handle last few known edge cases, but still a lot of times the shape of an XML isn't guaranteed to be always the same. E.g. some of the attributes might be present or absent, but an element without attributes is never decoded as a KeyedBox even with a value intrinsic. And vice versa, a KeyedBox with attributes can't be decoded with a primitive type that maps to the element value.

This was previously reported by @Inukinator as an issue in InukVT/Read#2.

Consider this sample XML:

<container>
<foo id="123">456</foo>
<foo id="789">123</foo>
</container>

As of 847d754 this can't be decoded as

struct Container: Codable {
  let foo: [Int]
}

And this xml:

<container>
<foo>456</foo>
<foo>123</foo>
<foo>789</foo>
</container>

can't be decoded with

struct Container: Codable {
  struct Foo: Codable {
    let value: Int
  }

  let foo: [Foo]
}

This is fixed now with added optional down casts that peek into the box structure and map it correctly in these remaining edge cases.

@codecov
Copy link

codecov bot commented Apr 7, 2019

Codecov Report

Merging #89 into master will decrease coverage by 0.37%.
The diff coverage is 53.22%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #89      +/-   ##
==========================================
- Coverage   77.36%   76.98%   -0.38%     
==========================================
  Files          38       38              
  Lines        2076     2112      +36     
==========================================
+ Hits         1606     1626      +20     
- Misses        470      486      +16
Impacted Files Coverage Δ
...es/XMLCoder/Decoder/XMLDecoderImplementation.swift 61.59% <53.22%> (-0.91%) ⬇️

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 f241d42...d41b238. Read the comment docs.

@MaxDesiatov MaxDesiatov merged commit 2bbe8ee into master Apr 8, 2019
@delete-merged-branch delete-merged-branch bot deleted the intrinsic-fix branch April 8, 2019 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants