Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Sources/SWONMacros/Decoding.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ struct SWONDecodeMacro: MemberMacro {
} else {
// Parse struct fields
for prop in properties {
// Skip computed properties
guard prop.bindings.allSatisfy({ !$0.isComputed }) else {
continue
}
guard let field = prop.bindings.first?.pattern.as(IdentifierPatternSyntax.self)?.identifier.text else {
continue
}
Expand Down
4 changes: 4 additions & 0 deletions Sources/SWONMacros/Encoding.swift
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ struct SWONEncodeMacro: MemberMacro {
} else {
// Struct fields
for prop in properties {
// Skip computed properties
guard prop.bindings.allSatisfy({ !$0.isComputed }) else {
continue
}
guard let field = prop.bindings.first?.pattern.as(IdentifierPatternSyntax.self)?.identifier.text else {
continue
}
Expand Down
6 changes: 6 additions & 0 deletions Sources/SWONMacros/Helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ extension EnumDeclSyntax {
}
}

extension PatternBindingSyntax {
var isComputed: Bool {
accessorBlock != nil
}
}

struct SWONMessage: DiagnosticMessage {
let severity: DiagnosticSeverity = .note
let message: String
Expand Down