Skip to content

Conversation

@ashender
Copy link

rename property wrappers to avoid clash with Factory ones

- @injected → @ResolverInjected
- @OptionalInjected → @ResolverOptionalInjected
- @LazyInjected → @ResolverLazyInjected
- @WeakLazyInjected → @ResolverWeakLazyInjected
- @InjectedObject → @ResolverInjectedObject

This resolves naming conflicts with the Factory DI framework when both are used together.
Copy link

@0x0sky 0x0sky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, but take a look at the comments — there’s a genuine intention to help polish this.

}


class InjectedCyclicA {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why didn't you use a 'final' keyword?
'
Swift gives us a final keyword just for this purpose: when you declare a class as being final, no other class can inherit from it. This means they can’t override your methods in order to change your behavior – they need to use your class the way it was written.
'

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noting that those are tests and not part of the library per se.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You were right+ It was only later that I noticed the word test!

@ResolverInjected(name: "fred") var service: XYZNameService
}

class NamedInjectedViewController2 {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

y didn’t you use the final keyword here (if it isn’t already inherited)?

@discardableResult
public static func register<Service>(_ type: Service.Type = Service.self, name: Resolver.Name? = nil,
factory: @escaping ResolverFactory<Service>) -> ResolverOptions<Service> {
factory: @escaping ResolverFactorySendable<Service>) -> ResolverOptions<Service> {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line-break


class ContainerInjectedViewController {
@Injected(container: .custom) var service: XYZNameService
@ResolverInjected(container: .custom) var service: XYZNameService
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this outside the class?
In Ruby, I’d usually keep properties as isolated as possible.
Swift tends to rely more on access-level modifiers.

@hmlongco
Copy link
Owner

hmlongco commented Jan 3, 2026

Several things. First, Resolver is deprecated in favor of Factory. Second, renaming major components is a breaking change and would be outside of a point release.

Third, and in light of the first two cases, I see no need to use both libraries in the same project.

@hmlongco hmlongco closed this Jan 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants