diff --git a/src/GlobalSuppressions.cs b/src/GlobalSuppressions.cs index e9653745..8a50d39d 100644 --- a/src/GlobalSuppressions.cs +++ b/src/GlobalSuppressions.cs @@ -175,7 +175,7 @@ #endregion #region CA2000 Dispose objects -[assembly: SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Scope = "member", Target = "Microsoft.Restier.Publishers.OData.RestierController.#CreateQueryResponse(System.Linq.IQueryable,Microsoft.OData.Edm.IEdmType,System.Boolean,System.Web.OData.Formatter.ETag)")] +[assembly: SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Scope = "member", Target = "Microsoft.Restier.Publishers.OData.RestierController.#CreateQueryResponse(System.Linq.IQueryable,Microsoft.OData.Edm.IEdmType,System.Web.OData.Formatter.ETag)")] [assembly: SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Scope = "member", Target = "Microsoft.Restier.Publishers.OData.RestierExceptionFilterAttribute.#HandleCommonException(System.Web.Http.Filters.HttpActionExecutedContext,System.Boolean,System.Threading.CancellationToken)")] #endregion diff --git a/src/Microsoft.Restier.Publishers.OData/Formatter/Deserialization/DeserializationHelpers.cs b/src/Microsoft.Restier.Publishers.OData/Formatter/Deserialization/DeserializationHelpers.cs index 2d912dbc..acb1c2eb 100644 --- a/src/Microsoft.Restier.Publishers.OData/Formatter/Deserialization/DeserializationHelpers.cs +++ b/src/Microsoft.Restier.Publishers.OData/Formatter/Deserialization/DeserializationHelpers.cs @@ -33,16 +33,6 @@ internal static object ConvertValue( Request = request }; - // Enum logic can be removed after RestierEnumDeserializer extends ODataEnumDeserializer - var deserializerProvider = serviceProvider.GetService(); - var enumValue = odataValue as ODataEnumValue; - if (enumValue != null) - { - ODataEdmTypeDeserializer deserializer - = deserializerProvider.GetEdmTypeDeserializer(propertyType.AsEnum()); - return deserializer.ReadInline(enumValue, propertyType, readContext); - } - var returnValue = ODataModelBinderConverter.Convert( odataValue, propertyType, expectedReturnType, parameterName, readContext, serviceProvider); diff --git a/src/Microsoft.Restier.Publishers.OData/Formatter/Deserialization/RestierEnumDeserializer.cs b/src/Microsoft.Restier.Publishers.OData/Formatter/Deserialization/RestierEnumDeserializer.cs index b5786406..92713960 100644 --- a/src/Microsoft.Restier.Publishers.OData/Formatter/Deserialization/RestierEnumDeserializer.cs +++ b/src/Microsoft.Restier.Publishers.OData/Formatter/Deserialization/RestierEnumDeserializer.cs @@ -12,15 +12,10 @@ namespace Microsoft.Restier.Publishers.OData.Formatter /// /// The serializer for enum result. /// - internal class RestierEnumDeserializer : ODataEdmTypeDeserializer + internal class RestierEnumDeserializer : ODataEnumDeserializer { private ODataEnumDeserializer enumDeserializer = new ODataEnumDeserializer(); - public RestierEnumDeserializer() - : base(ODataPayloadKind.Property) - { - } - /// public override object Read( ODataMessageReader messageReader, diff --git a/src/Microsoft.Restier.Publishers.OData/RestierController.cs b/src/Microsoft.Restier.Publishers.OData/RestierController.cs index 3805de69..0a3c5cb7 100644 --- a/src/Microsoft.Restier.Publishers.OData/RestierController.cs +++ b/src/Microsoft.Restier.Publishers.OData/RestierController.cs @@ -86,9 +86,6 @@ public async Task Get( IQueryable queryable = this.GetQuery(path); ETag etag; - // TODO This flag can be removed when Etag isIfNoneMatch is changed to public. - bool isIfNoneMatch; - // TODO #365 Do not support additional path segment after function call now if (lastSegment is OperationImportSegment) { @@ -97,7 +94,7 @@ public async Task Get( Func getParaValueFunc = p => unboundSegment.GetParameterValue(p); result = await ExecuteOperationAsync( getParaValueFunc, operation.Name, true, null, cancellationToken); - result = ApplyQueryOptions(result, path, true, out isIfNoneMatch, out etag); + result = ApplyQueryOptions(result, path, true, out etag); } else { @@ -119,16 +116,16 @@ public async Task Get( result = await ExecuteOperationAsync( getParaValueFunc, operation.Name, true, result, cancellationToken); - result = ApplyQueryOptions(result, path, true, out isIfNoneMatch, out etag); + result = ApplyQueryOptions(result, path, true, out etag); } else { - queryable = ApplyQueryOptions(queryable, path, false, out isIfNoneMatch, out etag); + queryable = ApplyQueryOptions(queryable, path, false, out etag); result = await ExecuteQuery(queryable, cancellationToken); } } - return this.CreateQueryResponse(result, path.EdmType, isIfNoneMatch, etag); + return this.CreateQueryResponse(result, path.EdmType, etag); } /// @@ -330,7 +327,7 @@ public async Task PostAction( return this.Request.CreateResponse(HttpStatusCode.NoContent); } - return this.CreateQueryResponse(result, path.EdmType, false, null); + return this.CreateQueryResponse(result, path.EdmType, null); } private static IEdmTypeReference GetTypeReference(IEdmType edmType) @@ -418,7 +415,7 @@ private async Task Update( } private HttpResponseMessage CreateQueryResponse( - IQueryable query, IEdmType edmType, bool isIfNoneMatch, ETag etag) + IQueryable query, IEdmType edmType, ETag etag) { IEdmTypeReference typeReference = GetTypeReference(edmType); BaseSingleResult singleResult = null; @@ -504,7 +501,7 @@ private HttpResponseMessage CreateQueryResponse( etag.EntityType = query.ElementType; query = etag.ApplyTo(query); entityResult = query.SingleOrDefault(); - if (entityResult == null && !isIfNoneMatch) + if (entityResult == null && !etag.IsIfNoneMatch) { return this.Request.CreateResponse(HttpStatusCode.PreconditionFailed); } @@ -537,10 +534,8 @@ private IQueryable GetQuery(ODataPath path) } private IQueryable ApplyQueryOptions( - IQueryable queryable, ODataPath path, bool applyCount, out bool isIfNoneMatch, out ETag etag) + IQueryable queryable, ODataPath path, bool applyCount, out ETag etag) { - // ETAG IsIfNoneMatch is changed to public access, this flag can be removed. - isIfNoneMatch = false; etag = null; if (this.shouldWriteRawValue) @@ -562,7 +557,6 @@ private IQueryable ApplyQueryOptions( } else if (queryOptions.IfNoneMatch != null) { - isIfNoneMatch = true; etag = queryOptions.IfNoneMatch; } diff --git a/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Northwind.Tests/OperationTests.cs b/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Northwind.Tests/OperationTests.cs index d3ae88d8..6c15051e 100644 --- a/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Northwind.Tests/OperationTests.cs +++ b/test/ODataEndToEnd/Microsoft.OData.Service.Sample.Northwind.Tests/OperationTests.cs @@ -5,9 +5,7 @@ using System.Text; using System.Threading.Tasks; using System.Web.Http; -using System.Web.OData.Extensions; using Microsoft.OData.Service.Sample.Northwind.Models; -using Microsoft.OData.UriParser; using Microsoft.Restier.Tests; using Xunit;