-
Notifications
You must be signed in to change notification settings - Fork 351
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated odata.context computation to remove trailing cast segments th… (
#2681) * updated odata.context computation to remove trailing cast segments that are following by key segments as well as the case where the standard key syntax is used within a cast segment * Removed use of Predicate delegate * Update ReadOnlyCollectionExtensions.cs * fixed public api tests * actually fix public api tests? * add unit tests for the new trim extension * added comment * adding back the odataurislim variant for computing context url * moving findlastindex from spatial to edm * adding test for findlastindex * fix publicapi tests * public api tests * asdf
- Loading branch information
1 parent
f5bc755
commit f9a9405
Showing
19 changed files
with
442 additions
and
7 deletions.
There are no files selected for viewing
This file contains 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 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 @@ | ||
static Microsoft.OData.UriParser.ODataPathExtensions.TrimEndingTypeAndKeySegments(this Microsoft.OData.UriParser.ODataPath path) -> Microsoft.OData.UriParser.ODataPath |
This file contains 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 @@ | ||
static Microsoft.OData.UriParser.ODataPathExtensions.TrimEndingTypeAndKeySegments(this Microsoft.OData.UriParser.ODataPath path) -> Microsoft.OData.UriParser.ODataPath |
This file contains 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 @@ | ||
static Microsoft.OData.UriParser.ODataPathExtensions.TrimEndingTypeAndKeySegments(this Microsoft.OData.UriParser.ODataPath path) -> Microsoft.OData.UriParser.ODataPath |
This file contains 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 @@ | ||
static Microsoft.OData.UriParser.ODataPathExtensions.TrimEndingTypeAndKeySegments(this Microsoft.OData.UriParser.ODataPath path) -> Microsoft.OData.UriParser.ODataPath |
This file contains 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
3 changes: 2 additions & 1 deletion
3
src/Microsoft.OData.Edm/PublicAPI/net45/PublicAPI.Unshipped.txt
This file contains 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 |
---|---|---|
@@ -1 +1,2 @@ | ||
| ||
static System.Collections.Generic.ReadOnlyListExtensions.FindLastIndex<T>(this System.Collections.Generic.IReadOnlyList<T> list, System.Func<T, bool> predicate) -> int | ||
System.Collections.Generic.ReadOnlyListExtensions |
3 changes: 2 additions & 1 deletion
3
src/Microsoft.OData.Edm/PublicAPI/netstandard1.1/PublicAPI.Unshipped.txt
This file contains 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 |
---|---|---|
@@ -1 +1,2 @@ | ||
| ||
static System.Collections.Generic.ReadOnlyListExtensions.FindLastIndex<T>(this System.Collections.Generic.IReadOnlyList<T> list, System.Func<T, bool> predicate) -> int | ||
System.Collections.Generic.ReadOnlyListExtensions |
3 changes: 2 additions & 1 deletion
3
src/Microsoft.OData.Edm/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt
This file contains 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 |
---|---|---|
@@ -1 +1,2 @@ | ||
| ||
static System.Collections.Generic.ReadOnlyListExtensions.FindLastIndex<T>(this System.Collections.Generic.IReadOnlyList<T> list, System.Func<T, bool> predicate) -> int | ||
System.Collections.Generic.ReadOnlyListExtensions |
45 changes: 45 additions & 0 deletions
45
src/Microsoft.OData.Edm/System/Collections/Generic/ReadOnlyListExtensions.cs
This file contains 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,45 @@ | ||
namespace System.Collections.Generic | ||
{ | ||
/// <summary> | ||
/// Extensions methods <see cref="IReadOnlyList{T}"/> | ||
/// </summary> | ||
public static class ReadOnlyListExtensions | ||
{ | ||
/// <summary> | ||
/// Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the last occurrence within the | ||
/// entire <see cref="IReadOnlyList{T}"/> | ||
/// </summary> | ||
/// <typeparam name="T">The type of the elements in <paramref name="list"/></typeparam> | ||
/// <param name="list">The <see cref="IReadOnlyList{T}"/> to find the index of the last element of</param> | ||
/// <param name="predicate">The <see cref="Func{T, TResult}"/> delegate that defines the conditions of the element to search for.</param> | ||
/// <returns> | ||
/// The zero-based index of the last occurrence of an element that matches the conditions defined by <paramref name="predicate"/>, if found; otherwise, -1 | ||
/// </returns> | ||
/// <exception cref="ArgumentNullException">Thrown if <paramref name="list"/> or <paramref name="predicate"/> is <see langword="null"/></exception> | ||
/// <remarks> | ||
/// Copied from <see href="https://github.com/dotnet/runtime/blob/87c25589bda5a79baf8d056501663b8525f366a8/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/List.cs#L560"/> | ||
/// </remarks> | ||
public static int FindLastIndex<T>(this IReadOnlyList<T> list, Func<T, bool> predicate) | ||
{ | ||
if (list == null) | ||
{ | ||
throw new ArgumentNullException(nameof(list)); | ||
} | ||
|
||
if (predicate == null) | ||
{ | ||
throw new ArgumentNullException(nameof(predicate)); | ||
} | ||
|
||
for (int i = list.Count - 1; i > -1; --i) | ||
{ | ||
if (predicate(list[i])) | ||
{ | ||
return i; | ||
} | ||
} | ||
|
||
return -1; | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...ta.Core.Tests/JsonLight/GenerateContextUrlFromSlimUriWithDerivedTypeCastAndKeySegment.xml
This file contains 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,35 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" xmlns:ags="http://aggregator.microsoft.com/internal" xmlns:odata="http://schemas.microsoft.com/oDataCapabilities"> | ||
<edmx:DataServices> | ||
<Schema Namespace="ns" Alias="self" xmlns="http://docs.oasis-open.org/odata/ns/edm" xmlns:ags="http://aggregator.microsoft.com/internal" xmlns:odata="http://schemas.microsoft.com/oDataCapabilities"> | ||
<EntityContainer Name="Container"> | ||
<EntitySet Name="orders" EntityType="self.order" /> | ||
<EntitySet Name="categories" EntityType="self.category" /> | ||
</EntityContainer> | ||
<EntityType Name="order"> | ||
<Key> | ||
<PropertyRef Name="id" /> | ||
</Key> | ||
<Property Name="id" Type="Edm.String" Nullable="false" /> | ||
<NavigationProperty Name="products" Type="Collection(self.product)" ContainsTarget="true" Nullable="false" /> | ||
</EntityType> | ||
<EntityType Name="product"> | ||
<Key> | ||
<PropertyRef Name="id" /> | ||
</Key> | ||
<Property Name="id" Type="Edm.String" Nullable="false" /> | ||
<Property Name="name" Type="Edm.String" Nullable="false" /> | ||
</EntityType> | ||
<EntityType Name="category"> | ||
<Key> | ||
<PropertyRef Name="id" /> | ||
</Key> | ||
<Property Name="id" Type="Edm.String" Nullable="false" /> | ||
<Property Name="foo" Type="Edm.String" Nullable="false" /> | ||
</EntityType> | ||
<EntityType Name="derivedProduct" BaseType="self.product"> | ||
<NavigationProperty Name="category" Type="self.category" ContainsTarget="true" /> | ||
</EntityType> | ||
</Schema> | ||
</edmx:DataServices> | ||
</edmx:Edmx> |
This file contains 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
26 changes: 26 additions & 0 deletions
26
...icrosoft.OData.Core.Tests/JsonLight/WriteContextWithDerivedTypeCastAndKeySegmentAsync.xml
This file contains 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,26 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<edmx:Edmx Version="4.0" xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" xmlns:ags="http://aggregator.microsoft.com/internal" xmlns:odata="http://schemas.microsoft.com/oDataCapabilities"> | ||
<edmx:DataServices> | ||
<Schema Namespace="ns" Alias="self" xmlns="http://docs.oasis-open.org/odata/ns/edm" xmlns:ags="http://aggregator.microsoft.com/internal" xmlns:odata="http://schemas.microsoft.com/oDataCapabilities"> | ||
<EntityContainer Name="Container"> | ||
<EntitySet Name="orders" EntityType="self.order" /> | ||
</EntityContainer> | ||
<EntityType Name="order"> | ||
<Key> | ||
<PropertyRef Name="id" /> | ||
</Key> | ||
<Property Name="id" Type="Edm.String" Nullable="false" /> | ||
<NavigationProperty Name="products" Type="Collection(self.product)" ContainsTarget="true" Nullable="false" /> | ||
</EntityType> | ||
<EntityType Name="product"> | ||
<Key> | ||
<PropertyRef Name="id" /> | ||
</Key> | ||
<Property Name="id" Type="Edm.String" Nullable="false" /> | ||
<Property Name="name" Type="Edm.String" Nullable="false" /> | ||
</EntityType> | ||
<EntityType Name="derivedProduct" BaseType="self.product"> | ||
</EntityType> | ||
</Schema> | ||
</edmx:DataServices> | ||
</edmx:Edmx> |
Oops, something went wrong.