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

Switch to using fileID macro #195

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions Sources/Knit/Module/Container+AbstractRegistration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,9 @@ extension Container {
public func registerAbstract<Service>(
_ serviceType: Service.Type,
name: String? = nil,
file: StaticString = #file
file: String = #fileID
) {
// Simplify the name to support Xcode 14.2.
// Once 14.2 support is dropped and #file becomes shortened this can be removed
let shortFile = URL(fileURLWithPath: file.description).lastPathComponent
let registration = RealAbstractRegistration<Service>(name: name, file: shortFile)
let registration = RealAbstractRegistration<Service>(name: name, file: file)
abstractRegistrations().abstractRegistrations.append(registration)
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Knit/Module/ModuleAssembler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public final class ModuleAssembler {
assemblyValidation: ((any ModuleAssembly.Type) throws -> Void)? = nil,
errorFormatter: ModuleAssemblerErrorFormatter = DefaultModuleAssemblerErrorFormatter(),
postAssemble: ((Container) -> Void)? = nil,
file: StaticString = #file,
file: StaticString = #fileID,
line: UInt = #line
) {
// Hold an optional reference to be used by error handling later
Expand Down
2 changes: 1 addition & 1 deletion Sources/Knit/Module/ScopedModuleAssembler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public final class ScopedModuleAssembler<ScopedResolver> {
overrideBehavior: OverrideBehavior = .defaultOverridesWhenTesting,
errorFormatter: ModuleAssemblerErrorFormatter = DefaultModuleAssemblerErrorFormatter(),
postAssemble: ((Container) -> Void)? = nil,
file: StaticString = #file,
file: StaticString = #fileID,
line: UInt = #line
) {
do {
Expand Down
4 changes: 2 additions & 2 deletions Tests/KnitTests/AbstractRegistrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ final class AbstractRegistrationTests: XCTestCase {
XCTAssertEqual(
error.localizedDescription,
"""
Unsatisfied abstract registration. Service: String, File: AbstractRegistrationTests.swift
Unsatisfied abstract registration. Service: String, File: AbstractRegistrationTests.swift, Name: test
Unsatisfied abstract registration. Service: String, File: KnitTests/AbstractRegistrationTests.swift
Unsatisfied abstract registration. Service: String, File: KnitTests/AbstractRegistrationTests.swift, Name: test
"""
)
}
Expand Down