From 065f4ebe3cb987fea22f3f9502763f8669ff0241 Mon Sep 17 00:00:00 2001 From: Christian Cabarrocas Date: Thu, 24 Oct 2024 13:41:37 +0200 Subject: [PATCH] Fix macros (#18) --- .../CodableMacros/Builders/DecodeVariableBuild.swift | 4 ++-- .../CodableMacrosTests/CustomDecodableTests.swift | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Sources/SageSwiftKitMacros/CodableMacros/Builders/DecodeVariableBuild.swift b/Sources/SageSwiftKitMacros/CodableMacros/Builders/DecodeVariableBuild.swift index 4fe9f14..72f78bf 100644 --- a/Sources/SageSwiftKitMacros/CodableMacros/Builders/DecodeVariableBuild.swift +++ b/Sources/SageSwiftKitMacros/CodableMacros/Builders/DecodeVariableBuild.swift @@ -186,7 +186,7 @@ struct DecodeVariableBuild { } func buildStringOrInt(attribute: AttributeSyntax) -> CodeBlockItemSyntaxBuilder { - guard type == "String" else { + guard type == "String?" else { return buildBasicDecode() } @@ -221,7 +221,7 @@ struct DecodeVariableBuild { } func buildStringOrDouble(attribute: AttributeSyntax) -> CodeBlockItemSyntaxBuilder { - guard type == "String" else { + guard type == "String?" else { return buildBasicDecode() } diff --git a/Tests/SageSwiftKitTests/CodableMacrosTests/CustomDecodableTests.swift b/Tests/SageSwiftKitTests/CodableMacrosTests/CustomDecodableTests.swift index c3a8807..6ff2151 100644 --- a/Tests/SageSwiftKitTests/CodableMacrosTests/CustomDecodableTests.swift +++ b/Tests/SageSwiftKitTests/CodableMacrosTests/CustomDecodableTests.swift @@ -136,12 +136,12 @@ final class CustomDecodableTests: XCTestCase { @CustomCodable struct PlayingObject { @StringOrInt - var value: String + var value: String? } """, expandedSource: """ struct PlayingObject { - var value: String + var value: String? enum CodingKeys: String, CodingKey { case value @@ -180,12 +180,12 @@ final class CustomDecodableTests: XCTestCase { @CustomCodable struct PlayingObject { @StringOrDouble - var value: String + var value: String? } """, expandedSource: """ struct PlayingObject { - var value: String + var value: String? enum CodingKeys: String, CodingKey { case value