Replies: 1 comment 1 reply
-
|
Hey @marcisme, thanks for sharing. It's a pretty interesting idea and something we hadn't considered. We're not sure exactly how it would work, but one possibility (if macros are up for the challenge) may be a kind of two step process for defining a struct with the data you want from the class, and then a step to extend the class with the snapshot functionality: @DebugSnapshotValue(target: CLLocation.self)
struct Location {
// All fields you want from `CLLocation`. Names and types would have to exactly match.
var coordinate: CLLocationCoordinate2D
var timestamp: Date
}
@DebugSnapshot(target: Location.self)
extension CLLocation { /* nothing needed here */ }That should theoretically allow you to hold onto |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm curious if something similar to debug snapshots or extending it has been considered for use with Dependencies?
Some of the frameworks that I create dependency clients for vend types that have no public initializers, or sometimes even classes with inheritance hierarchies. Historically I've created
Equatablestruct wrappers with arawValueproperty, inspired by code like composable-core-location and composable-core-motion.My understanding is macros can't be applied to types outside of their definition, but it could be possible to create a macro that could be used with a type that accepts a target type and key paths to the properties to generate. Something like (pseudocode):
Creating the needed boilerplate for types like this is much less onerous these days, and sometimes I'd rather have generated code than a macro. I also just had some bad cglib/AspectJ flashbacks. Regardless it is a possible bug vector, and
@DebugSnapshotseems to already do much of what would be needed, if viable.Beta Was this translation helpful? Give feedback.
All reactions