-
Notifications
You must be signed in to change notification settings - Fork 179
Support SingleResourceCastNode for unquoted type parameters in BindIsOf and BindCastSingleValue #1511
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
Merged
Merged
Support SingleResourceCastNode for unquoted type parameters in BindIsOf and BindCastSingleValue #1511
Changes from 10 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
a3aa09d
Handle SingleResourceCastNode conversion
WanjohiSammy 352a6a9
handles SingleResourceCastNode in BindCastSingleValue method
WanjohiSammy 8bed779
bump ODL version and fix some failing tests
WanjohiSammy 208799d
Ensure typeName is not null
WanjohiSammy a33f552
Bump ODL version
WanjohiSammy 47ac759
Avoid finding TypeReference again for singleResourceCastNode
WanjohiSammy 6d9cfd5
Refactor tests and move GetEdmTypeReferenceFromQueryNode to extension
WanjohiSammy b812622
rename test names
WanjohiSammy 6e2b88a
resolve failing test
WanjohiSammy aeeafe1
Handle exception thrown in BindSingleResourceCastFunctionCall when Qu…
WanjohiSammy d97eeef
Remove helper method and use the conditions directly
WanjohiSammy 04298f1
Remove unused using
WanjohiSammy a4ea9a7
Model.FindType() can return null; handle null value
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
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
31 changes: 31 additions & 0 deletions
31
test/Microsoft.AspNetCore.OData.E2E.Tests/IsOfAndCast/IsOfAndCastController.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,31 @@ | ||
| //----------------------------------------------------------------------------- | ||
| // <copyright file="IsOfAndCastController.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.Query; | ||
| using Microsoft.AspNetCore.OData.Routing.Controllers; | ||
|
|
||
| namespace Microsoft.AspNetCore.OData.E2E.Tests.IsOfAndCast; | ||
|
|
||
| public class IsOfAndCastController : ODataController | ||
| { | ||
| private static IsOfAndCastDataSource _dataSource = new IsOfAndCastDataSource(); | ||
|
|
||
| [EnableQuery] | ||
| [HttpGet("odata/products")] | ||
| public IActionResult GetProducts() | ||
| { | ||
| return Ok(_dataSource.Products); | ||
| } | ||
|
|
||
| [EnableQuery] | ||
| [HttpGet("odata/orders")] | ||
| public IActionResult GetOrders() | ||
| { | ||
| return Ok(_dataSource.Orders); | ||
| } | ||
| } |
64 changes: 64 additions & 0 deletions
64
test/Microsoft.AspNetCore.OData.E2E.Tests/IsOfAndCast/IsOfAndCastDataModel.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,64 @@ | ||
| //----------------------------------------------------------------------------- | ||
| // <copyright file="IsOfAndCastDataModel.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 System; | ||
| using System.Collections.Generic; | ||
| using System.ComponentModel.DataAnnotations; | ||
|
|
||
| namespace Microsoft.AspNetCore.OData.E2E.Tests.IsOfAndCast; | ||
|
|
||
| public class Product | ||
| { | ||
| [Key] | ||
| public int ID { get; set; } | ||
| public string Name { get; set; } | ||
| public Domain Domain { get; set; } | ||
| public Double Weight { get; set; } | ||
| } | ||
|
|
||
| [Flags] | ||
| public enum Domain | ||
| { | ||
| Military = 1, | ||
| Civil = 2, | ||
| Both = 3, | ||
| } | ||
|
|
||
| public class AirPlane : Product | ||
| { | ||
| public int Speed { get; set; } | ||
| public string Model { get; set; } | ||
| } | ||
|
|
||
| public class JetPlane : AirPlane | ||
| { | ||
| public string JetType { get; set; } | ||
| } | ||
|
|
||
| public class Order | ||
| { | ||
| [Key] | ||
| public int OrderID { get; set; } | ||
| public Address Location { get; set; } | ||
| public IList<Product> Products { get; set; } | ||
| } | ||
|
|
||
| public class Address | ||
| { | ||
| public string City { get; set; } | ||
| } | ||
|
|
||
| public class HomeAddress : Address | ||
| { | ||
| public string HomeNo { get; set; } | ||
| } | ||
|
|
||
| public class OfficeAddress : Address | ||
| { | ||
| public string OfficeNo { get; set; } | ||
| } | ||
|
|
106 changes: 106 additions & 0 deletions
106
test/Microsoft.AspNetCore.OData.E2E.Tests/IsOfAndCast/IsOfAndCastDataSource.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,106 @@ | ||
| //----------------------------------------------------------------------------- | ||
| // <copyright file="IsOfAndCastDataSource.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 System.Collections.Generic; | ||
|
|
||
| namespace Microsoft.AspNetCore.OData.E2E.Tests.IsOfAndCast; | ||
|
|
||
| public class IsOfAndCastDataSource | ||
| { | ||
| public IsOfAndCastDataSource() | ||
| { | ||
| ResetData(); | ||
| InitializeData(); | ||
| } | ||
|
|
||
| private void ResetData() | ||
| { | ||
| this.Products?.Clear(); | ||
| this.Orders?.Clear(); | ||
| } | ||
|
|
||
| public IList<Product> Products { get; private set; } | ||
| public IList<Order> Orders { get; private set; } | ||
|
|
||
| private void InitializeData() | ||
| { | ||
| this.Products = new List<Product> | ||
| { | ||
| new Product | ||
| { | ||
| ID = 1, | ||
| Name = "Product1", | ||
| Domain = Domain.Civil, | ||
| Weight = 1000 | ||
| }, | ||
| new Product | ||
| { | ||
| ID = 2, | ||
| Name = "Product2", | ||
| Domain = Domain.Military, | ||
| Weight = 2000, | ||
| }, | ||
| new AirPlane | ||
| { | ||
| ID = 3, | ||
| Name = "Product3", | ||
| Domain = Domain.Both, | ||
| Weight = 1500, | ||
| Speed = 900, | ||
| Model = "Boeing 737" | ||
| }, | ||
| new JetPlane | ||
| { | ||
| ID = 4, | ||
| Name = "Product4", | ||
| Domain = Domain.Civil, | ||
| Weight = 1200, | ||
| Speed = 1000, | ||
| Model = "Airbus A320", | ||
| JetType = "Turbofan" | ||
| }, | ||
| new JetPlane | ||
| { | ||
| ID = 5, | ||
| Name = "Product5", | ||
| Domain = Domain.Military, | ||
| Weight = 1800, | ||
| Speed = 1500, | ||
| Model = "F-22 Raptor", | ||
| JetType = "Afterburning Turbofan" | ||
| } | ||
| }; | ||
|
|
||
| this.Orders = new List<Order> | ||
| { | ||
| new Order | ||
| { | ||
| OrderID = 1, | ||
| Location = new Address { City = "City1" }, | ||
| Products = new List<Product> { this.Products[0], this.Products[2] } | ||
| }, | ||
| new Order | ||
| { | ||
| OrderID = 2, | ||
| Location = new HomeAddress { City = "City2", HomeNo = "100NO" }, | ||
| Products = new List<Product> { this.Products[1], this.Products[3], this.Products[4] } | ||
| }, | ||
| new Order | ||
| { | ||
| OrderID = 3, | ||
| Location = new OfficeAddress { City = "City3", OfficeNo = "300NO" }, | ||
| Products = new List<Product> { this.Products[0], this.Products[2], this.Products[3] } | ||
| }, | ||
| new Order | ||
| { | ||
| OrderID = 4, | ||
| Location = new HomeAddress { City = "City4", HomeNo = "200NO" }, | ||
| Products = new List<Product> { this.Products[1], this.Products[4] } | ||
| } | ||
| }; | ||
| } | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.