diff --git a/src/Microsoft.AspNetCore.OData/Edm/ODataNullValueExtensions.cs b/src/Microsoft.AspNetCore.OData/Edm/ODataNullValueExtensions.cs new file mode 100644 index 000000000..e27ae74e0 --- /dev/null +++ b/src/Microsoft.AspNetCore.OData/Edm/ODataNullValueExtensions.cs @@ -0,0 +1,16 @@ +//----------------------------------------------------------------------------- +// +// Copyright (c) .NET Foundation and Contributors. All rights reserved. +// See License.txt in the project root for license information. +// +//------------------------------------------------------------------------------ + +using Microsoft.OData; + +namespace Microsoft.AspNetCore.OData.Edm +{ + internal class ODataNullValueExtensions + { + public static readonly ODataNullValue NullValue = new ODataNullValue(); + } +} diff --git a/src/Microsoft.AspNetCore.OData/Formatter/Serialization/ODataEnumSerializer.cs b/src/Microsoft.AspNetCore.OData/Formatter/Serialization/ODataEnumSerializer.cs index c81551990..1f5104d64 100644 --- a/src/Microsoft.AspNetCore.OData/Formatter/Serialization/ODataEnumSerializer.cs +++ b/src/Microsoft.AspNetCore.OData/Formatter/Serialization/ODataEnumSerializer.cs @@ -64,7 +64,7 @@ public sealed override ODataValue CreateODataValue(object graph, IEdmTypeReferen ODataEnumValue value = CreateODataEnumValue(graph, expectedType.AsEnum(), writeContext); if (value == null) { - return new ODataNullValue(); + return ODataNullValueExtensions.NullValue; } return value; diff --git a/src/Microsoft.AspNetCore.OData/Formatter/Serialization/ODataPrimitiveSerializer.cs b/src/Microsoft.AspNetCore.OData/Formatter/Serialization/ODataPrimitiveSerializer.cs index 931067c07..936971e6e 100644 --- a/src/Microsoft.AspNetCore.OData/Formatter/Serialization/ODataPrimitiveSerializer.cs +++ b/src/Microsoft.AspNetCore.OData/Formatter/Serialization/ODataPrimitiveSerializer.cs @@ -10,8 +10,7 @@ using System.Threading.Tasks; using System.Xml.Linq; using Microsoft.AspNetCore.OData.Common; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Options; +using Microsoft.AspNetCore.OData.Edm; using Microsoft.OData; using Microsoft.OData.Edm; @@ -65,7 +64,7 @@ public sealed override ODataValue CreateODataValue(object graph, IEdmTypeReferen ODataPrimitiveValue value = CreateODataPrimitiveValue(graph, expectedType.AsPrimitive(), writeContext); if (value == null) { - return new ODataNullValue(); + return ODataNullValueExtensions.NullValue; } return value; diff --git a/src/Microsoft.AspNetCore.OData/Formatter/Serialization/ODataResourceSerializer.cs b/src/Microsoft.AspNetCore.OData/Formatter/Serialization/ODataResourceSerializer.cs index 4e2221af7..bf7cf00c3 100644 --- a/src/Microsoft.AspNetCore.OData/Formatter/Serialization/ODataResourceSerializer.cs +++ b/src/Microsoft.AspNetCore.OData/Formatter/Serialization/ODataResourceSerializer.cs @@ -286,7 +286,7 @@ private static IEnumerable CreateODataPropertiesFromDynamicType(E property = new ODataProperty { Name = prop.Key, - Value = new ODataNullValue() + Value = ODataNullValueExtensions.NullValue }; } else @@ -618,7 +618,7 @@ public virtual void AppendDynamicProperties(ODataResource resource, SelectExpand dynamicProperties.Add(new ODataProperty { Name = dynamicProperty.Key, - Value = new ODataNullValue() + Value = ODataNullValueExtensions.NullValue }); continue; diff --git a/src/Microsoft.AspNetCore.OData/Microsoft.AspNetCore.OData.xml b/src/Microsoft.AspNetCore.OData/Microsoft.AspNetCore.OData.xml index 3bdc9e386..24994c504 100644 --- a/src/Microsoft.AspNetCore.OData/Microsoft.AspNetCore.OData.xml +++ b/src/Microsoft.AspNetCore.OData/Microsoft.AspNetCore.OData.xml @@ -1102,20 +1102,6 @@ The type to test. True if the type is a DateTime; false otherwise. - - - Determine if a type is a . - - The type to test. - True if the type is a DateOnly; false otherwise. - - - - Determine if a type is a . - - The type to test. - True if the type is a TimeOnly; false otherwise. - Determine if a type is a TimeSpan. @@ -5907,7 +5893,7 @@ Read OData item. - The odata reader. + The OData reader. The item stack. The top level item.