mockolo
mockolo copied to clipboard
Suppress Sendable protocol warnings
I want to create a mock from a protocol that inherits from Sendable
with this OSS, but I have a problem.
Mocks generated by this OSS have variables, so if I generate a mock from a protocol that inherits from Sendable
, I get a warning as shown below.
/// @mockable
protocol Hoge: Sendable {
func hoge() -> Int
}
↓ generated
final class HogeMock: Hoge {
init() { }
private(set) var hogeCallCount = 0 // warning: Stored property 'hogeCallCount' of 'Sendable'-conforming class 'HogeMock' is mutable
var hogeHandler: (() -> (Int))?
func hoge() -> Int {
hogeCallCount += 1
if let hogeHandler = hogeHandler {
return hogeHandler()
}
return 0
}
}
I want to suppress unnecessary warnings because they reduce visibility and make it difficult to notice necessary warnings. For this reason, I would like to suggest that mocks generated from protocols that inherit from Sendable be marked with @unchecked sendable
.
Thank you.