From 36bf2a909688e7e598ecd0295fabc1377fafc9db Mon Sep 17 00:00:00 2001 From: David Lebee Date: Fri, 13 Aug 2021 12:21:27 -0400 Subject: [PATCH] deprecating ODATA support in 3.x until we make the protocol work properly, also the library from microsoft is quite inconsistent when it comes to case ofthe property in their convention vs the property names in urls. --- Demo/Demo.csproj | 15 +++--- Demo/Startup.cs | 8 +--- .../PoweredSoft.CQRS.Abstractions.csproj | 2 +- ....CQRS.AspNetCore.OData.Abstractions.csproj | 11 ----- .../QueryControllerIgnoreAttribute.cs | 11 ----- .../EndpointExstensions.cs | 44 ------------------ .../MvcBuilderExensions.cs | 46 ------------------- .../PoweredSoft.CQRS.AspNetCore.OData.csproj | 25 ---------- .../QueryODataController.cs | 23 ---------- .../QueryODataControllerConvention.cs | 29 ------------ .../QueryODataControllerFeatureProvider.cs | 45 ------------------ .../QueryODataControllerOptions.cs | 11 ----- .../PoweredSoft.CQRS.FluentValidation.csproj | 2 +- ...weredSoft.CQRS.GraphQL.DynamicQuery.csproj | 2 +- ...dSoft.CQRS.GraphQL.FluentValidation.csproj | 4 +- ...S.GraphQL.HotChocolate.DynamicQuery.csproj | 2 +- ...weredSoft.CQRS.GraphQL.HotChocolate.csproj | 4 +- PoweredSoft.CQRS.sln | 14 +----- 18 files changed, 17 insertions(+), 281 deletions(-) delete mode 100644 PoweredSoft.CQRS.AspNetCore.OData.Abstractions/PoweredSoft.CQRS.AspNetCore.OData.Abstractions.csproj delete mode 100644 PoweredSoft.CQRS.AspNetCore.OData.Abstractions/QueryControllerIgnoreAttribute.cs delete mode 100644 PoweredSoft.CQRS.AspNetCore.OData/EndpointExstensions.cs delete mode 100644 PoweredSoft.CQRS.AspNetCore.OData/MvcBuilderExensions.cs delete mode 100644 PoweredSoft.CQRS.AspNetCore.OData/PoweredSoft.CQRS.AspNetCore.OData.csproj delete mode 100644 PoweredSoft.CQRS.AspNetCore.OData/QueryODataController.cs delete mode 100644 PoweredSoft.CQRS.AspNetCore.OData/QueryODataControllerConvention.cs delete mode 100644 PoweredSoft.CQRS.AspNetCore.OData/QueryODataControllerFeatureProvider.cs delete mode 100644 PoweredSoft.CQRS.AspNetCore.OData/QueryODataControllerOptions.cs diff --git a/Demo/Demo.csproj b/Demo/Demo.csproj index 1d9a7a7..d68334b 100644 --- a/Demo/Demo.csproj +++ b/Demo/Demo.csproj @@ -5,17 +5,16 @@ - - - - - - - + + + + + + + - diff --git a/Demo/Startup.cs b/Demo/Startup.cs index 42a61bc..fdc750e 100644 --- a/Demo/Startup.cs +++ b/Demo/Startup.cs @@ -24,8 +24,8 @@ using System.Linq; using PoweredSoft.CQRS.GraphQL.HotChocolate.DynamicQuery; using PoweredSoft.CQRS.Abstractions.Security; using Demo.Security; -using Microsoft.AspNet.OData.Extensions; using PoweredSoft.CQRS.FluentValidation; +using Microsoft.AspNetCore.OData; namespace Demo { @@ -53,14 +53,12 @@ namespace Demo services.AddPoweredSoftDynamicQuery(); services.AddPoweredSoftCQRS(); - services.AddOData(); services .AddControllers() .AddPoweredSoftQueries() .AddPoweredSoftCommands() .AddPoweredSoftDynamicQueries() - .AddPoweredSoftODataQueries() .AddFluentValidation(); services @@ -138,10 +136,6 @@ namespace Demo { endpoints.MapControllers(); endpoints.MapGraphQL(); - - endpoints.Select().Filter().OrderBy().Count().MaxTop(10); - - endpoints.MapODataRoute("odata", "odata", endpoints.GetPoweredSoftODataEdmModel()); }); } } diff --git a/PoweredSoft.CQRS.Abstractions/PoweredSoft.CQRS.Abstractions.csproj b/PoweredSoft.CQRS.Abstractions/PoweredSoft.CQRS.Abstractions.csproj index 8fc4cc1..347de36 100644 --- a/PoweredSoft.CQRS.Abstractions/PoweredSoft.CQRS.Abstractions.csproj +++ b/PoweredSoft.CQRS.Abstractions/PoweredSoft.CQRS.Abstractions.csproj @@ -8,6 +8,6 @@ PoweredSoft Team - + diff --git a/PoweredSoft.CQRS.AspNetCore.OData.Abstractions/PoweredSoft.CQRS.AspNetCore.OData.Abstractions.csproj b/PoweredSoft.CQRS.AspNetCore.OData.Abstractions/PoweredSoft.CQRS.AspNetCore.OData.Abstractions.csproj deleted file mode 100644 index 892921b..0000000 --- a/PoweredSoft.CQRS.AspNetCore.OData.Abstractions/PoweredSoft.CQRS.AspNetCore.OData.Abstractions.csproj +++ /dev/null @@ -1,11 +0,0 @@ - - - - netstandard2.0 - Powered Softwares Inc. - https://secure.gravatar.com/avatar/4e32f73820c16718909a06c2927f1f8b?s=512&amp;r=g&amp;d=retro - PoweredSoft - PoweredSoft Team - - - diff --git a/PoweredSoft.CQRS.AspNetCore.OData.Abstractions/QueryControllerIgnoreAttribute.cs b/PoweredSoft.CQRS.AspNetCore.OData.Abstractions/QueryControllerIgnoreAttribute.cs deleted file mode 100644 index af85fe7..0000000 --- a/PoweredSoft.CQRS.AspNetCore.OData.Abstractions/QueryControllerIgnoreAttribute.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace PoweredSoft.CQRS.AspNetCore.OData.Abstractions -{ - [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)] - public class QueryOdataControllerIgnoreAttribute : Attribute - { - } -} diff --git a/PoweredSoft.CQRS.AspNetCore.OData/EndpointExstensions.cs b/PoweredSoft.CQRS.AspNetCore.OData/EndpointExstensions.cs deleted file mode 100644 index abfe9cc..0000000 --- a/PoweredSoft.CQRS.AspNetCore.OData/EndpointExstensions.cs +++ /dev/null @@ -1,44 +0,0 @@ -using Microsoft.AspNet.OData.Builder; -using Microsoft.AspNetCore.Routing; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.OData.Edm; -using PoweredSoft.CQRS.Abstractions.Discovery; -using PoweredSoft.CQRS.AspNetCore.OData.Abstractions; -using System.Linq; -using System.Reflection; - -namespace PoweredSoft.CQRS.AspNetCore.Mvc -{ - public static class EndpointExstensions - { - public static IEdmModel GetPoweredSoftODataEdmModel(this IEndpointRouteBuilder endpoint) - { - var queryDiscovery = endpoint.ServiceProvider.GetRequiredService(); - - var odataBuilder = new ODataConventionModelBuilder(); - odataBuilder.EnableLowerCamelCase(); - - foreach(var q in queryDiscovery.GetQueries()) - { - var ignoreAttribute = q.QueryType.GetCustomAttribute(); - if (ignoreAttribute != null) - continue; - - if (q.Category != "BasicQuery") - continue; - - var isQueryable = q.QueryResultType.Namespace == "System.Linq" && q.QueryResultType.Name.Contains("IQueryable"); - if (!isQueryable) - continue; - - - var entityType = q.QueryResultType.GetGenericArguments().First(); - odataBuilder.GetType().GetMethod("EntitySet").MakeGenericMethod(entityType).Invoke(odataBuilder, new object[] { - q.LowerCamelCaseName - }); - } - - return odataBuilder.GetEdmModel(); - } - } -} diff --git a/PoweredSoft.CQRS.AspNetCore.OData/MvcBuilderExensions.cs b/PoweredSoft.CQRS.AspNetCore.OData/MvcBuilderExensions.cs deleted file mode 100644 index 5001341..0000000 --- a/PoweredSoft.CQRS.AspNetCore.OData/MvcBuilderExensions.cs +++ /dev/null @@ -1,46 +0,0 @@ -using Microsoft.AspNetCore.Mvc.Formatters; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Net.Http.Headers; -using PoweredSoft.CQRS.AspNetCore.OData; -using System; -using System.Linq; -using System.Text; - -namespace PoweredSoft.CQRS.AspNetCore.Mvc -{ - - public static class MvcBuilderExtensions - { - public static IMvcBuilder AddPoweredSoftODataQueries(this IMvcBuilder builder, Action configuration = null) - { - var options = new QueryODataControllerOptions(); - configuration?.Invoke(options); - var services = builder.Services; - var serviceProvider = services.BuildServiceProvider(); - builder.AddMvcOptions(o => o.Conventions.Add(new QueryODataControllerConvention(serviceProvider))); - builder.ConfigureApplicationPartManager(m => m.FeatureProviders.Add(new QueryODataControllerFeatureProvider(serviceProvider))); - - if (options.FixODataSwagger) - builder.FixODataSwagger(); - return builder; - } - - public static IMvcBuilder FixODataSwagger(this IMvcBuilder builder) - { - builder.AddMvcOptions(options => - { - foreach (var outputFormatter in options.OutputFormatters.OfType().Where(x => x.SupportedMediaTypes.Count == 0)) - { - outputFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/prs.odatatestxx-odata")); - } - - foreach (var inputFormatter in options.InputFormatters.OfType().Where(x => x.SupportedMediaTypes.Count == 0)) - { - inputFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("application/prs.odatatestxx-odata")); - } - }); - - return builder; - } - } -} diff --git a/PoweredSoft.CQRS.AspNetCore.OData/PoweredSoft.CQRS.AspNetCore.OData.csproj b/PoweredSoft.CQRS.AspNetCore.OData/PoweredSoft.CQRS.AspNetCore.OData.csproj deleted file mode 100644 index de16928..0000000 --- a/PoweredSoft.CQRS.AspNetCore.OData/PoweredSoft.CQRS.AspNetCore.OData.csproj +++ /dev/null @@ -1,25 +0,0 @@ - - - - netcoreapp3.1 - Powered Softwares Inc. - https://secure.gravatar.com/avatar/4e32f73820c16718909a06c2927f1f8b?s=512&amp;r=g&amp;d=retro - PoweredSoft - PoweredSoft Team - - - - - - - - - - - - - - - - - diff --git a/PoweredSoft.CQRS.AspNetCore.OData/QueryODataController.cs b/PoweredSoft.CQRS.AspNetCore.OData/QueryODataController.cs deleted file mode 100644 index 56feee5..0000000 --- a/PoweredSoft.CQRS.AspNetCore.OData/QueryODataController.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Microsoft.AspNet.OData; -using Microsoft.AspNetCore.Mvc; -using PoweredSoft.CQRS.Abstractions; -using PoweredSoft.CQRS.AspNetCore.Mvc; -using System; -using System.Threading.Tasks; - -namespace PoweredSoft.CQRS.AspNetCore.OData -{ - [Route("api/odata/[controller]")] - [ApiExplorerSettings(IgnoreApi = true)] - public class QueryODataController : ODataController - where TQuery : class - { - [EnableQuery, HttpGet, QueryControllerAuthorization] - public async Task Get([FromServices]IQueryHandler queryHandler, [FromQuery]TQuery query) - { - var result = await queryHandler.HandleAsync(query, HttpContext.RequestAborted); - return result; - } - } - -} diff --git a/PoweredSoft.CQRS.AspNetCore.OData/QueryODataControllerConvention.cs b/PoweredSoft.CQRS.AspNetCore.OData/QueryODataControllerConvention.cs deleted file mode 100644 index e8cafcb..0000000 --- a/PoweredSoft.CQRS.AspNetCore.OData/QueryODataControllerConvention.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.ApplicationModels; -using Microsoft.Extensions.DependencyInjection; -using PoweredSoft.CQRS.Abstractions.Discovery; -using System; - -namespace PoweredSoft.CQRS.AspNetCore.Mvc -{ - public class QueryODataControllerConvention : IControllerModelConvention - { - private readonly IServiceProvider serviceProvider; - - public QueryODataControllerConvention(IServiceProvider serviceProvider) - { - this.serviceProvider = serviceProvider; - } - - public void Apply(ControllerModel controller) - { - if (controller.ControllerType.IsGenericType && controller.ControllerType.Name.Contains("QueryODataController") && controller.ControllerType.Assembly == typeof(QueryODataControllerConvention).Assembly) - { - var genericType = controller.ControllerType.GenericTypeArguments[0]; - var queryDiscovery = this.serviceProvider.GetRequiredService(); - var query = queryDiscovery.FindQuery(genericType); - controller.ControllerName = $"{query.LowerCamelCaseName}"; - } - } - } -} diff --git a/PoweredSoft.CQRS.AspNetCore.OData/QueryODataControllerFeatureProvider.cs b/PoweredSoft.CQRS.AspNetCore.OData/QueryODataControllerFeatureProvider.cs deleted file mode 100644 index 9ad2936..0000000 --- a/PoweredSoft.CQRS.AspNetCore.OData/QueryODataControllerFeatureProvider.cs +++ /dev/null @@ -1,45 +0,0 @@ -using Microsoft.AspNetCore.Mvc.ApplicationParts; -using Microsoft.AspNetCore.Mvc.Controllers; -using Microsoft.Extensions.DependencyInjection; -using PoweredSoft.CQRS.Abstractions.Discovery; -using PoweredSoft.CQRS.AspNetCore.Abstractions.Attributes; -using PoweredSoft.CQRS.AspNetCore.OData.Abstractions; -using System; -using System.Collections.Generic; -using System.Reflection; -using System.Text; - -namespace PoweredSoft.CQRS.AspNetCore.OData -{ - public class QueryODataControllerFeatureProvider : IApplicationFeatureProvider - { - private readonly ServiceProvider serviceProvider; - - public QueryODataControllerFeatureProvider(ServiceProvider serviceProvider) - { - this.serviceProvider = serviceProvider; - } - - public void PopulateFeature(IEnumerable parts, ControllerFeature feature) - { - var queryDiscovery = this.serviceProvider.GetRequiredService(); - foreach (var f in queryDiscovery.GetQueries()) - { - var ignoreAttribute = f.QueryType.GetCustomAttribute(); - if (ignoreAttribute != null) - continue; - - if (f.Category != "BasicQuery") - continue; - - var isQueryable = f.QueryResultType.Namespace == "System.Linq" && f.QueryResultType.Name.Contains("IQueryable"); - if (!isQueryable) - continue; - - var controllerType = typeof(QueryODataController<,>).MakeGenericType(f.QueryType, f.QueryResultType); - var controllerTypeInfo = controllerType.GetTypeInfo(); - feature.Controllers.Add(controllerTypeInfo); - } - } - } -} diff --git a/PoweredSoft.CQRS.AspNetCore.OData/QueryODataControllerOptions.cs b/PoweredSoft.CQRS.AspNetCore.OData/QueryODataControllerOptions.cs deleted file mode 100644 index 031cec8..0000000 --- a/PoweredSoft.CQRS.AspNetCore.OData/QueryODataControllerOptions.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace PoweredSoft.CQRS.AspNetCore.Mvc -{ - public class QueryODataControllerOptions - { - public bool FixODataSwagger { get; set; } = true; - - public QueryODataControllerOptions() - { - } - } -} \ No newline at end of file diff --git a/PoweredSoft.CQRS.FluentValidation/PoweredSoft.CQRS.FluentValidation.csproj b/PoweredSoft.CQRS.FluentValidation/PoweredSoft.CQRS.FluentValidation.csproj index dfb63a4..ff8211a 100644 --- a/PoweredSoft.CQRS.FluentValidation/PoweredSoft.CQRS.FluentValidation.csproj +++ b/PoweredSoft.CQRS.FluentValidation/PoweredSoft.CQRS.FluentValidation.csproj @@ -9,7 +9,7 @@ - + diff --git a/PoweredSoft.CQRS.GraphQL.DynamicQuery/PoweredSoft.CQRS.GraphQL.DynamicQuery.csproj b/PoweredSoft.CQRS.GraphQL.DynamicQuery/PoweredSoft.CQRS.GraphQL.DynamicQuery.csproj index 12177ff..25066c3 100644 --- a/PoweredSoft.CQRS.GraphQL.DynamicQuery/PoweredSoft.CQRS.GraphQL.DynamicQuery.csproj +++ b/PoweredSoft.CQRS.GraphQL.DynamicQuery/PoweredSoft.CQRS.GraphQL.DynamicQuery.csproj @@ -9,7 +9,7 @@ - + diff --git a/PoweredSoft.CQRS.GraphQL.FluentValidation/PoweredSoft.CQRS.GraphQL.FluentValidation.csproj b/PoweredSoft.CQRS.GraphQL.FluentValidation/PoweredSoft.CQRS.GraphQL.FluentValidation.csproj index 21fa40e..0ca0369 100644 --- a/PoweredSoft.CQRS.GraphQL.FluentValidation/PoweredSoft.CQRS.GraphQL.FluentValidation.csproj +++ b/PoweredSoft.CQRS.GraphQL.FluentValidation/PoweredSoft.CQRS.GraphQL.FluentValidation.csproj @@ -9,8 +9,8 @@ - - + + diff --git a/PoweredSoft.CQRS.GraphQL.HotChocolate.DynamicQuery/PoweredSoft.CQRS.GraphQL.HotChocolate.DynamicQuery.csproj b/PoweredSoft.CQRS.GraphQL.HotChocolate.DynamicQuery/PoweredSoft.CQRS.GraphQL.HotChocolate.DynamicQuery.csproj index 8c5957d..ee403e7 100644 --- a/PoweredSoft.CQRS.GraphQL.HotChocolate.DynamicQuery/PoweredSoft.CQRS.GraphQL.HotChocolate.DynamicQuery.csproj +++ b/PoweredSoft.CQRS.GraphQL.HotChocolate.DynamicQuery/PoweredSoft.CQRS.GraphQL.HotChocolate.DynamicQuery.csproj @@ -9,7 +9,7 @@ - + diff --git a/PoweredSoft.CQRS.GraphQL.HotChocolate/PoweredSoft.CQRS.GraphQL.HotChocolate.csproj b/PoweredSoft.CQRS.GraphQL.HotChocolate/PoweredSoft.CQRS.GraphQL.HotChocolate.csproj index d369197..5868d85 100644 --- a/PoweredSoft.CQRS.GraphQL.HotChocolate/PoweredSoft.CQRS.GraphQL.HotChocolate.csproj +++ b/PoweredSoft.CQRS.GraphQL.HotChocolate/PoweredSoft.CQRS.GraphQL.HotChocolate.csproj @@ -9,8 +9,8 @@ - - + + diff --git a/PoweredSoft.CQRS.sln b/PoweredSoft.CQRS.sln index 8365054..88ddd77 100644 --- a/PoweredSoft.CQRS.sln +++ b/PoweredSoft.CQRS.sln @@ -35,11 +35,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PoweredSoft.CQRS.GraphQL.Ho EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PoweredSoft.CQRS.GraphQL.DynamicQuery", "PoweredSoft.CQRS.GraphQL.DynamicQuery\PoweredSoft.CQRS.GraphQL.DynamicQuery.csproj", "{34B27880-A5D5-47EA-A5FA-86E04E0F7A21}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PoweredSoft.CQRS.AspNetCore.OData", "PoweredSoft.CQRS.AspNetCore.OData\PoweredSoft.CQRS.AspNetCore.OData.csproj", "{04459C2D-B02F-4FF0-8D66-73042F27C7CC}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PoweredSoft.CQRS.AspNetCore.OData.Abstractions", "PoweredSoft.CQRS.AspNetCore.OData.Abstractions\PoweredSoft.CQRS.AspNetCore.OData.Abstractions.csproj", "{9B65B727-C088-4562-A607-8BD5B5EFF289}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PoweredSoft.CQRS.FluentValidation", "PoweredSoft.CQRS.FluentValidation\PoweredSoft.CQRS.FluentValidation.csproj", "{70BD37C4-7497-474D-9A40-A701203971D8}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PoweredSoft.CQRS.FluentValidation", "PoweredSoft.CQRS.FluentValidation\PoweredSoft.CQRS.FluentValidation.csproj", "{70BD37C4-7497-474D-9A40-A701203971D8}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -99,14 +95,6 @@ Global {34B27880-A5D5-47EA-A5FA-86E04E0F7A21}.Debug|Any CPU.Build.0 = Debug|Any CPU {34B27880-A5D5-47EA-A5FA-86E04E0F7A21}.Release|Any CPU.ActiveCfg = Release|Any CPU {34B27880-A5D5-47EA-A5FA-86E04E0F7A21}.Release|Any CPU.Build.0 = Release|Any CPU - {04459C2D-B02F-4FF0-8D66-73042F27C7CC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {04459C2D-B02F-4FF0-8D66-73042F27C7CC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {04459C2D-B02F-4FF0-8D66-73042F27C7CC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {04459C2D-B02F-4FF0-8D66-73042F27C7CC}.Release|Any CPU.Build.0 = Release|Any CPU - {9B65B727-C088-4562-A607-8BD5B5EFF289}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9B65B727-C088-4562-A607-8BD5B5EFF289}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9B65B727-C088-4562-A607-8BD5B5EFF289}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9B65B727-C088-4562-A607-8BD5B5EFF289}.Release|Any CPU.Build.0 = Release|Any CPU {70BD37C4-7497-474D-9A40-A701203971D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {70BD37C4-7497-474D-9A40-A701203971D8}.Debug|Any CPU.Build.0 = Debug|Any CPU {70BD37C4-7497-474D-9A40-A701203971D8}.Release|Any CPU.ActiveCfg = Release|Any CPU