diff --git a/src/Microsoft.AspNetCore.OData/Formatter/Deserialization/ODataResourceDeserializer.cs b/src/Microsoft.AspNetCore.OData/Formatter/Deserialization/ODataResourceDeserializer.cs index 192a16725..4fdc92d2b 100644 --- a/src/Microsoft.AspNetCore.OData/Formatter/Deserialization/ODataResourceDeserializer.cs +++ b/src/Microsoft.AspNetCore.OData/Formatter/Deserialization/ODataResourceDeserializer.cs @@ -877,8 +877,8 @@ private ODataResourceWrapper UpdateResourceWrapper(ODataResourceWrapper resource } else { - IDictionary newPropertiesDic = resourceWrapper.Resource.Properties.ToDictionary(p => p.Name, p => p); - foreach (ODataProperty key in keys) + IDictionary newPropertiesDic = resourceWrapper.Resource.Properties.ToDictionary(p => p.Name, p => p); + foreach (ODataPropertyInfo key in keys) { // Logic: if we have the key property, try to keep the key property and get rid of the key value from ID. // Need to double confirm whether it is the right logic? diff --git a/src/Microsoft.AspNetCore.OData/Microsoft.AspNetCore.OData.csproj b/src/Microsoft.AspNetCore.OData/Microsoft.AspNetCore.OData.csproj index 40a632e65..403148b3c 100644 --- a/src/Microsoft.AspNetCore.OData/Microsoft.AspNetCore.OData.csproj +++ b/src/Microsoft.AspNetCore.OData/Microsoft.AspNetCore.OData.csproj @@ -28,13 +28,13 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/test/Microsoft.AspNetCore.OData.Tests/Formatter/Serialization/ODataResourceSerializerTests.cs b/test/Microsoft.AspNetCore.OData.Tests/Formatter/Serialization/ODataResourceSerializerTests.cs index 524e57028..52b9703b7 100644 --- a/test/Microsoft.AspNetCore.OData.Tests/Formatter/Serialization/ODataResourceSerializerTests.cs +++ b/test/Microsoft.AspNetCore.OData.Tests/Formatter/Serialization/ODataResourceSerializerTests.cs @@ -1009,30 +1009,30 @@ public void CreateResource_Works_ToAppendDynamicProperties_ForOpenEntityType() Assert.Equal(6, resource.Properties.Count()); // Verify the declared properties - ODataProperty street = Assert.Single(resource.Properties.Where(p => p.Name == "CustomerId")); + ODataProperty street = Assert.IsType(Assert.Single(resource.Properties.Where(p => p.Name == "CustomerId"))); Assert.Equal(991, street.Value); - ODataProperty city = Assert.Single(resource.Properties.Where(p => p.Name == "Name")); + ODataProperty city = Assert.IsType(Assert.Single(resource.Properties.Where(p => p.Name == "Name"))); Assert.Equal("Name #991", city.Value); // Verify the nested open complex property Assert.Empty(resource.Properties.Where(p => p.Name == "Address")); // Verify the dynamic properties - ODataProperty enumProperty = Assert.Single(resource.Properties.Where(p => p.Name == "EnumProperty")); + ODataProperty enumProperty = Assert.IsType(Assert.Single(resource.Properties.Where(p => p.Name == "EnumProperty"))); ODataEnumValue enumValue = Assert.IsType(enumProperty.Value); Assert.Equal("Fourth", enumValue.Value); Assert.Equal("Default.SimpleEnum", enumValue.TypeName); - ODataProperty guidProperty = Assert.Single(resource.Properties.Where(p => p.Name == "GuidProperty")); + ODataProperty guidProperty = Assert.IsType(Assert.Single(resource.Properties.Where(p => p.Name == "GuidProperty"))); Assert.Equal(new Guid("181D3A20-B41A-489F-9F15-F91F0F6C9ECA"), guidProperty.Value); - ODataProperty listProperty = Assert.Single(resource.Properties.Where(p => p.Name == "ListProperty")); + ODataProperty listProperty = Assert.IsType(Assert.Single(resource.Properties.Where(p => p.Name == "ListProperty"))); ODataCollectionValue collectionValue = Assert.IsType(listProperty.Value); Assert.Equal(new List { 5, 4, 3, 2, 1 }, collectionValue.Items.OfType().ToList()); Assert.Equal("Collection(Edm.Int32)", collectionValue.TypeName); - ODataProperty dateTimeProperty = Assert.Single(resource.Properties.Where(p => p.Name == "DateTimeProperty")); + ODataProperty dateTimeProperty = Assert.IsType(Assert.Single(resource.Properties.Where(p => p.Name == "DateTimeProperty"))); Assert.Equal(new DateTimeOffset(dateTime), dateTimeProperty.Value); } @@ -1101,20 +1101,20 @@ public void CreateResource_Works_ToAppendNullDynamicProperties_ForOpenEntityType Assert.Equal(4, resource.Properties.Count()); // Verify the declared properties - ODataProperty street = Assert.Single(resource.Properties.Where(p => p.Name == "CustomerId")); + ODataProperty street = Assert.IsType(Assert.Single(resource.Properties.Where(p => p.Name == "CustomerId"))); Assert.Equal(991, street.Value); - ODataProperty city = Assert.Single(resource.Properties.Where(p => p.Name == "Name")); + ODataProperty city = Assert.IsType(Assert.Single(resource.Properties.Where(p => p.Name == "Name"))); Assert.Equal("Name #991", city.Value); // Verify the nested open complex property Assert.Empty(resource.Properties.Where(p => p.Name == "Address")); // Verify the dynamic properties - ODataProperty guidProperty = Assert.Single(resource.Properties.Where(p => p.Name == "GuidProperty")); + ODataProperty guidProperty = Assert.IsType(Assert.Single(resource.Properties.Where(p => p.Name == "GuidProperty"))); Assert.Equal(new Guid("181D3A20-B41A-489F-9F15-F91F0F6C9ECA"), guidProperty.Value); - ODataProperty nullProperty = resource.Properties.Single(p => p.Name == "NullProperty"); + ODataProperty nullProperty = resource.Properties.OfType().Single(p => p.Name == "NullProperty"); Assert.Null(nullProperty.Value); } @@ -1183,7 +1183,7 @@ public void CreateResource_Works_ToIgnoreDynamicPropertiesWithEmptyNames_ForOpen Assert.Equal(3, resource.Properties.Count()); // Verify properties with empty names are ignored - ODataProperty emptyProperty = resource.Properties.SingleOrDefault(p => p.Name == ""); + ODataProperty emptyProperty = resource.Properties.OfType().SingleOrDefault(p => p.Name == ""); Assert.Null(emptyProperty); } @@ -2333,7 +2333,7 @@ public async Task WriteObjectInlineAsync_Writes_Nested_Entities_Without_Navigati // Assert stream.Position = 0; - using (StreamReader reader = new StreamReader(stream)) + using (StreamReader reader = new StreamReader(stream, leaveOpen: true)) { string response = reader.ReadToEnd(); Assert.Contains(@"""ProductID"":1", response); diff --git a/test/Microsoft.AspNetCore.OData.Tests/Formatter/Wrapper/ODataReaderExtensionsTests.Untyped.cs b/test/Microsoft.AspNetCore.OData.Tests/Formatter/Wrapper/ODataReaderExtensionsTests.Untyped.cs index 0617a7d8b..6c2147487 100644 --- a/test/Microsoft.AspNetCore.OData.Tests/Formatter/Wrapper/ODataReaderExtensionsTests.Untyped.cs +++ b/test/Microsoft.AspNetCore.OData.Tests/Formatter/Wrapper/ODataReaderExtensionsTests.Untyped.cs @@ -102,7 +102,7 @@ public async Task ReadOpenResource_WithUntypedPrimitiveValue_WorksAsExpected(str ODataResourceWrapper resourceWrapper = Assert.IsType(item); Assert.Empty(resourceWrapper.NestedResourceInfos); - Assert.Collection(resourceWrapper.Resource.Properties, + Assert.Collection(resourceWrapper.Resource.Properties.OfType(), p => { // Declared property with 'Edm.Int32' @@ -146,7 +146,7 @@ public async Task ReadOpenResource_WithUntypedResourceValue_WorksAsExpected() Assert.NotNull(item); ODataResourceWrapper resourceWrapper = Assert.IsType(item); - ODataProperty property = Assert.Single(resourceWrapper.Resource.Properties); + ODataProperty property = Assert.IsType(Assert.Single(resourceWrapper.Resource.Properties)); // Declared property with 'Edm.Int32' Assert.Equal("ID", property.Name); Assert.Equal(17, property.Value); @@ -158,7 +158,7 @@ public async Task ReadOpenResource_WithUntypedResourceValue_WorksAsExpected() Assert.Equal(n, p.NestedResourceInfo.Name); ODataResourceWrapper nestedResourceWrapper = Assert.IsType(Assert.Single(p.NestedItems)); Assert.Empty(nestedResourceWrapper.NestedResourceInfos); - Assert.Collection(nestedResourceWrapper.Resource.Properties, + Assert.Collection(nestedResourceWrapper.Resource.Properties.OfType(), p => { Assert.Equal("Key1", p.Name); @@ -213,7 +213,7 @@ public async Task ReadOpenResource_WithUntypedCollectionValue_WorksAsExpected() Assert.NotNull(item); ODataResourceWrapper resourceWrapper = Assert.IsType(item); - ODataProperty property = Assert.Single(resourceWrapper.Resource.Properties); + ODataProperty property = Assert.IsType(Assert.Single(resourceWrapper.Resource.Properties)); // Declared property with 'Edm.Int32' Assert.Equal("ID", property.Name); Assert.Equal(17, property.Value); @@ -236,7 +236,7 @@ public async Task ReadOpenResource_WithUntypedCollectionValue_WorksAsExpected() { Assert.Empty(p.NestedResourceInfos); Assert.NotNull(p.Resource); - Assert.Collection(p.Resource.Properties, + Assert.Collection(p.Resource.Properties.OfType(), p => { Assert.Equal("Key1", p.Name); @@ -261,7 +261,7 @@ public async Task ReadOpenResource_WithUntypedCollectionValue_WorksAsExpected() ODataResourceWrapper resourceWrapper = Assert.IsType(p); Assert.Empty(resourceWrapper.NestedResourceInfos); Assert.NotNull(resourceWrapper.Resource); - Assert.Collection(resourceWrapper.Resource.Properties, + Assert.Collection(resourceWrapper.Resource.Properties.OfType(), p => { Assert.Equal("Key1", p.Name); @@ -349,7 +349,7 @@ public async Task ReadOpenResource_WithUntypedCollectionValue_OnNestedResourceIn Assert.Equal("NS.Info", p.Resource.TypeName); Assert.Empty(p.NestedResourceInfos); - ODataProperty property = Assert.Single(p.Resource.Properties); + ODataProperty property = Assert.IsType(Assert.Single(p.Resource.Properties)); Assert.Equal("Key1", property.Name); Assert.Equal("Value1", property.Value); }, diff --git a/test/Microsoft.AspNetCore.OData.Tests/Formatter/Wrapper/ODataReaderExtensionsTests.cs b/test/Microsoft.AspNetCore.OData.Tests/Formatter/Wrapper/ODataReaderExtensionsTests.cs index 92255f24a..492093e7b 100644 --- a/test/Microsoft.AspNetCore.OData.Tests/Formatter/Wrapper/ODataReaderExtensionsTests.cs +++ b/test/Microsoft.AspNetCore.OData.Tests/Formatter/Wrapper/ODataReaderExtensionsTests.cs @@ -189,12 +189,12 @@ public async Task ReadResourceSetWithNestedResourceSetWorksAsExpected() r => { Assert.Equal("NS.Order", r.Resource.TypeName); - Assert.Equal(82, r.Resource.Properties.First(p => p.Name == "Price").Value); + Assert.Equal(82, r.Resource.Properties.OfType().First(p => p.Name == "Price").Value); }, r => { Assert.Equal("NS.VipOrder", r.Resource.TypeName); - Assert.Equal("abc@efg.com", r.Resource.Properties.First(p => p.Name == "Email").Value); + Assert.Equal("abc@efg.com", r.Resource.Properties.OfType().First(p => p.Name == "Email").Value); }); } @@ -257,7 +257,7 @@ public async Task ReadDeltaResourceSetWorksAsExpected() ODataResourceWrapper resource2 = Assert.IsType(ordersDeltaResourceSet.DeltaItems.ElementAt(1)); Assert.Equal("NS.VipOrder", resource2.Resource.TypeName); - Assert.Collection(resource2.Resource.Properties, + Assert.Collection(resource2.Resource.Properties.OfType(), p => { Assert.Equal("OrderId", p.Name); @@ -335,7 +335,7 @@ public async Task ReadDeletedLinkInDeltaResourceSetWorksAsExpected() // 1) Resource ODataResourceWrapper resource1 = Assert.IsType(e); Assert.Equal("Customers(42)", resource1.Resource.Id.OriginalString); - Assert.Equal("Sammy", resource1.Resource.Properties.First(p => p.Name == "Name").Value); + Assert.Equal("Sammy", resource1.Resource.Properties.OfType().First(p => p.Name == "Name").Value); }, e => { @@ -358,7 +358,7 @@ public async Task ReadDeletedLinkInDeltaResourceSetWorksAsExpected() // 4) Resource ODataResourceWrapper resource2 = Assert.IsType(e); Assert.Equal("Orders(10643)", resource2.Resource.Id.OriginalString); - Assert.Equal(82, resource2.Resource.Properties.First(p => p.Name == "Price").Value); + Assert.Equal(82, resource2.Resource.Properties.OfType().First(p => p.Name == "Price").Value); }, e => { @@ -418,7 +418,7 @@ public async Task ReadDeletedLinkInDeltaResourceSetWorksAsExpected2() ODataDeletedResource innerDeletedResource = Assert.IsType(orderResource.Resource); Assert.Equal(DeltaDeletedEntryReason.Deleted, innerDeletedResource.Reason); - ODataProperty property = Assert.Single(innerDeletedResource.Properties); + ODataProperty property = Assert.Single(innerDeletedResource.Properties.OfType()); Assert.Equal("OrderId", property.Name); Assert.Equal(10, property.Value); } diff --git a/tool/builder.versions.settings.targets b/tool/builder.versions.settings.targets index d531cdd62..bb9880af2 100644 --- a/tool/builder.versions.settings.targets +++ b/tool/builder.versions.settings.targets @@ -4,12 +4,12 @@ 9 0 0 - preview.2 + rc.1 - [8.0.0-preview.3, 9.0.0) + [8.0.0-rc.1, 9.0.0) [1.0.9, 2.0.0)