Skip to content

Commit 9aa18f8

Browse files
committed
Fix forEachField
1 parent ed7aa8a commit 9aa18f8

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

Sources/OpenGraphShims/Metadata+Debug.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ extension Metadata {
4242
switch kind {
4343
case .enum:
4444
write(&result, string: "enum \(type) {", level: level)
45-
_ = forEachField(options: [._4]) { name, offset, type in // anything contains ._4 will work here
45+
_ = forEachField(options: [.enumerateEnumCases]) { name, offset, type in // anything contains ._4 will work here
4646
let fieldName = String(cString: name)
4747
write(&result, string: "case \(fieldName)(\(type)) // offset = \(offset.hex)", level: level+1)
4848
if recursive {
@@ -52,7 +52,7 @@ extension Metadata {
5252
}
5353
write(&result, string: "}", level: level)
5454
case .optional:
55-
_ = forEachField(options: [._4]) { name, offset, type in // anything contains ._4 will work here
55+
_ = forEachField(options: [.enumerateEnumCases]) { name, offset, type in // anything contains ._4 will work here
5656
let fieldName = String(cString: name)
5757
write(&result, string: "case \(fieldName)(\(type)) // offset = \(offset.hex)", level: level+1)
5858
if recursive {
@@ -74,7 +74,7 @@ extension Metadata {
7474
case .tuple: break
7575
case .class:
7676
write(&result, string: "class \(type) {", level: level)
77-
_ = forEachField(options: [._1]) { name, offset, type in // anything contains ._1 will work here
77+
_ = forEachField(options: [.enumerateClassFields]) { name, offset, type in // anything contains ._1 will work here
7878
let fieldName = String(cString: name)
7979

8080
write(&result, string: "var \(fieldName): \(type) // offset = \(offset.hex)", level: level+1)

Tests/OpenGraphCompatibilityTests/Runtime/MetadataCompatibilityTests.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ struct MetadataCompatibilityTests {
160160

161161
@Test(.disabled(if: !compatibilityTestEnabled, "Metadata is not implemented"))
162162
func forEachField() throws {
163-
for options in [OGTypeApplyOptions._1] {
163+
for options in [OGTypeApplyOptions.enumerateClassFields] {
164164
let result = Metadata(T1.self).forEachField(options: options) { name, offset, type in
165165
if offset == 16 {
166166
#expect(type is Int.Type)
@@ -176,7 +176,7 @@ struct MetadataCompatibilityTests {
176176
}
177177
#expect(result == true)
178178
}
179-
for options in [OGTypeApplyOptions._2, ._4, []] {
179+
for options in [OGTypeApplyOptions.continueAfterUnknownField, .enumerateEnumCases, []] {
180180
let result = Metadata(T1.self).forEachField(options: options) { name, offset, type in
181181
if offset == 16 {
182182
#expect(type is Int.Type)
@@ -192,7 +192,7 @@ struct MetadataCompatibilityTests {
192192
}
193193
#expect(result == false)
194194
}
195-
for options in [OGTypeApplyOptions._2, []] {
195+
for options in [OGTypeApplyOptions.continueAfterUnknownField, []] {
196196
let result = Metadata(T2.self).forEachField(options: options) { name, offset, type in
197197
if offset == 0 {
198198
#expect(type is Int.Type)
@@ -206,7 +206,7 @@ struct MetadataCompatibilityTests {
206206
}
207207
#expect(result == true)
208208
}
209-
for options in [OGTypeApplyOptions._1, ._4] {
209+
for options in [OGTypeApplyOptions.enumerateClassFields, .enumerateEnumCases] {
210210
let result = Metadata(T2.self).forEachField(options: options) { name, offset, type in
211211
if offset == 0 {
212212
#expect(type is Int.Type)
@@ -222,7 +222,7 @@ struct MetadataCompatibilityTests {
222222
}
223223
#expect(result == false)
224224
}
225-
for options in [OGTypeApplyOptions._1, ._2, ._4, []] {
225+
for options in [OGTypeApplyOptions.enumerateClassFields, .continueAfterUnknownField, .enumerateEnumCases, []] {
226226
let result = Metadata(T3.self).forEachField(options: options) { _, _, _ in
227227
true
228228
}

0 commit comments

Comments
 (0)