Skip to content

Commit

Permalink
Merge branch 'master' into fix-empty-string-empty-elt
Browse files Browse the repository at this point in the history
  • Loading branch information
bwetherfield committed Nov 11, 2019
2 parents 0222d24 + bf09326 commit 2a840ef
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 28 deletions.
12 changes: 12 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# These are supported funding model platforms

github: MaxDesiatov # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ by [@sharplet](https://github.com/sharplet).

**Apple Platforms**
- Xcode 10.0 or later
* **IMPORTANT**: compiling XMLCoder with Xcode 11.2.0 (11B52) may cause crashes with `EXC_BAD_ACCESS` due to [a compiler bug](https://bugs.swift.org/browse/SR-11564). A known workaround is to set `DEAD_CODE_STRIPPING = NO` in your project settings. Please refer to [\#150](https://github.com/MaxDesiatov/XMLCoder/issues/150) for more details.
- Swift 4.2 or later
- iOS 9.0 / watchOS 2.0 / tvOS 9.0 / macOS 10.10 or later deployment targets

Expand Down Expand Up @@ -408,8 +409,7 @@ Please check [SwiftFormat
documentation](https://github.com/nicklockwood/SwiftFormat#how-do-i-install-it)
for more details.

SwiftFormat also runs within our [Travis
CI](https://travis-ci.org/MaxDesiatov/XMLCoder) setup and a CI build can fail
SwiftFormat also runs on CI for every PR and thus a CI build can fail
with incosistent formatting. We require CI builds to pass for any PR before
merging.

Expand Down
2 changes: 1 addition & 1 deletion Sources/XMLCoder/Auxiliaries/Box/KeyedBox.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct KeyedBox {
}

var value: SimpleBox? {
return elements["value"].first as? SimpleBox
return elements[""].first as? SimpleBox
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/XMLCoder/Auxiliaries/XMLCoderElement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ struct XMLCoderElement: Equatable {
// Handle attributed unkeyed value <foo attr="bar">zap</foo>
// Value should be zap. Detect only when no other elements exist
if elements.isEmpty, let value = value {
elements.append(StringBox(value), at: "value")
elements.append(StringBox(value), at: "")
}
return KeyedBox(elements: elements, attributes: attributes)
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/XMLCoder/Decoder/XMLDecoderImplementation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class XMLDecoderImplementation: Decoder {
return KeyedDecodingContainer(XMLKeyedDecodingContainer<Key>(
referencing: self,
wrapping: SharedBox(KeyedBox(
elements: KeyedStorage([("value", string)]),
elements: KeyedStorage([("", string)]),
attributes: KeyedStorage()
))
))
Expand Down
16 changes: 3 additions & 13 deletions Sources/XMLCoder/Decoder/XMLKeyedDecodingContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -232,19 +232,9 @@ extension XMLKeyedDecodingContainer {

let elements = container
.withShared { keyedBox -> [KeyedBox.Element] in
if ["value", ""].contains(key.stringValue) {
let keyString = key.stringValue.isEmpty ? "value" : key.stringValue
let value = keyedBox.elements[keyString]
if !value.isEmpty {
return value.map {
if let singleKeyed = $0 as? SingleKeyedBox {
return singleKeyed.element
} else {
return $0
}
}
} else if let value = keyedBox.value {
return [value]
keyedBox.elements[key.stringValue].map {
if let singleKeyed = $0 as? SingleKeyedBox {
return singleKeyed.element
} else {
return []
}
Expand Down
10 changes: 7 additions & 3 deletions Tests/XMLCoderTests/AttributedIntrinsicTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private struct Foo: Codable, DynamicNodeEncoding, Equatable {

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

static func nodeEncoding(for key: CodingKey) -> XMLEncoder.NodeEncoding {
Expand All @@ -97,6 +97,10 @@ private struct Foo: Codable, DynamicNodeEncoding, Equatable {

private struct FooValue: Codable, Equatable {
let value: Int

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

private struct FooOptional: Codable, DynamicNodeEncoding, Equatable {
Expand All @@ -105,7 +109,7 @@ private struct FooOptional: Codable, DynamicNodeEncoding, Equatable {

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

static func nodeEncoding(for key: CodingKey) -> XMLEncoder.NodeEncoding {
Expand Down Expand Up @@ -167,7 +171,7 @@ private struct PreviewImageTime: Codable, Equatable, DynamicNodeEncoding {

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

static func nodeEncoding(for key: CodingKey) -> XMLEncoder.NodeEncoding {
Expand Down
30 changes: 23 additions & 7 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,54 +9,70 @@ jobs:
- bash: ./lint.sh
- job: pod
pool:
vmImage: 'macos-latest'
vmImage: 'macOS-10.14'
steps:
- bash: ./pod.sh
- job: test_xcodebuild_10_0
pool:
vmImage: 'macos-latest'
vmImage: 'macOS-10.14'
steps:
- bash: ./test_xcodebuild.sh Xcode_10
env:
IOS_DEVICE: 'platform=iOS Simulator,OS=12.0,name=iPhone SE'
TVOS_DEVICE: 'platform=tvOS Simulator,OS=12.0,name=Apple TV 4K'
- job: test_xcodebuild_10_1
pool:
vmImage: 'macos-latest'
vmImage: 'macOS-10.14'
steps:
- bash: ./test_xcodebuild.sh Xcode_10.1
env:
IOS_DEVICE: 'platform=iOS Simulator,OS=12.1,name=iPhone SE'
TVOS_DEVICE: 'platform=tvOS Simulator,OS=12.1,name=Apple TV 4K'
- job: test_xcodebuild_10_2
pool:
vmImage: 'macos-latest'
vmImage: 'macOS-10.14'
steps:
- bash: ./test_xcodebuild.sh Xcode_10.2.1
env:
IOS_DEVICE: 'platform=iOS Simulator,OS=12.2,name=iPhone SE'
TVOS_DEVICE: 'platform=tvOS Simulator,OS=12.2,name=Apple TV 4K'
- job: test_xcodebuild_10_3
pool:
vmImage: 'macOS-10.14'
steps:
- bash: ./test_xcodebuild.sh Xcode_10.3
env:
IOS_DEVICE: 'platform=iOS Simulator,OS=12.4,name=iPhone SE'
TVOS_DEVICE: 'platform=tvOS Simulator,OS=12.4,name=Apple TV 4K'
- job: test_xcodebuild_11_0
pool:
vmImage: 'macos-latest'
vmImage: 'macOS-10.14'
steps:
- bash: ./test_xcodebuild.sh Xcode_11
env:
IOS_DEVICE: 'platform=iOS Simulator,OS=13.0,name=iPhone 8'
TVOS_DEVICE: 'platform=tvOS Simulator,OS=13.0,name=Apple TV 4K'
- job: test_xcodebuild_11_1
pool:
vmImage: 'macos-latest'
vmImage: 'macOS-10.14'
steps:
- bash: ./test_xcodebuild.sh Xcode_11.1
env:
IOS_DEVICE: 'platform=iOS Simulator,OS=13.1,name=iPhone 8'
TVOS_DEVICE: 'platform=tvOS Simulator,OS=13.0,name=Apple TV 4K'
- job: test_xcodebuild_11_2
pool:
vmImage: 'macOS-10.14'
steps:
- bash: ./test_xcodebuild.sh Xcode_11.2
env:
IOS_DEVICE: 'platform=iOS Simulator,OS=13.2,name=iPhone 8'
TVOS_DEVICE: 'platform=tvOS Simulator,OS=13.2,name=Apple TV 4K'
CODECOV_JOB: 'true'
CODECOV_TOKEN: $(codecovToken)
- job: test_swiftpm
pool:
vmImage: 'macos-latest'
vmImage: 'macOS-10.14'
steps:
- script: ./test_swiftpm.sh
- job: test_linux_5_0
Expand Down

0 comments on commit 2a840ef

Please sign in to comment.