Skip to content

Commit

Permalink
Merge pull request #4 from Ryu0118/fix-static-property
Browse files Browse the repository at this point in the history
Static properties are excluded from testValue
  • Loading branch information
Ryu0118 authored Oct 2, 2023
2 parents 39895af + b87d00b commit a4aa1dc
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 a4aa1dc

Please sign in to comment.