pointfreeco / swift-custom-dump

A collection of tools for debugging, diffing, and testing your application's data structures.
MIT License
800 stars 89 forks source link

Add new helper protocols to dump to control which child nodes are included in the dump #59

Closed tahirmt closed 2 years ago

tahirmt commented 2 years ago

Draft because it is based off of #58.

Motivation

The Current method of using CustomDumpReflectable can be used to include/exclude properties from the resulting dump but it requires implementing a custom mirror as described in https://github.com/pointfreeco/swift-custom-dump/blob/c9b6b940d95c0a925c63f6858943415714d8a981/Sources/CustomDump/CustomDumpReflectable.swift#L30. So for example if someone wants to exclude one property from an object with 20 properties, it will require creating a map with 19 properties to create a custom mirror. With CustomDumpExcludedChildNodesProvider the same result can be achieved by 2-3 lines and a simple string based array.

Open to naming suggestions and improvements.

stephencelis commented 2 years ago

@tahirmt Thanks for these general explorations! Sorry to push back again on added protocol surface area, but we already think the 3 this repo ships with is a lot 😄

I wonder if there's a more general infrastructure we could provide for customization points like this. Like is there a concept similar to SwiftSyntax's Visitor, which could be used to fully customize how a dump is done for a given node. Might take more time to think about, but just wanted to give you an initial thought as a library maintainer.

tahirmt commented 2 years ago

I'm going to close this since this isn't something we want to introduce