Skip to content

Commit

Permalink
Multi targeting update (#190)
Browse files Browse the repository at this point in the history
* 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] <[email protected]>

* 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>
  • Loading branch information
mauroservienti and dependabot[bot] authored Nov 22, 2020
1 parent 91d0952 commit a8e648c
Show file tree
Hide file tree
Showing 15 changed files with 203 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<IsPackable>false</IsPackable>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFrameworks>netcoreapp3.1;net5.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
8 changes: 6 additions & 2 deletions src/ServiceComposer.AspNetCore.Tests/API/APIApprovals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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<string, ServiceComposer.AspNetCore.AssemblyScanner.FilterResults> 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<string> defaultValue) { }
}
public delegate System.Threading.Tasks.Task CompositionEventHandler<in TEvent>(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<System.ValueTuple<object, int>> 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<TEvent>(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<TEvent>(ServiceComposer.AspNetCore.CompositionEventHandler<TEvent> 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<TEvent>(ServiceComposer.AspNetCore.EventHandler<TEvent> 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<ServiceComposer.AspNetCore.ViewModelCompositionOptions> 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<System.Type, Microsoft.Extensions.DependencyInjection.IServiceCollection> configurationHandler) { }
public void AddTypesRegistrationHandler(System.Func<System.Type, bool> typesFilter, System.Action<System.Collections.Generic.IEnumerable<System.Type>> registrationHandler) { }
public void EnableCompositionOverControllers() { }
public void EnableCompositionOverControllers(bool useCaseInsensitiveRouteMatching) { }
public void EnableWriteSupport() { }
public void RegisterCompositionEventsSubscriber<T>()
where T : ServiceComposer.AspNetCore.ISubscribeToCompositionEvents { }
public void RegisterCompositionHandler<T>() { }
public void RegisterRequestsHandler<T>()
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<Microsoft.AspNetCore.Routing.IRouteBuilder> 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<string, object> constraints, Microsoft.AspNetCore.Routing.RouteValueDictionary defaults = null, Microsoft.AspNetCore.Routing.RouteValueDictionary dataTokens = null) { }
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,57 @@

<PropertyGroup>
<IsPackable>false</IsPackable>
<TargetFrameworks>netcoreapp2.1;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>netcoreapp2.1;netcoreapp3.1;net5.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\ServiceComposer.AspNetCore\ServiceComposer.AspNetCore.csproj" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.1' ">
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="3.1.6" />
<PackageReference Include="Microsoft.AspNetCore.Routing" Version="2.2.2" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="3.1.6" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net5.0' ">
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="5.0.0" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="System.Reflection.Metadata" Version="1.8.1" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="Microsoft.AspNetCore.Routing" Version="2.2.2" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="ApprovalTests" Version="5.4.3" />
<PackageReference Include="ApprovalTests" Version="5.4.4" />
<PackageReference Include="FakeItEasy" Version="6.2.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0" />
<PackageReference Include="PublicApiGenerator" Version="10.2.0" />
<PackageReference Include="ServiceComposer.AspNetCore.Testing" Version="1.1.0" />
<PackageReference Include="ServiceComposer.AspNetCore.Testing" Version="1.2.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<None Update="API\NET5_0\APIApprovals.Approve_API.approved.txt">
<ParentExtension>.cs</ParentExtension>
<ParentFile>APIApprovals</ParentFile>
<DependentUpon>APIApprovals.cs</DependentUpon>
</None>
<None Update="API\NET5_0\APIApprovals.Approve_API.approved.txt.orig">
<ParentExtension>.cs</ParentExtension>
<ParentFile>APIApprovals</ParentFile>
<DependentUpon>APIApprovals.cs</DependentUpon>
</None>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NETCOREAPP3_1
#if NETCOREAPP3_1 || NET5_0

using System;
using System.Collections.Generic;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NETCOREAPP3_1
#if NETCOREAPP3_1 || NET5_0

using System.Collections.Generic;
using System.Linq;
Expand Down
2 changes: 1 addition & 1 deletion src/ServiceComposer.AspNetCore/CompositionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public class CompositionHandler
}
}

#if NETCOREAPP3_1
#if NETCOREAPP3_1 || NET5_0
internal static async Task<dynamic> HandleComposableRequest(HttpContext context, Type[] handlerTypes)
{
context.Request.EnableBuffering();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NETCOREAPP3_1
#if NETCOREAPP3_1 || NET5_0
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
Expand Down
2 changes: 1 addition & 1 deletion src/ServiceComposer.AspNetCore/EndpointsExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NETCOREAPP3_1
#if NETCOREAPP3_1 || NET5_0

using System;
using System.Collections.Generic;
Expand Down
2 changes: 1 addition & 1 deletion src/ServiceComposer.AspNetCore/HttpRequestExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NETCOREAPP3_1
#if NETCOREAPP3_1 || NET5_0

using Microsoft.AspNetCore.Http;

Expand Down
2 changes: 1 addition & 1 deletion src/ServiceComposer.AspNetCore/IViewModelPreviewHandler.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NETCOREAPP3_1
#if NETCOREAPP3_1 || NET5_0

using System;
using System.Threading.Tasks;
Expand Down
10 changes: 8 additions & 2 deletions src/ServiceComposer.AspNetCore/ServiceComposer.AspNetCore.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netcoreapp3.1</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netcoreapp3.1;net5.0</TargetFrameworks>
</PropertyGroup>

<PropertyGroup>
Expand All @@ -23,17 +23,23 @@
<None Include="..\..\assets\ServiceComposer.png" Pack="true" PackagePath="\" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net5.0' ">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="[5.0.0, 6.0.0)" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="[3.1.5, 4.0.0)" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="Microsoft.AspNetCore.Routing" Version="[2.2.2, 3.0.0)" />
<PackageReference Include="Microsoft.CSharp" Version="[4.7.0, 5.0.0)" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="[3.1.5, 4.0.0)" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="[3.1.5, 4.0.0)" />
<PackageReference Include="Newtonsoft.Json" Version="[12.0.3, 13.0.0)" />
<PackageReference Include="System.Reflection.Metadata" Version="[1.8.1, 2.0.0)" />
<PackageReference Include="System.ValueTuple" Version="[4.5.0, 5.0.0)" />
Expand Down
8 changes: 4 additions & 4 deletions src/ServiceComposer.AspNetCore/ViewModelCompositionOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -40,7 +40,7 @@ public void AddTypesRegistrationHandler(Func<Type, bool> typesFilter, Action<IEn
typesRegistrationHandlers.Add((typesFilter, registrationHandler));
}

#if NETCOREAPP3_1
#if NETCOREAPP3_1 || NET5_0
internal CompositionOverControllersOptions CompositionOverControllersOptions { get; private set; } = new CompositionOverControllersOptions();

public void EnableCompositionOverControllers()
Expand All @@ -64,7 +64,7 @@ public void EnableWriteSupport()

internal void InitializeServiceCollection()
{
#if NETCOREAPP3_1
#if NETCOREAPP3_1 || NET5_0
if (CompositionOverControllersOptions.IsEnabled)
{
Services.AddSingleton(_compositionOverControllersRoutes);
Expand Down Expand Up @@ -109,7 +109,7 @@ internal void InitializeServiceCollection()
}
});

#if NETCOREAPP3_1
#if NETCOREAPP3_1 || NET5_0
AddTypesRegistrationHandler(
typesFilter: type =>
{
Expand Down

0 comments on commit a8e648c

Please sign in to comment.