description
for main actor classes with Swift strict concurrency
Is there a best practice for implementing description
and debugDescription
for main actor classes with Swift strict concurrency? This works, but seems off:
override var description: String {
if Thread.isMainThread {
MainActor.assumeIsolated {
"\(type(of: self)) Property 1: \(property1), Property 2: \(property2)"
}
} else {
"\(type(of: self))(Not on main thread)"
}
}