@@ -4,6 +4,7 @@ import SwiftSyntaxMacros
44private struct ModelMemberProperty {
55 var name : String
66 var type : String
7+ var modifiers : DeclModifierListSyntax = [ ]
78 var isOptional : Bool = false
89 var normalKeys : [ String ] = [ ]
910 var nestedKeys : [ String ] = [ ]
@@ -43,11 +44,17 @@ struct ModelMemberPropertyContainer {
4344 }
4445
4546 private func attributesPrefix( option: AttributeOption ) -> String {
47+ let hasPublicProperites = memberProperties. contains ( where: {
48+ $0. modifiers. contains ( where: {
49+ $0. name. text == " public " || $0. name. text == " open "
50+ } )
51+ } )
52+
4653 let modifiers = decl. modifiers. compactMap { $0. name. text }
4754 var attributes : [ String ] = [ ]
4855 if option. contains ( . open) , modifiers. contains ( " open " ) {
4956 attributes. append ( " open " )
50- } else if option. contains ( . public) , modifiers. contains ( " open " ) || modifiers. contains ( " public " ) {
57+ } else if option. contains ( . public) , hasPublicProperites || modifiers. contains ( " open " ) || modifiers. contains ( " public " ) {
5158 attributes. append ( " public " )
5259 }
5360 if option. contains ( . required) , decl. is ( ClassDeclSyntax . self) {
@@ -56,6 +63,7 @@ struct ModelMemberPropertyContainer {
5663 if !attributes. isEmpty {
5764 attributes. append ( " " )
5865 }
66+
5967 return attributes. joined ( separator: " " )
6068 }
6169
@@ -178,6 +186,7 @@ private extension ModelMemberPropertyContainer {
178186 }
179187
180188 var mp = ModelMemberProperty ( name: name, type: type)
189+ mp. modifiers = variable. modifiers
181190 let attributes = variable. attributes
182191
183192 // isOptional
0 commit comments