@@ -94,30 +94,40 @@ private void AddSerializableClass(INamedTypeSymbol? classSymbol)
94
94
95
95
if ( member is IPropertySymbol propertySymbol )
96
96
{
97
- classObject . PropertySymbols . Add ( propertySymbol ) ;
98
- CheckForSupportedGeneric ( propertySymbol . Type ) ;
97
+ if ( ! classObject . PropertySymbols . ContainsName ( propertySymbol ) )
98
+ {
99
+ classObject . PropertySymbols . Add ( propertySymbol ) ;
100
+ CheckForSupportedGeneric ( propertySymbol . Type ) ;
101
+ }
99
102
}
100
103
else if ( member is IFieldSymbol fieldSymbol )
101
104
{
102
- classObject . FieldSymbols . Add ( fieldSymbol ) ;
103
- CheckForSupportedGeneric ( fieldSymbol . Type ) ;
105
+ if ( ! classObject . FieldSymbols . ContainsName ( fieldSymbol ) )
106
+ {
107
+ classObject . FieldSymbols . Add ( fieldSymbol ) ;
108
+ CheckForSupportedGeneric ( fieldSymbol . Type ) ;
109
+ }
104
110
}
105
111
else if ( member is IMethodSymbol methodSymbol )
106
112
{
107
113
var methodAttributes = methodSymbol . GetAttributes ( ) ;
108
- if ( methodAttributes . Any ( x => x . AttributeClass ! . ToDisplayString ( ) == "YamlDotNet.Serialization.Callbacks.OnDeserializedAttribute" ) )
114
+ if ( methodAttributes . Any ( x => x . AttributeClass ! . ToDisplayString ( ) == "YamlDotNet.Serialization.Callbacks.OnDeserializedAttribute" )
115
+ && ! classObject . OnDeserializedMethods . ContainsName ( methodSymbol ) )
109
116
{
110
117
classObject . OnDeserializedMethods . Add ( methodSymbol ) ;
111
118
}
112
- if ( methodAttributes . Any ( x => x . AttributeClass ! . ToDisplayString ( ) == "YamlDotNet.Serialization.Callbacks.OnDeserializingAttribute" ) )
119
+ if ( methodAttributes . Any ( x => x . AttributeClass ! . ToDisplayString ( ) == "YamlDotNet.Serialization.Callbacks.OnDeserializingAttribute" )
120
+ && ! classObject . OnDeserializingMethods . ContainsName ( methodSymbol ) )
113
121
{
114
122
classObject . OnDeserializingMethods . Add ( methodSymbol ) ;
115
123
}
116
- if ( methodAttributes . Any ( x => x . AttributeClass ! . ToDisplayString ( ) == "YamlDotNet.Serialization.Callbacks.OnSerializedAttribute" ) )
124
+ if ( methodAttributes . Any ( x => x . AttributeClass ! . ToDisplayString ( ) == "YamlDotNet.Serialization.Callbacks.OnSerializedAttribute" )
125
+ && ! classObject . OnSerializedMethods . ContainsName ( methodSymbol ) )
117
126
{
118
127
classObject . OnSerializedMethods . Add ( methodSymbol ) ;
119
128
}
120
- if ( methodAttributes . Any ( x => x . AttributeClass ! . ToDisplayString ( ) == "YamlDotNet.Serialization.Callbacks.OnSerializingAttribute" ) )
129
+ if ( methodAttributes . Any ( x => x . AttributeClass ! . ToDisplayString ( ) == "YamlDotNet.Serialization.Callbacks.OnSerializingAttribute" )
130
+ && ! classObject . OnSerializingMethods . ContainsName ( methodSymbol ) )
121
131
{
122
132
classObject . OnSerializingMethods . Add ( methodSymbol ) ;
123
133
}
@@ -146,10 +156,12 @@ private void CheckForSupportedGeneric(ITypeSymbol type)
146
156
else if ( typeName . StartsWith ( "System.Collections.Generic.Dictionary" ) )
147
157
{
148
158
Classes . Add ( sanitizedTypeName , new ClassObject ( sanitizedTypeName , ( INamedTypeSymbol ) type , true ) ) ;
159
+ CheckForSupportedGeneric ( ( ( INamedTypeSymbol ) type ) . TypeArguments [ 1 ] ) ;
149
160
}
150
161
else if ( typeName . StartsWith ( "System.Collections.Generic.List" ) )
151
162
{
152
163
Classes . Add ( sanitizedTypeName , new ClassObject ( sanitizedTypeName , ( INamedTypeSymbol ) type , isList : true ) ) ;
164
+ CheckForSupportedGeneric ( ( ( INamedTypeSymbol ) type ) . TypeArguments [ 0 ] ) ;
153
165
}
154
166
}
155
167
}
0 commit comments