From a8e648c154cb5f4280f9b9d4e3060038d0444f5f Mon Sep 17 00:00:00 2001 From: Mauro Servienti Date: Sun, 22 Nov 2020 14:22:31 +0100 Subject: [PATCH] Multi targeting update (#190) * Bump ApprovalTests in /src/ServiceComposer.AspNetCore.Tests Bumps [ApprovalTests](https://github.com/approvals/ApprovalTests.Net) from 5.4.3 to 5.4.4. - [Release notes](https://github.com/approvals/ApprovalTests.Net/releases) - [Commits](https://github.com/approvals/ApprovalTests.Net/commits/5.4.4) Signed-off-by: dependabot[bot] * Add .NET 5 support * Tests using .NET 5 * Test using .NET 5 * Options for .NET 5 * Approved API Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- ...Composer.AspNetCore.Endpoints.Tests.csproj | 2 +- .../API/APIApprovals.cs | 8 +- .../APIApprovals.Approve_API.approved.txt | 145 ++++++++++++++++++ .../APIApprovals.Approve_API.approved.txt | 1 + .../APIApprovals.Approve_API.approved.txt | 1 + .../ServiceComposer.AspNetCore.Tests.csproj | 36 ++++- .../CompositionEndpointBuilder.cs | 2 +- .../CompositionEndpointDataSource.cs | 2 +- .../CompositionHandler.cs | 2 +- .../CompositionOverControllersActionFilter.cs | 2 +- .../EndpointsExtensions.cs | 2 +- .../HttpRequestExtensions.cs | 2 +- .../IViewModelPreviewHandler.cs | 2 +- .../ServiceComposer.AspNetCore.csproj | 10 +- .../ViewModelCompositionOptions.cs | 8 +- 15 files changed, 203 insertions(+), 22 deletions(-) create mode 100644 src/ServiceComposer.AspNetCore.Tests/API/NET5_0/APIApprovals.Approve_API.approved.txt rename src/ServiceComposer.AspNetCore.Tests/API/{NETSTANDARD2_0 => NETCOREAPP2_1}/APIApprovals.Approve_API.approved.txt (98%) diff --git a/src/ServiceComposer.AspNetCore.Endpoints.Tests/ServiceComposer.AspNetCore.Endpoints.Tests.csproj b/src/ServiceComposer.AspNetCore.Endpoints.Tests/ServiceComposer.AspNetCore.Endpoints.Tests.csproj index 57504784..aee7980e 100644 --- a/src/ServiceComposer.AspNetCore.Endpoints.Tests/ServiceComposer.AspNetCore.Endpoints.Tests.csproj +++ b/src/ServiceComposer.AspNetCore.Endpoints.Tests/ServiceComposer.AspNetCore.Endpoints.Tests.csproj @@ -2,7 +2,7 @@ false - netcoreapp3.1 + netcoreapp3.1;net5.0 diff --git a/src/ServiceComposer.AspNetCore.Tests/API/APIApprovals.cs b/src/ServiceComposer.AspNetCore.Tests/API/APIApprovals.cs index 9083fa91..5807ffe4 100644 --- a/src/ServiceComposer.AspNetCore.Tests/API/APIApprovals.cs +++ b/src/ServiceComposer.AspNetCore.Tests/API/APIApprovals.cs @@ -14,8 +14,12 @@ public class APIApprovals [MethodImpl(MethodImplOptions.NoInlining)] #if NETCOREAPP3_1 [UseApprovalSubdirectory("NETCOREAPP3_1")] - #else - [UseApprovalSubdirectory("NETSTANDARD2_0")] + #endif + #if NET5_0 + [UseApprovalSubdirectory("NET5_0")] + #endif + #if NETCOREAPP2_1 + [UseApprovalSubdirectory("NETCOREAPP2_1")] #endif public void Approve_API() { diff --git a/src/ServiceComposer.AspNetCore.Tests/API/NET5_0/APIApprovals.Approve_API.approved.txt b/src/ServiceComposer.AspNetCore.Tests/API/NET5_0/APIApprovals.Approve_API.approved.txt new file mode 100644 index 00000000..10c513cb --- /dev/null +++ b/src/ServiceComposer.AspNetCore.Tests/API/NET5_0/APIApprovals.Approve_API.approved.txt @@ -0,0 +1,145 @@ +[assembly: System.Reflection.AssemblyMetadata("RepositoryUrl", "https://github.com/ServiceComposer/ServiceComposer.AspNetCore.git")] +[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("ServiceComposer.AspNetCore.Tests")] +[assembly: System.Runtime.Versioning.TargetFramework(".NETCoreApp,Version=v5.0", FrameworkDisplayName="")] +namespace ServiceComposer.AspNetCore +{ + public class AssemblyScanner + { + public System.IO.SearchOption DirectorySearchOptions { get; set; } + public bool IsEnabled { get; } + public void AddAssemblyFilter(System.Func filter) { } + public void Disable() { } + public enum FilterResults + { + Exclude = 0, + Include = 1, + } + } + public class ComposedRequestIdHeader + { + public const string Key = "composed-request-id"; + public ComposedRequestIdHeader() { } + } + public static class ComposedRequestIdHeaderExtensions + { + public static void AddComposedRequestIdHeader(this Microsoft.AspNetCore.Http.IHeaderDictionary headers, string requestId) { } + public static void AddComposedRequestIdHeader(this System.Net.Http.Headers.HttpRequestHeaders headers, string requestId) { } + public static string GetComposedRequestId(this Microsoft.AspNetCore.Http.IHeaderDictionary headers) { } + public static string GetComposedRequestIdHeaderOr(this Microsoft.AspNetCore.Http.IHeaderDictionary headers, System.Func defaultValue) { } + } + public delegate System.Threading.Tasks.Task CompositionEventHandler(TEvent @event, Microsoft.AspNetCore.Http.HttpRequest httpRequest); + public class CompositionHandler + { + public CompositionHandler() { } + [return: System.Runtime.CompilerServices.Dynamic(new bool[] { + false, + false, + true, + false})] + [return: System.Runtime.CompilerServices.TupleElementNames(new string[] { + "ViewModel", + "StatusCode"})] + public static System.Threading.Tasks.Task> HandleRequest(string requestId, Microsoft.AspNetCore.Http.HttpContext context) { } + } + public static class EndpointsExtensions + { + public static void MapCompositionHandlers(this Microsoft.AspNetCore.Routing.IEndpointRouteBuilder endpoints) { } + [System.Obsolete("To enable write support use the EnableWriteSupport() method on the ViewModelCompo" + + "sitionOptions. This method will be removed in v2.")] + public static void MapCompositionHandlers(this Microsoft.AspNetCore.Routing.IEndpointRouteBuilder endpoints, bool enableWriteSupport) { } + } + public delegate System.Threading.Tasks.Task EventHandler(string requestId, [System.Runtime.CompilerServices.Dynamic] object viewModel, TEvent @event, Microsoft.AspNetCore.Routing.RouteData routeData, Microsoft.AspNetCore.Http.HttpRequest httpRequest); + public static class HttpRequestExtensions + { + public static readonly string ComposedResponseModelKey; + [return: System.Runtime.CompilerServices.Dynamic] + public static object GetComposedResponseModel(this Microsoft.AspNetCore.Http.HttpRequest request) { } + } + public interface ICompositionErrorsHandler + { + System.Threading.Tasks.Task OnRequestError(Microsoft.AspNetCore.Http.HttpRequest request, System.Exception ex); + } + public interface ICompositionEventsPublisher + { + void Subscribe(ServiceComposer.AspNetCore.CompositionEventHandler handler); + } + public interface ICompositionEventsSubscriber + { + void Subscribe(ServiceComposer.AspNetCore.ICompositionEventsPublisher publisher); + } + public interface ICompositionRequestsHandler + { + System.Threading.Tasks.Task Handle(Microsoft.AspNetCore.Http.HttpRequest request); + } + public interface IHandleRequests : ServiceComposer.AspNetCore.IInterceptRoutes + { + System.Threading.Tasks.Task Handle(string requestId, [System.Runtime.CompilerServices.Dynamic] object vm, Microsoft.AspNetCore.Routing.RouteData routeData, Microsoft.AspNetCore.Http.HttpRequest request); + } + public interface IHandleRequestsErrors : ServiceComposer.AspNetCore.IInterceptRoutes + { + System.Threading.Tasks.Task OnRequestError(string requestId, System.Exception ex, [System.Runtime.CompilerServices.Dynamic] object vm, Microsoft.AspNetCore.Routing.RouteData routeData, Microsoft.AspNetCore.Http.HttpRequest request); + } + public interface IInterceptRoutes + { + bool Matches(Microsoft.AspNetCore.Routing.RouteData routeData, string httpVerb, Microsoft.AspNetCore.Http.HttpRequest request); + } + public interface IPublishCompositionEvents + { + void Subscribe(ServiceComposer.AspNetCore.EventHandler handler); + } + public interface ISubscribeToCompositionEvents : ServiceComposer.AspNetCore.IInterceptRoutes + { + void Subscribe(ServiceComposer.AspNetCore.IPublishCompositionEvents publisher); + } + public interface IViewModelCompositionOptionsCustomization + { + void Customize(ServiceComposer.AspNetCore.ViewModelCompositionOptions options); + } + public interface IViewModelPreviewHandler + { + [System.Obsolete("Use Preview(HttpRequest request, dynamic viewModel). Will be removed in v2.")] + System.Threading.Tasks.Task Preview([System.Runtime.CompilerServices.Dynamic] object viewModel); + System.Threading.Tasks.Task Preview(Microsoft.AspNetCore.Http.HttpRequest request, [System.Runtime.CompilerServices.Dynamic] object viewModel); + } + public static class ServiceCollectionExtensions + { + public static void AddViewModelComposition(this Microsoft.Extensions.DependencyInjection.IServiceCollection services) { } + public static void AddViewModelComposition(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, System.Action config) { } + } + public class ViewModelCompositionOptions + { + public ServiceComposer.AspNetCore.AssemblyScanner AssemblyScanner { get; } + public Microsoft.Extensions.DependencyInjection.IServiceCollection Services { get; } + public void AddServicesConfigurationHandler(System.Type serviceType, System.Action configurationHandler) { } + public void AddTypesRegistrationHandler(System.Func typesFilter, System.Action> registrationHandler) { } + public void EnableCompositionOverControllers() { } + public void EnableCompositionOverControllers(bool useCaseInsensitiveRouteMatching) { } + public void EnableWriteSupport() { } + public void RegisterCompositionEventsSubscriber() + where T : ServiceComposer.AspNetCore.ISubscribeToCompositionEvents { } + public void RegisterCompositionHandler() { } + public void RegisterRequestsHandler() + where T : ServiceComposer.AspNetCore.IHandleRequests { } + } +} +namespace ServiceComposer.AspNetCore.Gateway +{ + public static class ApplicationBuilderExtensions + { + public static void RunCompositionGateway(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, System.Action routes = null) { } + public static void RunCompositionGatewayWithDefaultRoutes(this Microsoft.AspNetCore.Builder.IApplicationBuilder app) { } + } + public static class Composition + { + public static System.Threading.Tasks.Task HandleRequest(Microsoft.AspNetCore.Http.HttpContext context) { } + } + public static class RouteBuilderExtentions + { + public static Microsoft.AspNetCore.Routing.IRouteBuilder MapComposableDelete(this Microsoft.AspNetCore.Routing.IRouteBuilder routeBuilder, string template, Microsoft.AspNetCore.Routing.RouteValueDictionary defaults = null, Microsoft.AspNetCore.Routing.RouteValueDictionary dataTokens = null) { } + public static Microsoft.AspNetCore.Routing.IRouteBuilder MapComposableGet(this Microsoft.AspNetCore.Routing.IRouteBuilder routeBuilder, string template, Microsoft.AspNetCore.Routing.RouteValueDictionary defaults = null, Microsoft.AspNetCore.Routing.RouteValueDictionary dataTokens = null) { } + public static Microsoft.AspNetCore.Routing.IRouteBuilder MapComposablePatch(this Microsoft.AspNetCore.Routing.IRouteBuilder routeBuilder, string template, Microsoft.AspNetCore.Routing.RouteValueDictionary defaults = null, Microsoft.AspNetCore.Routing.RouteValueDictionary dataTokens = null) { } + public static Microsoft.AspNetCore.Routing.IRouteBuilder MapComposablePost(this Microsoft.AspNetCore.Routing.IRouteBuilder routeBuilder, string template, Microsoft.AspNetCore.Routing.RouteValueDictionary defaults = null, Microsoft.AspNetCore.Routing.RouteValueDictionary dataTokens = null) { } + public static Microsoft.AspNetCore.Routing.IRouteBuilder MapComposablePut(this Microsoft.AspNetCore.Routing.IRouteBuilder routeBuilder, string template, Microsoft.AspNetCore.Routing.RouteValueDictionary defaults = null, Microsoft.AspNetCore.Routing.RouteValueDictionary dataTokens = null) { } + public static Microsoft.AspNetCore.Routing.IRouteBuilder MapComposableRoute(this Microsoft.AspNetCore.Routing.IRouteBuilder routeBuilder, string template, System.Collections.Generic.IDictionary constraints, Microsoft.AspNetCore.Routing.RouteValueDictionary defaults = null, Microsoft.AspNetCore.Routing.RouteValueDictionary dataTokens = null) { } + } +} \ No newline at end of file diff --git a/src/ServiceComposer.AspNetCore.Tests/API/NETSTANDARD2_0/APIApprovals.Approve_API.approved.txt b/src/ServiceComposer.AspNetCore.Tests/API/NETCOREAPP2_1/APIApprovals.Approve_API.approved.txt similarity index 98% rename from src/ServiceComposer.AspNetCore.Tests/API/NETSTANDARD2_0/APIApprovals.Approve_API.approved.txt rename to src/ServiceComposer.AspNetCore.Tests/API/NETCOREAPP2_1/APIApprovals.Approve_API.approved.txt index d4bc6007..b150a120 100644 --- a/src/ServiceComposer.AspNetCore.Tests/API/NETSTANDARD2_0/APIApprovals.Approve_API.approved.txt +++ b/src/ServiceComposer.AspNetCore.Tests/API/NETCOREAPP2_1/APIApprovals.Approve_API.approved.txt @@ -1,3 +1,4 @@ +[assembly: System.Reflection.AssemblyMetadata("RepositoryUrl", "https://github.com/ServiceComposer/ServiceComposer.AspNetCore.git")] [assembly: System.Runtime.CompilerServices.InternalsVisibleTo("ServiceComposer.AspNetCore.Tests")] [assembly: System.Runtime.Versioning.TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName="")] namespace ServiceComposer.AspNetCore diff --git a/src/ServiceComposer.AspNetCore.Tests/API/NETCOREAPP3_1/APIApprovals.Approve_API.approved.txt b/src/ServiceComposer.AspNetCore.Tests/API/NETCOREAPP3_1/APIApprovals.Approve_API.approved.txt index 9d3c30a1..e38760c4 100644 --- a/src/ServiceComposer.AspNetCore.Tests/API/NETCOREAPP3_1/APIApprovals.Approve_API.approved.txt +++ b/src/ServiceComposer.AspNetCore.Tests/API/NETCOREAPP3_1/APIApprovals.Approve_API.approved.txt @@ -1,3 +1,4 @@ +[assembly: System.Reflection.AssemblyMetadata("RepositoryUrl", "https://github.com/ServiceComposer/ServiceComposer.AspNetCore.git")] [assembly: System.Runtime.CompilerServices.InternalsVisibleTo("ServiceComposer.AspNetCore.Tests")] [assembly: System.Runtime.Versioning.TargetFramework(".NETCoreApp,Version=v3.1", FrameworkDisplayName="")] namespace ServiceComposer.AspNetCore diff --git a/src/ServiceComposer.AspNetCore.Tests/ServiceComposer.AspNetCore.Tests.csproj b/src/ServiceComposer.AspNetCore.Tests/ServiceComposer.AspNetCore.Tests.csproj index cb17fc44..3f91563b 100644 --- a/src/ServiceComposer.AspNetCore.Tests/ServiceComposer.AspNetCore.Tests.csproj +++ b/src/ServiceComposer.AspNetCore.Tests/ServiceComposer.AspNetCore.Tests.csproj @@ -2,33 +2,57 @@ false - netcoreapp2.1;netcoreapp3.1 + netcoreapp2.1;netcoreapp3.1;net5.0 - + + + + + + + + + + + + + - - + - + - + all runtime; build; native; contentfiles; analyzers + + + + .cs + APIApprovals + APIApprovals.cs + + + .cs + APIApprovals + APIApprovals.cs + + diff --git a/src/ServiceComposer.AspNetCore/CompositionEndpointBuilder.cs b/src/ServiceComposer.AspNetCore/CompositionEndpointBuilder.cs index ed3e7d51..cc9f6644 100644 --- a/src/ServiceComposer.AspNetCore/CompositionEndpointBuilder.cs +++ b/src/ServiceComposer.AspNetCore/CompositionEndpointBuilder.cs @@ -1,4 +1,4 @@ -#if NETCOREAPP3_1 +#if NETCOREAPP3_1 || NET5_0 using System; using System.Collections.Generic; diff --git a/src/ServiceComposer.AspNetCore/CompositionEndpointDataSource.cs b/src/ServiceComposer.AspNetCore/CompositionEndpointDataSource.cs index 4e1967d0..2dfd28a8 100644 --- a/src/ServiceComposer.AspNetCore/CompositionEndpointDataSource.cs +++ b/src/ServiceComposer.AspNetCore/CompositionEndpointDataSource.cs @@ -1,4 +1,4 @@ -#if NETCOREAPP3_1 +#if NETCOREAPP3_1 || NET5_0 using System.Collections.Generic; using System.Linq; diff --git a/src/ServiceComposer.AspNetCore/CompositionHandler.cs b/src/ServiceComposer.AspNetCore/CompositionHandler.cs index 3d484ef4..c6be8230 100644 --- a/src/ServiceComposer.AspNetCore/CompositionHandler.cs +++ b/src/ServiceComposer.AspNetCore/CompositionHandler.cs @@ -77,7 +77,7 @@ public class CompositionHandler } } -#if NETCOREAPP3_1 +#if NETCOREAPP3_1 || NET5_0 internal static async Task HandleComposableRequest(HttpContext context, Type[] handlerTypes) { context.Request.EnableBuffering(); diff --git a/src/ServiceComposer.AspNetCore/CompositionOverControllersActionFilter.cs b/src/ServiceComposer.AspNetCore/CompositionOverControllersActionFilter.cs index 3d37759e..f595985b 100644 --- a/src/ServiceComposer.AspNetCore/CompositionOverControllersActionFilter.cs +++ b/src/ServiceComposer.AspNetCore/CompositionOverControllersActionFilter.cs @@ -1,4 +1,4 @@ -#if NETCOREAPP3_1 +#if NETCOREAPP3_1 || NET5_0 using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Http; diff --git a/src/ServiceComposer.AspNetCore/EndpointsExtensions.cs b/src/ServiceComposer.AspNetCore/EndpointsExtensions.cs index 97fd693f..3dd049d3 100644 --- a/src/ServiceComposer.AspNetCore/EndpointsExtensions.cs +++ b/src/ServiceComposer.AspNetCore/EndpointsExtensions.cs @@ -1,4 +1,4 @@ -#if NETCOREAPP3_1 +#if NETCOREAPP3_1 || NET5_0 using System; using System.Collections.Generic; diff --git a/src/ServiceComposer.AspNetCore/HttpRequestExtensions.cs b/src/ServiceComposer.AspNetCore/HttpRequestExtensions.cs index 1c60d24c..1f323178 100644 --- a/src/ServiceComposer.AspNetCore/HttpRequestExtensions.cs +++ b/src/ServiceComposer.AspNetCore/HttpRequestExtensions.cs @@ -1,4 +1,4 @@ -#if NETCOREAPP3_1 +#if NETCOREAPP3_1 || NET5_0 using Microsoft.AspNetCore.Http; diff --git a/src/ServiceComposer.AspNetCore/IViewModelPreviewHandler.cs b/src/ServiceComposer.AspNetCore/IViewModelPreviewHandler.cs index d537a354..762f44dd 100644 --- a/src/ServiceComposer.AspNetCore/IViewModelPreviewHandler.cs +++ b/src/ServiceComposer.AspNetCore/IViewModelPreviewHandler.cs @@ -1,4 +1,4 @@ -#if NETCOREAPP3_1 +#if NETCOREAPP3_1 || NET5_0 using System; using System.Threading.Tasks; diff --git a/src/ServiceComposer.AspNetCore/ServiceComposer.AspNetCore.csproj b/src/ServiceComposer.AspNetCore/ServiceComposer.AspNetCore.csproj index 56475831..0d315d90 100644 --- a/src/ServiceComposer.AspNetCore/ServiceComposer.AspNetCore.csproj +++ b/src/ServiceComposer.AspNetCore/ServiceComposer.AspNetCore.csproj @@ -1,7 +1,7 @@  - netstandard2.0;netcoreapp3.1 + netstandard2.0;netcoreapp3.1;net5.0 @@ -23,17 +23,23 @@ + + + + + + + - diff --git a/src/ServiceComposer.AspNetCore/ViewModelCompositionOptions.cs b/src/ServiceComposer.AspNetCore/ViewModelCompositionOptions.cs index 404ccfc1..cf697954 100644 --- a/src/ServiceComposer.AspNetCore/ViewModelCompositionOptions.cs +++ b/src/ServiceComposer.AspNetCore/ViewModelCompositionOptions.cs @@ -9,7 +9,7 @@ namespace ServiceComposer.AspNetCore public class ViewModelCompositionOptions { readonly CompositionMetadataRegistry _compositionMetadataRegistry = new CompositionMetadataRegistry(); -#if NETCOREAPP3_1 +#if NETCOREAPP3_1 || NET5_0 readonly CompositionOverControllersRoutes _compositionOverControllersRoutes = new CompositionOverControllersRoutes(); #endif @@ -40,7 +40,7 @@ public void AddTypesRegistrationHandler(Func typesFilter, Action {