Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create OptionalAbstractRegistration type #216

Merged
merged 2 commits into from
Dec 5, 2024

Conversation

skorulis-ap
Copy link
Collaborator

@skorulis-ap skorulis-ap commented Nov 14, 2024

Normally when we an abstract registration is created a placeholder during testing that will cause a fatal error making it easier to understand what has gone wrong. But for optional services it's possible to simply return nil and allow tests to continue along normally without the service.

@skorulis-ap skorulis-ap marked this pull request as ready for review November 14, 2024 08:03
@skorulis-ap skorulis-ap requested a review from bradfol November 14, 2024 08:03
@skorulis-ap skorulis-ap force-pushed the skorulis/optional-abstract-registration branch from 1734a1d to 19d6fd7 Compare December 4, 2024 04:23
Sources/Knit/Module/Container+AbstractRegistration.swift Outdated Show resolved Hide resolved
Comment on lines +79 to +82
let string = assembler.resolver.resolve(String?.self) ?? nil
XCTAssertNil(string)

let int = assembler.resolver.resolve(Optional<Int>.self) ?? nil
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why are there ?? nil on the resolution calls?

Copy link
Collaborator Author

@skorulis-ap skorulis-ap Dec 5, 2024

Choose a reason for hiding this comment

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

It converts from Int?? to Int?

Co-authored-by: Brad Fol <bradfol@users.noreply.github.com>
@skorulis-ap skorulis-ap merged commit b2c54c8 into main Dec 5, 2024
1 check passed
@skorulis-ap skorulis-ap deleted the skorulis/optional-abstract-registration branch December 5, 2024 02:22
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.

2 participants