diff --git a/Sources/CustomDump/Conformances/Foundation.swift b/Sources/CustomDump/Conformances/Foundation.swift index 3158488..5a4f28b 100644 --- a/Sources/CustomDump/Conformances/Foundation.swift +++ b/Sources/CustomDump/Conformances/Foundation.swift @@ -325,3 +325,23 @@ extension UUID: CustomDumpStringConvertible { "UUID(\(self.uuidString))" } } + +extension KeyPath: CustomDumpExcludeSuperclass {} +extension CFNumber: CustomDumpExcludeSuperclass {} +extension NSNumber: CustomDumpExcludeSuperclass {} +extension NSMutableAttributedString: CustomDumpExcludeSuperclass {} +extension NSCalendar: CustomDumpExcludeSuperclass {} +extension NSCountedSet: CustomDumpExcludeSuperclass {} +#if !os(WASI) +extension NSData: CustomDumpExcludeSuperclass {} +extension NSDate: CustomDumpExcludeSuperclass {} +extension NSNotification: CustomDumpExcludeSuperclass {} +extension NSTimeZone: CustomDumpExcludeSuperclass {} +extension NSURLRequest: CustomDumpExcludeSuperclass {} +#endif +extension NSDictionary: CustomDumpExcludeSuperclass {} +extension NSString: CustomDumpExcludeSuperclass {} +extension NSLocale: CustomDumpExcludeSuperclass {} +#if os(iOS) || os(macOS) || os(tvOS) || os(watchOS) +extension NSExpression: CustomDumpExcludeSuperclass {} +#endif diff --git a/Sources/CustomDump/CustomDumpChildren.swift b/Sources/CustomDump/CustomDumpChildren.swift index cdee3bb..2f3878b 100644 --- a/Sources/CustomDump/CustomDumpChildren.swift +++ b/Sources/CustomDump/CustomDumpChildren.swift @@ -1,5 +1,5 @@ -/// Implement this protocol to include superclass nodes -public protocol CustomDumpIncludeSuperclass {} +/// Implement this protocol to exclude superclass nodes +public protocol CustomDumpExcludeSuperclass {} /// Implement this protocol to ignore dumping child nodes /// diff --git a/Sources/CustomDump/Dump.swift b/Sources/CustomDump/Dump.swift index d3ede71..5c7d7a6 100644 --- a/Sources/CustomDump/Dump.swift +++ b/Sources/CustomDump/Dump.swift @@ -1,3 +1,4 @@ +import Foundation /// Dumps the given value's contents using its mirror to standard output. /// /// This function aims to dump the contents of a value into a nicely formatted, tree-like @@ -262,7 +263,7 @@ public func customDump( } } - if let superclassMirror = mirror.superclassMirror, value is CustomDumpIncludeSuperclass { + if let superclassMirror = mirror.superclassMirror, superclassMirror.subjectType != NSObject.self, !(value is CustomDumpExcludeSuperclass) { out.write("\n") dumpMirror(mirror: superclassMirror) } diff --git a/Tests/CustomDumpTests/DumpTests.swift b/Tests/CustomDumpTests/DumpTests.swift index 36065de..cf680e2 100644 --- a/Tests/CustomDumpTests/DumpTests.swift +++ b/Tests/CustomDumpTests/DumpTests.swift @@ -723,7 +723,7 @@ final class DumpTests: XCTestCase { let age = 97 } - class Doctor: Human, CustomDumpIncludeSuperclass { + class Doctor: Human { let field = "Podiatry" } @@ -750,7 +750,7 @@ final class DumpTests: XCTestCase { let age = 97 } - class Doctor: Human, CustomDumpIncludeSuperclass { + class Doctor: Human { let field = "Podiatry" }