@@ -111,17 +111,6 @@ public JsonClassInfo(Type type, JsonSerializerOptions options)
111111 continue ;
112112 }
113113
114- if ( IsNonPublicProperty ( propertyInfo ) )
115- {
116- if ( JsonPropertyInfo . GetAttribute < JsonIncludeAttribute > ( propertyInfo ) != null )
117- {
118- ThrowHelper . ThrowInvalidOperationException_JsonIncludeOnNonPublicInvalid ( propertyInfo , currentType ) ;
119- }
120-
121- // Non-public properties should not be included for (de)serialization.
122- continue ;
123- }
124-
125114 // For now we only support public getters\setters
126115 if ( propertyInfo . GetMethod ? . IsPublic == true ||
127116 propertyInfo . SetMethod ? . IsPublic == true )
@@ -149,6 +138,15 @@ public JsonClassInfo(Type type, JsonSerializerOptions options)
149138 // else ignore jsonPropertyInfo since it has [JsonIgnore] or it's hidden by a new slot.
150139 }
151140 }
141+ else
142+ {
143+ if ( JsonPropertyInfo . GetAttribute < JsonIncludeAttribute > ( propertyInfo ) != null )
144+ {
145+ ThrowHelper . ThrowInvalidOperationException_JsonIncludeOnNonPublicInvalid ( propertyInfo , currentType ) ;
146+ }
147+
148+ // Non-public properties should not be included for (de)serialization.
149+ }
152150 }
153151 }
154152
@@ -211,13 +209,6 @@ public JsonClassInfo(Type type, JsonSerializerOptions options)
211209 }
212210 }
213211
214- private static bool IsNonPublicProperty ( PropertyInfo propertyInfo )
215- {
216- MethodInfo ? getMethod = propertyInfo . GetMethod ;
217- MethodInfo ? setMethod = propertyInfo . SetMethod ;
218- return ! ( ( getMethod != null && getMethod . IsPublic ) || ( setMethod != null && setMethod . IsPublic ) ) ;
219- }
220-
221212 private void InitializeConstructorParameters ( Dictionary < string , JsonPropertyInfo > propertyCache , ConstructorInfo constructorInfo )
222213 {
223214 ParameterInfo [ ] parameters = constructorInfo ! . GetParameters ( ) ;
0 commit comments