From 026c647e214b2a0ea2017e83ebc7c7773477bcbb Mon Sep 17 00:00:00 2001 From: Sam Xu Date: Tue, 18 Apr 2023 14:20:41 -0700 Subject: [PATCH] Re-add the removed 'QuerySettings' to avoid breaking changes. Co-Author: Chris Martinez --- .../Microsoft.AspNetCore.OData.xml | 47 +++------------ .../ODataOptions.cs | 8 ++- .../PublicAPI.Unshipped.txt | 2 + .../Query/DefaultQueryConfigurations.cs | 57 ++----------------- ...rosoft.AspNetCore.OData.PublicApi.Net6.bsl | 15 ++--- ...t.AspNetCore.OData.PublicApi.NetCore31.bsl | 15 ++--- 6 files changed, 33 insertions(+), 111 deletions(-) diff --git a/src/Microsoft.AspNetCore.OData/Microsoft.AspNetCore.OData.xml b/src/Microsoft.AspNetCore.OData/Microsoft.AspNetCore.OData.xml index 3bdc9e386..3bca9b823 100644 --- a/src/Microsoft.AspNetCore.OData/Microsoft.AspNetCore.OData.xml +++ b/src/Microsoft.AspNetCore.OData/Microsoft.AspNetCore.OData.xml @@ -5907,7 +5907,7 @@ Read OData item. - The odata reader. + The OData reader. The item stack. The top level item. @@ -6259,7 +6259,7 @@ - Enable $skiptop query option. + Enable $skiptoken query option. The current instance to enable fluent configuration. @@ -6275,6 +6275,11 @@ Gets or sets whether or not the OData system query options should be prefixed with '$'. + + + Gets the query settings. + + Gets the query configurations. @@ -8022,44 +8027,6 @@ This class describes the default configurations to use during query composition. - - - Gets or sets a value indicating whether navigation property can be expanded. - - - - - Gets or sets a value indicating whether property can be selected. - - - - - Gets or sets a value indicating whether entity set and property can apply $count. - - - - - Gets or sets a value indicating whether property can apply $orderby. - - - - - Gets or sets a value indicating whether property can apply $filter. - - - - - Gets or sets the max value of $top that a client can request. - - - The max value of $top that a client can request, or null if there is no limit. - - - - - Gets or sets a value indicating whether the service will use skiptoken or not. - - This partial class defines the configuration on . diff --git a/src/Microsoft.AspNetCore.OData/ODataOptions.cs b/src/Microsoft.AspNetCore.OData/ODataOptions.cs index 09edefefa..f5a1db158 100644 --- a/src/Microsoft.AspNetCore.OData/ODataOptions.cs +++ b/src/Microsoft.AspNetCore.OData/ODataOptions.cs @@ -257,7 +257,7 @@ public ODataOptions Count() } /// - /// Enable $skiptop query option. + /// Enable $skiptoken query option. /// /// The current instance to enable fluent configuration. public ODataOptions SkipToken() @@ -287,6 +287,12 @@ public ODataOptions SetMaxTop(int? maxTopValue) /// public bool EnableNoDollarQueryOptions { get; set; } = true; + /// + /// Gets the query settings. + /// + [Obsolete("QuerySettings will be removed in the next major version. Use QueryConfigurations instead.")] + public DefaultQuerySettings QuerySettings => QueryConfigurations; + /// /// Gets the query configurations. /// diff --git a/src/Microsoft.AspNetCore.OData/PublicAPI.Unshipped.txt b/src/Microsoft.AspNetCore.OData/PublicAPI.Unshipped.txt index c4e1e0820..e9f674104 100644 --- a/src/Microsoft.AspNetCore.OData/PublicAPI.Unshipped.txt +++ b/src/Microsoft.AspNetCore.OData/PublicAPI.Unshipped.txt @@ -669,6 +669,8 @@ Microsoft.AspNetCore.OData.ODataOptions.GetRouteServices(string routePrefix) -> Microsoft.AspNetCore.OData.ODataOptions.ODataOptions() -> void Microsoft.AspNetCore.OData.ODataOptions.OrderBy() -> Microsoft.AspNetCore.OData.ODataOptions Microsoft.AspNetCore.OData.ODataOptions.QueryConfigurations.get -> Microsoft.AspNetCore.OData.Query.DefaultQueryConfigurations +Microsoft.AspNetCore.OData.ODataOptions.QuerySettings.get -> Microsoft.OData.ModelBuilder.Config.DefaultQuerySettings +Microsoft.AspNetCore.OData.ODataOptions.QuerySettings.set -> void Microsoft.AspNetCore.OData.ODataOptions.RouteComponents.get -> System.Collections.Generic.IDictionary Microsoft.AspNetCore.OData.ODataOptions.RouteOptions.get -> Microsoft.AspNetCore.OData.Routing.ODataRouteOptions Microsoft.AspNetCore.OData.ODataOptions.Select() -> Microsoft.AspNetCore.OData.ODataOptions diff --git a/src/Microsoft.AspNetCore.OData/Query/DefaultQueryConfigurations.cs b/src/Microsoft.AspNetCore.OData/Query/DefaultQueryConfigurations.cs index 81f1cac5f..2901320e5 100644 --- a/src/Microsoft.AspNetCore.OData/Query/DefaultQueryConfigurations.cs +++ b/src/Microsoft.AspNetCore.OData/Query/DefaultQueryConfigurations.cs @@ -5,63 +5,16 @@ // //------------------------------------------------------------------------------ +using Microsoft.OData.ModelBuilder.Config; + namespace Microsoft.AspNetCore.OData.Query { /// /// This class describes the default configurations to use during query composition. /// - public class DefaultQueryConfigurations + public class DefaultQueryConfigurations : DefaultQuerySettings { - private int? _maxTop = 0; - - /// - /// Gets or sets a value indicating whether navigation property can be expanded. - /// - public bool EnableExpand { get; set; } - - /// - /// Gets or sets a value indicating whether property can be selected. - /// - public bool EnableSelect { get; set; } - - /// - /// Gets or sets a value indicating whether entity set and property can apply $count. - /// - public bool EnableCount { get; set; } - - /// - /// Gets or sets a value indicating whether property can apply $orderby. - /// - public bool EnableOrderBy { get; set; } - - /// - /// Gets or sets a value indicating whether property can apply $filter. - /// - public bool EnableFilter { get; set; } - - /// - /// Gets or sets the max value of $top that a client can request. - /// - /// - /// The max value of $top that a client can request, or null if there is no limit. - /// - public int? MaxTop - { - get => _maxTop; - set - { - if (value.HasValue && value < 0) - { - throw Error.ArgumentMustBeGreaterThanOrEqualTo("value", value, 0); - } - - _maxTop = value; - } - } - - /// - /// Gets or sets a value indicating whether the service will use skiptoken or not. - /// - public bool EnableSkipToken { get; set; } + // We will add other query settings, for example, $compute, $search here + // In the next major release, we should remove the inheritance from 'DefaultQuerySettings'. } } diff --git a/test/Microsoft.AspNetCore.OData.Tests/PublicApi/Microsoft.AspNetCore.OData.PublicApi.Net6.bsl b/test/Microsoft.AspNetCore.OData.Tests/PublicApi/Microsoft.AspNetCore.OData.PublicApi.Net6.bsl index 6eb2500c8..4ce2d44b6 100644 --- a/test/Microsoft.AspNetCore.OData.Tests/PublicApi/Microsoft.AspNetCore.OData.PublicApi.Net6.bsl +++ b/test/Microsoft.AspNetCore.OData.Tests/PublicApi/Microsoft.AspNetCore.OData.PublicApi.Net6.bsl @@ -103,6 +103,11 @@ public class Microsoft.AspNetCore.OData.ODataOptions { bool EnableContinueOnErrorHeader { public get; public set; } bool EnableNoDollarQueryOptions { public get; public set; } Microsoft.AspNetCore.OData.Query.DefaultQueryConfigurations QueryConfigurations { public get; } + [ + ObsoleteAttribute(), + ] + Microsoft.OData.ModelBuilder.Config.DefaultQuerySettings QuerySettings { public get; } + [ TupleElementNamesAttribute(), ] @@ -1271,16 +1276,8 @@ public class Microsoft.AspNetCore.OData.Query.DefaultODataQueryRequestParser : I public virtual System.Threading.Tasks.Task`1[[System.String]] ParseAsync (Microsoft.AspNetCore.Http.HttpRequest request) } -public class Microsoft.AspNetCore.OData.Query.DefaultQueryConfigurations { +public class Microsoft.AspNetCore.OData.Query.DefaultQueryConfigurations : Microsoft.OData.ModelBuilder.Config.DefaultQuerySettings { public DefaultQueryConfigurations () - - bool EnableCount { public get; public set; } - bool EnableExpand { public get; public set; } - bool EnableFilter { public get; public set; } - bool EnableOrderBy { public get; public set; } - bool EnableSelect { public get; public set; } - bool EnableSkipToken { public get; public set; } - System.Nullable`1[[System.Int32]] MaxTop { public get; public set; } } public class Microsoft.AspNetCore.OData.Query.DefaultSkipTokenHandler : Microsoft.AspNetCore.OData.Query.SkipTokenHandler { diff --git a/test/Microsoft.AspNetCore.OData.Tests/PublicApi/Microsoft.AspNetCore.OData.PublicApi.NetCore31.bsl b/test/Microsoft.AspNetCore.OData.Tests/PublicApi/Microsoft.AspNetCore.OData.PublicApi.NetCore31.bsl index 6eb2500c8..4ce2d44b6 100644 --- a/test/Microsoft.AspNetCore.OData.Tests/PublicApi/Microsoft.AspNetCore.OData.PublicApi.NetCore31.bsl +++ b/test/Microsoft.AspNetCore.OData.Tests/PublicApi/Microsoft.AspNetCore.OData.PublicApi.NetCore31.bsl @@ -103,6 +103,11 @@ public class Microsoft.AspNetCore.OData.ODataOptions { bool EnableContinueOnErrorHeader { public get; public set; } bool EnableNoDollarQueryOptions { public get; public set; } Microsoft.AspNetCore.OData.Query.DefaultQueryConfigurations QueryConfigurations { public get; } + [ + ObsoleteAttribute(), + ] + Microsoft.OData.ModelBuilder.Config.DefaultQuerySettings QuerySettings { public get; } + [ TupleElementNamesAttribute(), ] @@ -1271,16 +1276,8 @@ public class Microsoft.AspNetCore.OData.Query.DefaultODataQueryRequestParser : I public virtual System.Threading.Tasks.Task`1[[System.String]] ParseAsync (Microsoft.AspNetCore.Http.HttpRequest request) } -public class Microsoft.AspNetCore.OData.Query.DefaultQueryConfigurations { +public class Microsoft.AspNetCore.OData.Query.DefaultQueryConfigurations : Microsoft.OData.ModelBuilder.Config.DefaultQuerySettings { public DefaultQueryConfigurations () - - bool EnableCount { public get; public set; } - bool EnableExpand { public get; public set; } - bool EnableFilter { public get; public set; } - bool EnableOrderBy { public get; public set; } - bool EnableSelect { public get; public set; } - bool EnableSkipToken { public get; public set; } - System.Nullable`1[[System.Int32]] MaxTop { public get; public set; } } public class Microsoft.AspNetCore.OData.Query.DefaultSkipTokenHandler : Microsoft.AspNetCore.OData.Query.SkipTokenHandler {