diff --git a/Sources/CustomDump/Conformances/KeyPath.swift b/Sources/CustomDump/Conformances/KeyPath.swift index a66ebec..3f8eea4 100644 --- a/Sources/CustomDump/Conformances/KeyPath.swift +++ b/Sources/CustomDump/Conformances/KeyPath.swift @@ -35,7 +35,11 @@ extension AnyKeyPath: CustomDumpStringConvertible { } return name #else - return typeName(Self.self, genericsAbbreviated: false) + return """ + \(typeName(Self.self))<\ + \(typeName(Self.rootType)), \ + \(typeName(Self.valueType,genericsAbbreviated: false))> + """ #endif } } diff --git a/Sources/CustomDump/Internal/AnyType.swift b/Sources/CustomDump/Internal/AnyType.swift index 0ef3481..d934bf5 100644 --- a/Sources/CustomDump/Internal/AnyType.swift +++ b/Sources/CustomDump/Internal/AnyType.swift @@ -5,13 +5,13 @@ func typeName( ) -> String { var name = _typeName(type, qualified: qualified) .replacingOccurrences( - of: #"\w+\.(\w+)"#, - with: "$1", + of: #"\(unknown context at \$[[:xdigit:]]+\)\."#, + with: "", options: .regularExpression ) .replacingOccurrences( - of: #"\(unknown context at \$[[:xdigit:]]+\)\."#, - with: "", + of: #"\w+\.([\w.]+)"#, + with: "$1", options: .regularExpression ) if genericsAbbreviated { diff --git a/Tests/CustomDumpTests/DumpTests.swift b/Tests/CustomDumpTests/DumpTests.swift index acc102b..46df8bf 100644 --- a/Tests/CustomDumpTests/DumpTests.swift +++ b/Tests/CustomDumpTests/DumpTests.swift @@ -24,6 +24,27 @@ final class DumpTests: XCTestCase { Foo.Bar.self """ ) + + struct Feature { + struct State {} + } + dump = "" + customDump(Feature.State.self, to: &dump) + XCTAssertNoDifference( + dump, + """ + DumpTests.Feature.State.self + """ + ) + + dump = "" + customDump((x: Double, y: Double).self, to: &dump) + XCTAssertNoDifference( + dump, + """ + (x: Double, y: Double).self + """ + ) } func testClass() {