diff --git a/Package.resolved b/Package.resolved new file mode 100644 index 0000000..fb062a5 --- /dev/null +++ b/Package.resolved @@ -0,0 +1,15 @@ +{ + "originHash" : "451a4227a52c5d76284cb42d2af427b33622a8db10ee88a856dc3a76ddb4d6cd", + "pins" : [ + { + "identity" : "swift-syntax", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-syntax.git", + "state" : { + "revision" : "64889f0c732f210a935a0ad7cda38f77f876262d", + "version" : "509.1.1" + } + } + ], + "version" : 3 +} diff --git a/Package.swift b/Package.swift index a8fb6e9..10b25b7 100644 --- a/Package.swift +++ b/Package.swift @@ -38,7 +38,7 @@ let package = Package( dependencies: ["Compose"] ), .testTarget( - name: "MacroTests", + name: "ComposeMacroTests", dependencies: [ "ComposeMacro", .product(name: "SwiftSyntaxMacrosTestSupport", package: "swift-syntax"), diff --git a/Sources/ComposeMacro/ComposableObjectMacro.swift b/Sources/ComposeMacro/ComposableObjectMacro.swift index 9a11880..1621756 100644 --- a/Sources/ComposeMacro/ComposableObjectMacro.swift +++ b/Sources/ComposeMacro/ComposableObjectMacro.swift @@ -68,7 +68,7 @@ private extension VariableDeclSyntax { } var isPrivateProperty: Bool { - modifier?.name.text == "private" + modifier?.name.text == "private" && modifier?.detail?.detail.text != "set" } } diff --git a/Tests/MacroTests/MacroTests.swift b/Tests/ComposeMacroTests/ComposeMacroTests.swift similarity index 66% rename from Tests/MacroTests/MacroTests.swift rename to Tests/ComposeMacroTests/ComposeMacroTests.swift index d5f5bdb..b6ee79c 100644 --- a/Tests/MacroTests/MacroTests.swift +++ b/Tests/ComposeMacroTests/ComposeMacroTests.swift @@ -1,5 +1,5 @@ // -// MacroTests.swift +// ComposeMacroTests.swift // // // Created by jsilver on 6/2/24. @@ -14,7 +14,7 @@ let testMacros: [String: Macro.Type] = [ "ComposableObject": ComposableObjectMacro.self, ] -final class MacroTests: XCTestCase { +final class ComposeMacroTests: XCTestCase { // MARK: - Property // MARK: - Lifecycle @@ -32,15 +32,21 @@ final class MacroTests: XCTestCase { """ @ComposableObject class Environment { - var a: Int = 0 - private var b: Int = 0 + public var a: Int = 0 + var b: Int = 0 + private(set) var c: Int = 0 + private var d: Int = 0 } """, expandedSource: """ class Environment { @Published - var a: Int = 0 - private var b: Int = 0 + public var a: Int = 0 + @Published + var b: Int = 0 + @Published + private(set) var c: Int = 0 + private var d: Int = 0 } extension Environment: ObservableObject {