Skip to content

Commit

Permalink
Static properties are excluded from testValue
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryu0118 committed Oct 2, 2023
1 parent 505083e commit b87d00b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Sources/DependenciesMacroPlugin/DependenciesMacro.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ extension DependenciesMacro: ExtensionMacro {
) throws -> [ExtensionDeclSyntax] {
let structDecl = try decodeExpansion(of: node, attachedTo: declaration, in: context)
let storedPropertyBindings = structDecl.memberBlock.members
.compactMap { $0.decl.as(VariableDeclSyntax.self)?.bindings }
.compactMap { $0.decl.as(VariableDeclSyntax.self) }
.filter { !$0.modifiers.contains { $0.as(DeclModifierSyntax.self)?.name.text == "static" } }
.map(\.bindings)
.flatMap { $0 }
.filter { $0.accessorBlock == nil }
let modifier = declaration.modifiers
Expand Down
2 changes: 2 additions & 0 deletions Tests/DependenciesMacroTests/DependenciesMacroTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ final class DependenciesMacroTests: XCTestCase {
"""
@Dependencies
public struct TestClient {
static let staticValue = 0
let a: String
let b: () -> Void
let c: @Sendable () -> Void
Expand All @@ -73,6 +74,7 @@ final class DependenciesMacroTests: XCTestCase {
} matches: {
#"""
public struct TestClient {
static let staticValue = 0
let a: String
let b: () -> Void
let c: @Sendable () -> Void
Expand Down

0 comments on commit b87d00b

Please sign in to comment.