diff --git a/Sources/SafeDICore/Errors/FixableInjectableError.swift b/Sources/SafeDICore/Errors/FixableInjectableError.swift index feec2ec3..88e40935 100644 --- a/Sources/SafeDICore/Errors/FixableInjectableError.swift +++ b/Sources/SafeDICore/Errors/FixableInjectableError.swift @@ -30,6 +30,8 @@ public enum FixableInjectableError: DiagnosticError { } } + public var localizedDescription: String { description } + public var diagnostic: DiagnosticMessage { InjectableDiagnosticMessage(error: self) } diff --git a/Sources/SafeDICore/Errors/FixableInstantiableError.swift b/Sources/SafeDICore/Errors/FixableInstantiableError.swift index 5f87c7fb..1ec899af 100644 --- a/Sources/SafeDICore/Errors/FixableInstantiableError.swift +++ b/Sources/SafeDICore/Errors/FixableInstantiableError.swift @@ -58,6 +58,8 @@ public enum FixableInstantiableError: DiagnosticError { } } + public var localizedDescription: String { description } + public var diagnostic: DiagnosticMessage { InstantiableDiagnosticMessage(error: self) } diff --git a/Sources/SafeDICore/Generators/DependencyTreeGenerator.swift b/Sources/SafeDICore/Generators/DependencyTreeGenerator.swift index 5f6aabfd..b3c804e7 100644 --- a/Sources/SafeDICore/Generators/DependencyTreeGenerator.swift +++ b/Sources/SafeDICore/Generators/DependencyTreeGenerator.swift @@ -93,6 +93,8 @@ public final class DependencyTreeGenerator { } } + var localizedDescription: String { description } + struct UnfulfillableProperty: Hashable, Comparable { static func < (lhs: DependencyTreeGenerator.DependencyTreeGeneratorError.UnfulfillableProperty, rhs: DependencyTreeGenerator.DependencyTreeGeneratorError.UnfulfillableProperty) -> Bool { lhs.property < rhs.property diff --git a/Sources/SafeDICore/Generators/ScopeGenerator.swift b/Sources/SafeDICore/Generators/ScopeGenerator.swift index 96da7999..608034be 100644 --- a/Sources/SafeDICore/Generators/ScopeGenerator.swift +++ b/Sources/SafeDICore/Generators/ScopeGenerator.swift @@ -285,6 +285,8 @@ actor ScopeGenerator { "Property `\(property.asSource)` on \(instantiable.concreteInstantiableType.asSource) incorrectly configured. Property should instead be of type `\(Dependency.forwardingInstantiatorType)<\(expectedType.asSource), \(property.typeDescription.asInstantiatedType.asSource)>`. First generic argument must match type of @\(Dependency.Source.forwarded.rawValue) property." } } + + var localizedDescription: String { description } } } diff --git a/Sources/SafeDICore/Models/Scope.swift b/Sources/SafeDICore/Models/Scope.swift index fe245394..ae411645 100644 --- a/Sources/SafeDICore/Models/Scope.swift +++ b/Sources/SafeDICore/Models/Scope.swift @@ -133,5 +133,7 @@ final class Scope { """ } } + + var localizedDescription: String { description } } } diff --git a/Sources/SafeDIMacros/Macros/InjectableMacro.swift b/Sources/SafeDIMacros/Macros/InjectableMacro.swift index 81ef9480..bbfca264 100644 --- a/Sources/SafeDIMacros/Macros/InjectableMacro.swift +++ b/Sources/SafeDIMacros/Macros/InjectableMacro.swift @@ -121,5 +121,7 @@ public struct InjectableMacro: PeerMacro { "The argument `ofType` must be a type literal" } } + + var localizedDescription: String { description } } } diff --git a/Sources/SafeDIMacros/Macros/InstantiableMacro.swift b/Sources/SafeDIMacros/Macros/InstantiableMacro.swift index 21eeddf2..2b24ee84 100644 --- a/Sources/SafeDIMacros/Macros/InstantiableMacro.swift +++ b/Sources/SafeDIMacros/Macros/InstantiableMacro.swift @@ -209,5 +209,7 @@ public struct InstantiableMacro: MemberMacro { "@\(InstantiableVisitor.macroName)-decorated extension must have a single `instantiate()` method" } } + + var localizedDescription: String { description } } } diff --git a/Sources/SafeDITool/SafeDITool.swift b/Sources/SafeDITool/SafeDITool.swift index cb56ea6a..49830297 100644 --- a/Sources/SafeDITool/SafeDITool.swift +++ b/Sources/SafeDITool/SafeDITool.swift @@ -221,11 +221,11 @@ struct SafeDITool: AsyncParsableCommand { let nestedInstantiableDecoratedTypeDescriptions: [TypeDescription] } - private enum CollectInstantiablesError: Error, CustomStringConvertible { + private enum CollectInstantiablesError: Error { case foundNestedInstantiables([String]) case foundDuplicateInstantiable(String) - var description: String { + var localizedDescription: String { switch self { case let .foundNestedInstantiables(nestedInstantiables): "@\(InstantiableVisitor.macroName) types must be top-level declarations. Found the following nested @\(InstantiableVisitor.macroName) types: \(nestedInstantiables.joined(separator: ", "))" diff --git a/Tests/SafeDIToolTests/SafeDIToolTests.swift b/Tests/SafeDIToolTests/SafeDIToolTests.swift index d1bc826a..4ab90141 100644 --- a/Tests/SafeDIToolTests/SafeDIToolTests.swift +++ b/Tests/SafeDIToolTests/SafeDIToolTests.swift @@ -2737,7 +2737,7 @@ final class SafeDIToolTests: XCTestCase { _ = try await block() } catch { didThrow = true - XCTAssertEqual((error as CustomStringConvertible).description, errorDescription, line: line) + XCTAssertEqual(error.localizedDescription, errorDescription, line: line) } XCTAssertTrue(didThrow, "Did not throw error!", line: line) }