-
Notifications
You must be signed in to change notification settings - Fork 357
Resolve issues with Deserialization of Untyped Types #3283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
WanjohiSammy
wants to merge
38
commits into
dev-9.x
Choose a base branch
from
fix/resolve-untype-values
base: dev-9.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
a4d1901
Rebase to 9.x
WanjohiSammy 9c927d9
Add more tests
WanjohiSammy 7d677d3
refactor tests
WanjohiSammy ecd4583
Add number conversition to Int64 before converting to decimal
WanjohiSammy 9151ef6
nit
WanjohiSammy 715b1ed
Add more tests
WanjohiSammy 772cbba
refactor number parser
WanjohiSammy 8654f30
remove unused variables
WanjohiSammy 64fef94
Add a feature flag
WanjohiSammy c388681
revert changes in ParseNumberPrimitiveValue() of JsonReader
WanjohiSammy 63a9ce5
refactor tests
WanjohiSammy 7c9e24d
Add untypedtype tests
WanjohiSammy 0673be8
Added E2E tests
WanjohiSammy 4b7f410
some tests
WanjohiSammy 1b607d0
Simplify E2E tests
WanjohiSammy 89c9693
Use LibraryCompatibility instead of having to add another setting for…
WanjohiSammy a28eb6e
sort out failed tests
WanjohiSammy c2ef32c
Rebase to 9.x
WanjohiSammy 3d715fe
Add more tests
WanjohiSammy 4e597ce
refactor tests
WanjohiSammy 7c41655
Add number conversition to Int64 before converting to decimal
WanjohiSammy 814e0a3
nit
WanjohiSammy 7fd89f3
Add more tests
WanjohiSammy 9036ebd
refactor number parser
WanjohiSammy ede9038
remove unused variables
WanjohiSammy 7c6473e
Add a feature flag
WanjohiSammy 57c661c
revert changes in ParseNumberPrimitiveValue() of JsonReader
WanjohiSammy 3b67cea
refactor tests
WanjohiSammy 27ba0cc
Add untypedtype tests
WanjohiSammy d1c28f0
Added E2E tests
WanjohiSammy bb16e0e
some tests
WanjohiSammy ae7b7b7
Simplify E2E tests
WanjohiSammy 4546387
Use LibraryCompatibility instead of having to add another setting for…
WanjohiSammy e522cef
sort out failed tests
WanjohiSammy 2b9017b
Merge branch 'fix/resolve-untype-values' of https://github.com/OData/…
WanjohiSammy 1f65eb1
default is set to disable the behavior to read untyped numeric as dec…
WanjohiSammy 0d38347
resolve missing Public API
WanjohiSammy 9e4b8c2
Merge branch 'dev-9.x' into fix/resolve-untype-values
WanjohiSammy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Microsoft.OData.ODataLibraryCompatibility.ReadUntypedNumericAsDecimal = 32 -> Microsoft.OData.ODataLibraryCompatibility | ||
Microsoft.OData.ODataLibraryCompatibility.Version7 = Microsoft.OData.ODataLibraryCompatibility.UseLegacyVariableCasing | Microsoft.OData.ODataLibraryCompatibility.UseLegacyODataInnerErrorSerialization | Microsoft.OData.ODataLibraryCompatibility.ReadUntypedNumericAsDecimal -> Microsoft.OData.ODataLibraryCompatibility | ||
Microsoft.OData.ODataLibraryCompatibility.Version8 = 32 -> Microsoft.OData.ODataLibraryCompatibility |
29 changes: 29 additions & 0 deletions
29
...icrosoft.OData.E2E.TestCommon/Common/Client/UntypedTypes/UntypedTypesODataServiceCsdl.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx"> | ||
<edmx:DataServices> | ||
<Schema Namespace="Microsoft.OData.E2E.TestCommon.Common.Server.UntypedTypes" xmlns="http://docs.oasis-open.org/odata/ns/edm"> | ||
<EntityType Name="Customer"> | ||
<Key> | ||
<PropertyRef Name="Id" /> | ||
</Key> | ||
<Property Name="Id" Type="Edm.Int32" Nullable="false" /> | ||
<Property Name="Name" Type="Edm.String" /> | ||
<Property Name="UntypedProperty" Type="Edm.Untyped" /> | ||
<Property Name="UntypedList" Type="Collection(Edm.Untyped)" /> | ||
<NavigationProperty Name="Orders" Type="Collection(Microsoft.OData.E2E.TestCommon.Common.Server.UntypedTypes.Order)" /> | ||
</EntityType> | ||
<EntityType Name="Order"> | ||
<Key> | ||
<PropertyRef Name="Id" /> | ||
</Key> | ||
<Property Name="Id" Type="Edm.Int32" Nullable="false" /> | ||
<Property Name="Amount" Type="Edm.Decimal" Nullable="false" Scale="variable" /> | ||
</EntityType> | ||
<EntityContainer Name="Container"> | ||
<EntitySet Name="Customers" EntityType="Microsoft.OData.E2E.TestCommon.Common.Server.UntypedTypes.Customer"> | ||
<NavigationPropertyBinding Path="Orders" Target="Orders" /> | ||
</EntitySet> | ||
<EntitySet Name="Orders" EntityType="Microsoft.OData.E2E.TestCommon.Common.Server.UntypedTypes.Order" /> | ||
</EntityContainer> | ||
</Schema> | ||
</edmx:DataServices> | ||
</edmx:Edmx> |
93 changes: 93 additions & 0 deletions
93
...ommon/Microsoft.OData.E2E.TestCommon/Common/Server/UntypedTypes/UntypedTypesController.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
//----------------------------------------------------------------------------- | ||
// <copyright file="UntypedTypesController.cs" company=".NET Foundation"> | ||
// Copyright (c) .NET Foundation and Contributors. All rights reserved. | ||
// See License.txt in the project root for license information. | ||
// </copyright> | ||
//------------------------------------------------------------------------------ | ||
|
||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.OData.Deltas; | ||
using Microsoft.AspNetCore.OData.Formatter; | ||
using Microsoft.AspNetCore.OData.Query; | ||
using Microsoft.AspNetCore.OData.Routing.Controllers; | ||
|
||
namespace Microsoft.OData.E2E.TestCommon.Common.Server.UntypedTypes; | ||
|
||
public class UntypedTypesController : ODataController | ||
{ | ||
private static UntypedTypesDataSource _dataSource; | ||
|
||
[EnableQuery] | ||
[HttpGet("odata/Customers")] | ||
public IActionResult GetCustomers() | ||
{ | ||
return Ok(_dataSource.Customers); | ||
} | ||
|
||
[EnableQuery] | ||
[HttpGet("odata/Customers({key})")] | ||
public IActionResult GetCustomer([FromODataUri] int key) | ||
{ | ||
var res = _dataSource.Customers?.FirstOrDefault(a => a.Id == key); | ||
if (res == null) | ||
{ | ||
return NotFound(); | ||
} | ||
|
||
return Ok(res); | ||
} | ||
|
||
[EnableQuery] | ||
[HttpGet("odata/Customers({key})/UntypedProperty")] | ||
public IActionResult GetCustomersUntypedProperty([FromODataUri] int key) | ||
{ | ||
var res = _dataSource.Customers?.FirstOrDefault(a => a.Id == key); | ||
if (res == null) | ||
{ | ||
return NotFound(); | ||
} | ||
|
||
return Ok(res.UntypedProperty); | ||
} | ||
|
||
[EnableQuery] | ||
[HttpGet("odata/Customers({key})/UntypedList")] | ||
public IActionResult GetCustomersUntypedList([FromODataUri] int key) | ||
{ | ||
var res = _dataSource.Customers?.FirstOrDefault(a => a.Id == key); | ||
if (res == null) | ||
{ | ||
return NotFound(); | ||
} | ||
|
||
return Ok(res.UntypedList); | ||
} | ||
|
||
[HttpPost("odata/Customers")] | ||
public IActionResult CreateCustomer([FromBody] Customer customer) | ||
{ | ||
_dataSource.Customers?.Add(customer); | ||
return Created(customer); | ||
} | ||
|
||
[HttpPatch("odata/Customers({key})")] | ||
public IActionResult UpdateAccount([FromODataUri] int key, [FromBody] Delta<Customer> delta) | ||
{ | ||
var existing = _dataSource.Customers?.FirstOrDefault(a => a.Id == key); | ||
if (existing == null) | ||
{ | ||
return NotFound(); | ||
} | ||
|
||
var updated = delta.Patch(existing); | ||
return Updated(updated); | ||
} | ||
|
||
[HttpPost("odata/untypedtypes/Default.ResetDefaultDataSource")] | ||
public IActionResult ResetDefaultDataSource() | ||
{ | ||
_dataSource = UntypedTypesDataSource.CreateInstance(); | ||
|
||
return Ok(); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...Common/Microsoft.OData.E2E.TestCommon/Common/Server/UntypedTypes/UntypedTypesDataModel.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
//--------------------------------------------------------------------- | ||
// <copyright file="UntypedTypesDataModel.cs" company="Microsoft"> | ||
// Copyright (C) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information. | ||
// </copyright> | ||
//--------------------------------------------------------------------- | ||
|
||
namespace Microsoft.OData.E2E.TestCommon.Common.Server.UntypedTypes; | ||
|
||
public class Customer | ||
{ | ||
public int Id { get; set; } | ||
public string? Name { get; set; } | ||
public object? UntypedProperty { get; set; } = null; | ||
public List<object>? UntypedList { get; set; } = null; | ||
public List<Order> Orders { get; set; } = new List<Order>(); | ||
} | ||
|
||
public class Order | ||
{ | ||
public int Id { get; set; } | ||
public decimal Amount { get; set; } | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's for 9.x, do we need to keep back compatible?