Closed jaseilers closed 3 months ago
Played around with a few other possible solutions, but still feel AutoRegistering is best. Added the following to the Container
documentation.
One can add auto registration capabilities to Factory's default container as well, but as of Swift 6 you'll need to add the @retroactive
attribute to the AutoRegistering
protocol definition.
extension Container: @retroactive AutoRegistering {
func autoRegister() {
someService.register { ModuleB.SomeService() }
}
}
This new attribute silences the warning, "Extension declares a conformance of imported type 'Container' to imported protocol 'AutoRegistering'; this will not behave correctly if the owners of 'Factory' introduce this conformance in the future".
Yeah. Me too. I know the developers of Swift mean well, but sometimes...
Declaring the conformance
AutoRegistering
toContainer
triggers the accepted proposal retroactive conformances warning in Swift 6:I'm aware that retroactive conformance is an API design choice in Factory and we won't run into the pitfall of multiple conformances since it wouldn't make sense for the library to add conformance here. But since it's discouraged by the Swift evolution: Do you intend to change features like
AutoRegistering
to fix it or will@retroactive
be the recommended solution?