Skip to content

Commit

Permalink
CR comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
biaol-odata committed Nov 13, 2018
1 parent fd97a44 commit 455f5bd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
{
Expand All @@ -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)
Expand Down
25 changes: 2 additions & 23 deletions src/Microsoft.OData.Core/SelectedPropertiesNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -492,32 +492,11 @@ internal IEnumerable<IEdmProperty> GetSelectedProperties(IEdmStructuredType stru
}

/// <summary>
/// Return names of dynamic properties.
/// </summary>
/// <param name="structuredType">The current structured type.</param>
/// <returns>The names of dynamic properties.</returns>
internal IEnumerable<string> GetSelectedDynamicProperties(IEdmStructuredType structuredType)
{
IEnumerable<string> dynamicProperties = Enumerable.Empty<string>();

if (this.selectedProperties != null && this.selectedProperties.Count > 0)
{
dynamicProperties = this.selectedProperties.Select(
prop => structuredType.FindProperty(prop) == null
? prop
: null)
.OfType<string>();
}

return dynamicProperties;
}

/// <summary>
/// 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.
/// </summary>
/// <param name="structuredType">The current structured type.</param>
/// <param name="resourceState">The current resource state.</param>
/// <returns>The list of property names with null values.</returns>
/// <returns>The list of property names missing from payload.</returns>
internal IList<string> GetSelectedNullValueProperties(IEdmStructuredType structuredType,
IODataJsonLightReaderResourceState resourceState)
{
Expand Down

0 comments on commit 455f5bd

Please sign in to comment.