From 455f5bd4b4c97fae6acdbcbc2ea34a2a90130df5 Mon Sep 17 00:00:00 2001 From: Biao Li Date: Tue, 13 Nov 2018 14:23:38 -0800 Subject: [PATCH] CR comments. --- .../ODataJsonLightPropertySerializer.cs | 9 +++---- .../SelectedPropertiesNode.cs | 25 ++----------------- 2 files changed, 6 insertions(+), 28 deletions(-) diff --git a/src/Microsoft.OData.Core/JsonLight/ODataJsonLightPropertySerializer.cs b/src/Microsoft.OData.Core/JsonLight/ODataJsonLightPropertySerializer.cs index 0403495fa4..40dad0c29e 100644 --- a/src/Microsoft.OData.Core/JsonLight/ODataJsonLightPropertySerializer.cs +++ b/src/Microsoft.OData.Core/JsonLight/ODataJsonLightPropertySerializer.cs @@ -186,8 +186,6 @@ private void WriteProperty( { WriterValidationUtils.ValidatePropertyNotNull(property); - ODataValue value = property.ODataValue; - string propertyName = property.Name; if (this.JsonLightOutputContext.MessageWriterSettings.Validations != ValidationKinds.None) @@ -204,6 +202,9 @@ private void WriteProperty( this.currentPropertyInfo = this.JsonLightOutputContext.PropertyCacheHandler.GetProperty(propertyName, owningType); } + WriterValidationUtils.ValidatePropertyDefined(this.currentPropertyInfo, this.MessageWriterSettings.ThrowOnUndeclaredPropertyForNonOpenType); + + duplicatePropertyNameChecker.ValidatePropertyUniqueness(property); if (currentPropertyInfo.MetadataType.IsUndeclaredProperty) { @@ -212,9 +213,7 @@ private void WriteProperty( WriteInstanceAnnotation(property, isTopLevel, currentPropertyInfo.MetadataType.IsUndeclaredProperty); - WriterValidationUtils.ValidatePropertyDefined(this.currentPropertyInfo, this.MessageWriterSettings.ThrowOnUndeclaredPropertyForNonOpenType); - - duplicatePropertyNameChecker.ValidatePropertyUniqueness(property); + ODataValue value = property.ODataValue; bool isNullValue = (value == null || value is ODataNullValue); if (isNullValue && omitNullValues) diff --git a/src/Microsoft.OData.Core/SelectedPropertiesNode.cs b/src/Microsoft.OData.Core/SelectedPropertiesNode.cs index 42fedf2e10..1e1b2e5b76 100644 --- a/src/Microsoft.OData.Core/SelectedPropertiesNode.cs +++ b/src/Microsoft.OData.Core/SelectedPropertiesNode.cs @@ -492,32 +492,11 @@ internal IEnumerable GetSelectedProperties(IEdmStructuredType stru } /// - /// Return names of dynamic properties. - /// - /// The current structured type. - /// The names of dynamic properties. - internal IEnumerable GetSelectedDynamicProperties(IEdmStructuredType structuredType) - { - IEnumerable dynamicProperties = Enumerable.Empty(); - - if (this.selectedProperties != null && this.selectedProperties.Count > 0) - { - dynamicProperties = this.selectedProperties.Select( - prop => structuredType.FindProperty(prop) == null - ? prop - : null) - .OfType(); - } - - return dynamicProperties; - } - - /// - /// Gets the list of names for selected declared or dynamic properties having values of null. + /// Gets the list of names for selected nullable declared or dynamic properties missing from payload. /// /// The current structured type. /// The current resource state. - /// The list of property names with null values. + /// The list of property names missing from payload. internal IList GetSelectedNullValueProperties(IEdmStructuredType structuredType, IODataJsonLightReaderResourceState resourceState) {