Skip to content

Commit

Permalink
Add .NET 6 support (#358)
Browse files Browse the repository at this point in the history
* Add .NET 6 target framework
  • Loading branch information
mauroservienti authored Feb 17, 2022
1 parent 929cf18 commit d2d1dd4
Show file tree
Hide file tree
Showing 18 changed files with 33 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

<PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/ServiceComposer.AspNetCore.Tests/API/APIApprovals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class APIApprovals
[Fact]
[UseReporter(typeof(DiffReporter))]
[MethodImpl(MethodImplOptions.NoInlining)]
#if NETCOREAPP3_1 || NET5_0
#if NETCOREAPP3_1 || NET5_0_OR_GREATER
[UseApprovalSubdirectory("NET")]
#endif
#if NETCOREAPP2_1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NETCOREAPP3_1 || NET5_0
#if NETCOREAPP3_1 || NET5_0_OR_GREATER

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 || NET5_0
#if NETCOREAPP3_1 || NET5_0_OR_GREATER

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 @@ -85,7 +85,7 @@ public class CompositionHandler
}
}

#if NETCOREAPP3_1 || NET5_0
#if NETCOREAPP3_1 || NET5_0_OR_GREATER
internal static async Task<object> HandleComposableRequest(HttpContext context, Type[] componentsTypes)
{
context.Request.EnableBuffering();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NETCOREAPP3_1 || NET5_0
#if NETCOREAPP3_1 || NET5_0_OR_GREATER
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
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 || NET5_0
#if NETCOREAPP3_1 || NET5_0_OR_GREATER

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 || NET5_0
#if NETCOREAPP3_1 || NET5_0_OR_GREATER
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Abstractions;
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 || NET5_0
#if NETCOREAPP3_1 || NET5_0_OR_GREATER

using System;
using Microsoft.AspNetCore.Http;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NETCOREAPP3_1 || NET5_0
#if NETCOREAPP3_1 || NET5_0_OR_GREATER
namespace ServiceComposer.AspNetCore
{
public interface IEndpointScopedViewModelFactory : IViewModelFactory
Expand Down
2 changes: 1 addition & 1 deletion src/ServiceComposer.AspNetCore/IViewModelFactory.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NETCOREAPP3_1 || NET5_0
#if NETCOREAPP3_1 || NET5_0_OR_GREATER
using Microsoft.AspNetCore.Http;

namespace ServiceComposer.AspNetCore
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 || NET5_0
#if NETCOREAPP3_1 || NET5_0_OR_GREATER

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

using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NET5_0 || NETCOREAPP3_1
#if NET5_0_OR_GREATER || NETCOREAPP3_1

using System;
using System.Threading.Tasks;
Expand Down Expand Up @@ -41,7 +41,7 @@ public RequestModelBinder(IModelBinderFactory modelBinderFactory, IModelMetadata
var valueProvider =
await CompositeValueProvider.CreateAsync(actionContext, mvcOptions.Value.ValueProviderFactories);

#if NET5_0
#if NET5_0_OR_GREATER
if (modelMetadata.BoundConstructor != null)
{
throw new NotSupportedException("Record type not supported");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace ServiceComposer.AspNetCore
{
#if NETCOREAPP3_1 || NET5_0
#if NETCOREAPP3_1 || NET5_0_OR_GREATER
public class ResponseSerializationOptions
{
IServiceCollection services;
Expand Down
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;net5.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
</PropertyGroup>

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

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

<ItemGroup Condition=" '$(TargetFramework)' == 'net5.0' ">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="[5.0.0, 6.0.0)" />
Expand Down
20 changes: 10 additions & 10 deletions src/ServiceComposer.AspNetCore/ViewModelCompositionOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Linq;
using System.Reflection;
using Microsoft.Extensions.DependencyInjection;
#if NETCOREAPP3_1 || NET5_0
#if NETCOREAPP3_1 || NET5_0_OR_GREATER
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.Extensions.Options;
Expand All @@ -14,7 +14,7 @@ namespace ServiceComposer.AspNetCore
public class ViewModelCompositionOptions
{
readonly CompositionMetadataRegistry _compositionMetadataRegistry = new CompositionMetadataRegistry();
#if NETCOREAPP3_1 || NET5_0
#if NETCOREAPP3_1 || NET5_0_OR_GREATER
readonly CompositionOverControllersRoutes _compositionOverControllersRoutes = new CompositionOverControllersRoutes();
#endif

Expand All @@ -25,7 +25,7 @@ internal ViewModelCompositionOptions(IServiceCollection services)

Services.AddSingleton(this);
Services.AddSingleton(_compositionMetadataRegistry);
#if NETCOREAPP3_1 || NET5_0
#if NETCOREAPP3_1 || NET5_0_OR_GREATER
ResponseSerialization = new ResponseSerializationOptions(Services);
#endif
}
Expand All @@ -50,7 +50,7 @@ public void AddTypesRegistrationHandler(Func<Type, bool> typesFilter, Action<IEn
typesRegistrationHandlers.Add((typesFilter, registrationHandler));
}

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

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

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

#if NETCOREAPP3_1 || NET5_0
#if NETCOREAPP3_1 || NET5_0_OR_GREATER
AddTypesRegistrationHandler(
typesFilter: type =>
{
Expand Down Expand Up @@ -217,7 +217,7 @@ internal void InitializeServiceCollection()

public IServiceCollection Services { get; private set; }

#if NETCOREAPP3_1 || NET5_0
#if NETCOREAPP3_1 || NET5_0_OR_GREATER
public ResponseSerializationOptions ResponseSerialization { get; }
#endif

Expand Down Expand Up @@ -246,13 +246,13 @@ void RegisterCompositionComponents(Type type)
!(
typeof(ICompositionRequestsHandler).IsAssignableFrom(type)
|| typeof(ICompositionEventsSubscriber).IsAssignableFrom(type)
#if NETCOREAPP3_1 || NET5_0
#if NETCOREAPP3_1 || NET5_0_OR_GREATER
|| typeof(IEndpointScopedViewModelFactory).IsAssignableFrom(type)
#endif
)
)
{
#if NETCOREAPP3_1 || NET5_0
#if NETCOREAPP3_1 || NET5_0_OR_GREATER
var message = $"Registered types must be either {nameof(ICompositionRequestsHandler)}, " +
$"{nameof(ICompositionEventsSubscriber)}, or {nameof(IEndpointScopedViewModelFactory)}.";
#else
Expand All @@ -273,7 +273,7 @@ void RegisterCompositionComponents(Type type)
}
}

#if NETCOREAPP3_1 || NET5_0
#if NETCOREAPP3_1 || NET5_0_OR_GREATER
public void RegisterEndpointScopedViewModelFactory<T>() where T: IEndpointScopedViewModelFactory
{
RegisterCompositionComponents(typeof(T));
Expand Down

0 comments on commit d2d1dd4

Please sign in to comment.