Skip to content

Commit 6ff81ed

Browse files
committed
updates
1 parent a6c6763 commit 6ff81ed

File tree

4 files changed

+51
-27
lines changed

4 files changed

+51
-27
lines changed

src/Microsoft.AspNet.OData.Shared/Formatter/Deserialization/ODataResourceDeserializer.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -469,24 +469,24 @@ private ODataResourceWrapper UpdateResourceWrapper(ODataResourceWrapper resource
469469
{
470470
Contract.Assert(readContext != null);
471471

472-
if (resourceWrapper?.Resource?.Id == null)
472+
if (resourceWrapper?.ResourceBase?.Id == null)
473473
{
474474
return resourceWrapper;
475475
}
476476

477-
IEnumerable<ODataProperty> keys = CreateKeyProperties(resourceWrapper.Resource.Id, readContext);
477+
IEnumerable<ODataProperty> keys = CreateKeyProperties(resourceWrapper.ResourceBase.Id, readContext);
478478
if (keys == null)
479479
{
480480
return resourceWrapper;
481481
}
482482

483-
if (resourceWrapper.Resource.Properties == null)
483+
if (resourceWrapper.ResourceBase.Properties == null)
484484
{
485-
resourceWrapper.Resource.Properties = keys;
485+
resourceWrapper.ResourceBase.Properties = keys;
486486
}
487487
else
488488
{
489-
IDictionary<string, ODataProperty> newPropertiesDic = resourceWrapper.Resource.Properties.ToDictionary(p => p.Name, p => p);
489+
IDictionary<string, ODataProperty> newPropertiesDic = resourceWrapper.ResourceBase.Properties.ToDictionary(p => p.Name, p => p);
490490
foreach (ODataProperty key in keys)
491491
{
492492
if (!newPropertiesDic.ContainsKey(key.Name))
@@ -495,7 +495,7 @@ private ODataResourceWrapper UpdateResourceWrapper(ODataResourceWrapper resource
495495
}
496496
}
497497

498-
resourceWrapper.Resource.Properties = newPropertiesDic.Values;
498+
resourceWrapper.ResourceBase.Properties = newPropertiesDic.Values;
499499
}
500500

501501
return resourceWrapper;

src/Microsoft.AspNet.OData/GlobalSuppressions.cs

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -65,33 +65,24 @@
6565
[assembly: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Upsert", Scope = "member", Target = "Microsoft.AspNet.OData.DataModificationOperationKind.#Upsert")]
6666
[assembly: SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Upsert", Scope = "member", Target = "Org.OData.Core.V1.DataModificationOperationKind.#Upsert")]
6767
[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "Org.OData.Core.V1")]
68-
[assembly: SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "Microsoft.AspNet.OData.DeltaSet`1.#TryDeleteObject(System.Collections.Generic.IDictionary`2<System.String,System.Object>,System.String&)")]
69-
[assembly: SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "Microsoft.AspNet.OData.DeltaSet`1.#TryGetObject(System.Collections.Generic.IDictionary`2<System.String,System.Object>,System.Object&,System.String&)")]
70-
[assembly: SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "Microsoft.AspNet.OData.EdmChangedObjectCollection.#TryCreateObject(System.Object&,System.String&)")]
71-
[assembly: SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "Microsoft.AspNet.OData.EdmChangedObjectCollection.#TryDeleteObject(System.Collections.Generic.IDictionary`2<System.String,System.Object>,System.String&)")]
72-
[assembly: SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "Microsoft.AspNet.OData.EdmChangedObjectCollection.#TryGetObject(System.Collections.Generic.IDictionary`2<System.String,System.Object>,System.Object&,System.String&)")]
73-
[assembly: SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible", Scope = "type", Target = "Microsoft.AspNet.OData.PatchMethodHandler+TryCreate")]
74-
[assembly: SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible", Scope = "type", Target = "Microsoft.AspNet.OData.PatchMethodHandler+TryDelete")]
75-
[assembly: SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible", Scope = "type", Target = "Microsoft.AspNet.OData.PatchMethodHandler+TryGet")]
76-
[assembly: SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "Microsoft.AspNet.OData.DeltaSet`1.#TryCreateObject(System.Object&,System.String&)")]
77-
[assembly: SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#", Scope = "member", Target = "Microsoft.AspNet.OData.PatchMethodHandler+TryCreate.#Invoke(System.Object&,System.String&)")]
78-
[assembly: SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "1#", Scope = "member", Target = "Microsoft.AspNet.OData.PatchMethodHandler+TryCreate.#Invoke(System.Object&,System.String&)")]
79-
[assembly: SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "1#", Scope = "member", Target = "Microsoft.AspNet.OData.PatchMethodHandler+TryDelete.#Invoke(System.Collections.Generic.IDictionary`2<System.String,System.Object>,System.String&)")]
80-
[assembly: SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "2#", Scope = "member", Target = "Microsoft.AspNet.OData.PatchMethodHandler+TryGet.#Invoke(System.Collections.Generic.IDictionary`2<System.String,System.Object>,System.Object&,System.String&)")]
81-
[assembly: SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "1#", Scope = "member", Target = "Microsoft.AspNet.OData.PatchMethodHandler+TryGet.#Invoke(System.Collections.Generic.IDictionary`2<System.String,System.Object>,System.Object&,System.String&)")]
8268
[assembly: SuppressMessage("Microsoft.Design", "CA1040:AvoidEmptyInterfaces", Scope = "type", Target = "Microsoft.AspNet.OData.IDeltaSet")]
83-
[assembly: SuppressMessage("Microsoft.Design", "CA1007:UseGenericsWhereAppropriate", Scope = "member", Target = "Microsoft.AspNet.OData.PatchMethodHandler+TryCreate.#Invoke(System.Object&,System.String&)")]
84-
[assembly: SuppressMessage("Microsoft.Design", "CA1007:UseGenericsWhereAppropriate", Scope = "member", Target = "Microsoft.AspNet.OData.PatchMethodHandler+TryGet.#Invoke(System.Collections.Generic.IDictionary`2<System.String,System.Object>,System.Object&,System.String&)")]
85-
[assembly: SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#", Scope = "member", Target = "Microsoft.AspNet.OData.PatchMethodHandler`1.#TryCreate(!0&,System.String&)")]
86-
[assembly: SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "1#", Scope = "member", Target = "Microsoft.AspNet.OData.PatchMethodHandler`1.#TryCreate(!0&,System.String&)")]
8769
[assembly: SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "2#", Scope = "member", Target = "Microsoft.AspNet.OData.PatchMethodHandler`1.#TryGet(System.Collections.Generic.IDictionary`2<System.String,System.Object>,!0&,System.String&)")]
8870
[assembly: SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "1#", Scope = "member", Target = "Microsoft.AspNet.OData.PatchMethodHandler`1.#TryDelete(System.Collections.Generic.IDictionary`2<System.String,System.Object>,System.String&)")]
8971
[assembly: SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "1#", Scope = "member", Target = "Microsoft.AspNet.OData.PatchMethodHandler`1.#TryGet(System.Collections.Generic.IDictionary`2<System.String,System.Object>,!0&,System.String&)")]
9072
[assembly: SuppressMessage("Microsoft.Design", "CA1040:AvoidEmptyInterfaces", Scope = "type", Target = "Microsoft.AspNet.OData.IPatchMethodHandler")]
9173
[assembly: SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling", Scope = "member", Target = "Microsoft.AspNet.OData.Formatter.Serialization.DefaultODataSerializerProvider.#GetODataPayloadSerializerImpl(System.Type,System.Func`1<Microsoft.OData.Edm.IEdmModel>,Microsoft.AspNet.OData.Routing.ODataPath,System.Type)")]
92-
[assembly: SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "1#", Scope = "member", Target = "Microsoft.AspNet.OData.EdmPatchMethodHandler.#TryCreate(Microsoft.AspNet.OData.IEdmChangedObject,Microsoft.AspNet.OData.EdmStructuredObject&,System.String&)")]
93-
[assembly: SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "2#", Scope = "member", Target = "Microsoft.AspNet.OData.EdmPatchMethodHandler.#TryCreate(Microsoft.AspNet.OData.IEdmChangedObject,Microsoft.AspNet.OData.EdmStructuredObject&,System.String&)")]
94-
[assembly: SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "2#", Scope = "member", Target = "Microsoft.AspNet.OData.EdmPatchMethodHandler.#TryGet(System.Collections.Generic.IDictionary`2<System.String,System.Object>,Microsoft.AspNet.OData.EdmStructuredObject&,System.String&)")]
9574
[assembly: SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "1#", Scope = "member", Target = "Microsoft.AspNet.OData.EdmPatchMethodHandler.#TryDelete(System.Collections.Generic.IDictionary`2<System.String,System.Object>,System.String&)")]
9675
[assembly: SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "1#", Scope = "member", Target = "Microsoft.AspNet.OData.EdmPatchMethodHandler.#TryGet(System.Collections.Generic.IDictionary`2<System.String,System.Object>,Microsoft.AspNet.OData.EdmStructuredObject&,System.String&)")]
76+
[assembly: SuppressMessage("Microsoft.Globalization", "CA1305:SpecifyIFormatProvider", MessageId = "System.String.Format(System.String,System.Object,System.Object)", Scope = "member", Target = "Microsoft.AspNet.OData.Formatter.ClrTypeCache+EdmTypeCacheItemComparer.#GetHashCode(Microsoft.AspNet.OData.Formatter.ClrTypeCache+EdmTypeCacheItem)")]
77+
[assembly: SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "1#", Scope = "member", Target = "Microsoft.AspNet.OData.EdmPatchMethodHandler.#TryCreate(Microsoft.AspNet.OData.IEdmChangedObject,Microsoft.AspNet.OData.IEdmStructuredObject&,System.String&)")]
78+
[assembly: SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "2#", Scope = "member", Target = "Microsoft.AspNet.OData.EdmPatchMethodHandler.#TryCreate(Microsoft.AspNet.OData.IEdmChangedObject,Microsoft.AspNet.OData.IEdmStructuredObject&,System.String&)")]
79+
[assembly: SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "2#", Scope = "member", Target = "Microsoft.AspNet.OData.EdmPatchMethodHandler.#TryGet(System.Collections.Generic.IDictionary`2<System.String,System.Object>,Microsoft.AspNet.OData.IEdmStructuredObject&,System.String&)")]
80+
[assembly: SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "1#", Scope = "member", Target = "Microsoft.AspNet.OData.EdmPatchMethodHandler.#TryGet(System.Collections.Generic.IDictionary`2<System.String,System.Object>,Microsoft.AspNet.OData.IEdmStructuredObject&,System.String&)")]
81+
[assembly: SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Scope = "member", Target = "Microsoft.AspNet.OData.EdmDeltaDeletedEntityObject.#_edmType")]
82+
[assembly: SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Scope = "member", Target = "Microsoft.AspNet.OData.EdmDeltaDeletedLink.#_edmType")]
83+
[assembly: SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Scope = "member", Target = "Microsoft.AspNet.OData.EdmDeltaEntityObject.#_edmType")]
84+
[assembly: SuppressMessage("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields", Scope = "member", Target = "Microsoft.AspNet.OData.EdmDeltaLink.#_edmType")]
85+
[assembly: SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes", Scope = "member", Target = "Microsoft.AspNet.OData.Formatter.Deserialization.ODataResourceDeserializer.#CreateKeyProperties(System.Uri,Microsoft.AspNet.OData.Formatter.Deserialization.ODataDeserializerContext)")]
86+
[assembly: SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.AspNet.OData.Formatter.Deserialization.ODataResourceDeserializer.#CreateResourceWrapper(Microsoft.OData.Edm.IEdmTypeReference,Microsoft.AspNet.OData.Formatter.Deserialization.ODataEntityReferenceLinkBase,Microsoft.AspNet.OData.Formatter.Deserialization.ODataDeserializerContext)")]
87+
[assembly: SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Microsoft.AspNet.OData.Formatter.Deserialization.ODataResourceDeserializer.#UpdateResourceWrapper(Microsoft.AspNet.OData.Formatter.Deserialization.ODataResourceWrapper,Microsoft.AspNet.OData.Formatter.Deserialization.ODataDeserializerContext)")]
9788

test/E2ETest/Microsoft.Test.E2E.AspNet.OData/BulkOperation/BulkInsertController.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,11 @@ public ITestActionResult Patch(int key, [FromBody] Delta<Employee> delta)
359359
try
360360
{
361361
delta.Patch(employee, new EmployeePatchHandler());
362+
363+
if(employee.Name == "Bind1")
364+
{
365+
Assert.NotNull(employee.Friends.Single(x => x.Id == 3));
366+
}
362367
}
363368
catch (ArgumentException ae)
364369
{

test/E2ETest/Microsoft.Test.E2E.AspNet.OData/BulkOperation/BulkInsertTest.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,34 @@ public async Task PatchEmployee_WithDelete()
654654
}
655655
}
656656

657+
[Fact]
658+
public async Task PatchEmployee_WithODataBind()
659+
{
660+
//Arrange
661+
662+
string requestUri = this.BaseAddress + "/convention/Employees(1)";
663+
664+
var content = @"{
665+
'Name':'Bind1' ,
666+
'[email protected]':['Friends(3)']
667+
}";
668+
669+
var requestForPost = new HttpRequestMessage(new HttpMethod("PATCH"), requestUri);
670+
671+
StringContent stringContent = new StringContent(content: content, encoding: Encoding.UTF8, mediaType: "application/json");
672+
requestForPost.Content = stringContent;
673+
674+
//Act & Assert
675+
using (HttpResponseMessage response = await this.Client.SendAsync(requestForPost))
676+
{
677+
var json = response.Content.ReadAsStringAsync().Result;
678+
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
679+
}
680+
681+
682+
683+
}
684+
657685

658686
[Fact]
659687
public async Task PatchEmployee_WithAddUpdateAndDelete()

0 commit comments

Comments
 (0)