Skip to content

Commit

Permalink
Add .NET 6 preview 7 support
Browse files Browse the repository at this point in the history
Closes #243
  • Loading branch information
cd21h committed Oct 27, 2021
1 parent c3718f0 commit 0cd24c7
Show file tree
Hide file tree
Showing 24 changed files with 95 additions and 41 deletions.
19 changes: 15 additions & 4 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,23 @@
<Product>Sharp Architecture</Product>
<Authors>Sharp Architecture Dev Team</Authors>

<TargetFrameworks>netstandard2.0;netstandard2.1;net5.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;net5.0;net6.0</TargetFrameworks>
<SignAssembly>false</SignAssembly>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<DebugSymbols>true</DebugSymbols>
<DebugType>portable</DebugType>

<LangVersion>9.0</LangVersion>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<IsTestProject>false</IsTestProject>

<NoWarn>$(NoWarn);0105</NoWarn>
</PropertyGroup>

<PropertyGroup Label="Custom targets">
<!-- target frameworks for unit-tests and applications -->
<AppTargetFrameworks>netcoreapp2.1;netcoreapp3.1;net5.0</AppTargetFrameworks>
<AppTargetFrameworks>netcoreapp2.1;netcoreapp3.1;net5.0;net6.0</AppTargetFrameworks>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)'=='Debug'">
Expand Down Expand Up @@ -57,9 +59,18 @@
<NoWarn>$(NoWarn);0618;1591</NoWarn>
</PropertyGroup>

<PropertyGroup Condition="'$(MSBuildProjectFullPath.Contains(Sample))' == true ">
<PropertyGroup Condition="'$(MSBuildProjectFullPath.Contains(Sample))' == true">
<IsPackable>false</IsPackable>
<NoWarn>$(NoWarn);1591</NoWarn>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1' or '$(TargetFramework)' == 'net5.0' or '$(TargetFramework)' == 'net6.0'">
<DefineConstants>$(DefineConstants);NET3UP</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0'">
<DefineConstants>$(DefineConstants);NET3UP</DefineConstants>
<LangVersion>preview</LangVersion>
</PropertyGroup>

</Project>
8 changes: 8 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project>
<!-- Workaround for this bug (https://github.com/dotnet/sdk/issues/18148) (replace the analyzer name with the one you need to exclude (filename only, no extension) -->
<Target Name="RemoveLoggingAnalyzer" AfterTargets="ResolveLockFileAnalyzers">
<ItemGroup>
<Analyzer Remove="@(Analyzer)" Condition="%(FileName) == 'Microsoft.Extensions.Logging.Generators'" />
</ItemGroup>
</Target>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class TestServerSetup : IDisposable
public TestServerSetup()
{
Server = new TestServer(Program.CreateHostBuilder(Array.Empty<string>())
#if NETCOREAPP3_1 || NET5_0
#if NET3UP
.UseTestServer()
#endif
.UseStartup<Startup>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="2.1.2" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="3.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
Expand Down Expand Up @@ -32,6 +32,9 @@
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="5.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="6.0.0-preview.7.*" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\..\Src\SharpArch.Testing.Xunit.NHibernate\SharpArch.Testing.Xunit.NHibernate.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace Suteki.TardisBank.WebApi.Controllers
public class AnnouncementsController : ControllerBase
{
readonly ILinqRepository<Announcement, int> _announcementRepository;
#if NETCOREAPP3_1 || NET5_0
#if NET3UP
readonly LinkGenerator _linkGenerator;
#endif
readonly IMapper _mapper;
Expand All @@ -35,13 +35,13 @@ public class AnnouncementsController : ControllerBase
/// <param name="announcementRepository">Announcements repository.</param>
/// <param name="mapper">Mapper</param>
public AnnouncementsController(ILinqRepository<Announcement, int> announcementRepository,
#if NETCOREAPP3_1 || NET5_0
#if NET3UP
LinkGenerator linkGenerator,
#endif
IMapper mapper)
{
_announcementRepository = announcementRepository ?? throw new ArgumentNullException(nameof(announcementRepository));
#if NETCOREAPP3_1 || NET5_0
#if NET3UP
_linkGenerator = linkGenerator ?? throw new ArgumentNullException(nameof(linkGenerator));
#endif
_mapper = mapper ?? throw new ArgumentNullException(nameof(mapper));
Expand Down Expand Up @@ -81,12 +81,12 @@ public async Task<ActionResult> Post(NewAnnouncement model)
{
var announcement = _mapper.Map<Announcement>(model);
await _announcementRepository.SaveAsync(announcement, HttpContext.RequestAborted).ConfigureAwait(false);
#if NETCOREAPP3_1 || NET5_0
#if NET3UP
var location = _linkGenerator.GetPathByName("GetAnnouncement", new {id = announcement.Id});
#else
var location = Url.RouteUrl("GetAnnouncement", new {id = announcement.Id});
#endif
return Created(location, announcement);
return Created(location!, announcement);
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Samples/TardisBank/Src/Suteki.TardisBank.WebApi/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Suteki.TardisBank.WebApi
using Serilog.Exceptions;
using Serilog.Formatting.Json;
using Serilog.Sinks.SystemConsole.Themes;
#if NETCOREAPP3_1 || NET5_0
#if NET3UP
using Microsoft.Extensions.Hosting;
#endif

Expand Down
4 changes: 2 additions & 2 deletions Samples/TardisBank/Src/Suteki.TardisBank.WebApi/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public Startup(IConfiguration configuration)
/// <param name="services"></param>
public void ConfigureServices(IServiceCollection services)
{
#if NETCOREAPP3_1 || NET5_0
#if NET3UP
services.AddControllers(options => { options.Filters.Add(new AutoTransactionHandler()); })
.AddNewtonsoftJson();

Expand Down Expand Up @@ -86,7 +86,7 @@ public void ConfigureServices(IServiceCollection services)
/// <param name="app"></param>
public void Configure(IApplicationBuilder app)
{
#if NETCOREAPP3_1 || NET5_0
#if NET3UP
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints => { endpoints.MapControllers(); });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Autofac" Version="6.1.0" />
<PackageReference Include="Autofac" Version="6.2.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.1.0" />
<PackageReference Include="AutoMapper" Version="10.1.1" />
<PackageReference Include="JetBrains.Annotations" Version="2021.1.0" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="2.1.2" />
<PackageReference Include="Serilog.Exceptions" Version="6.1.0" />
<PackageReference Include="JetBrains.Annotations" Version="2021.2.0" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="3.0.0" />
<PackageReference Include="Serilog.Exceptions" Version="7.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0" />
</ItemGroup>
Expand All @@ -31,9 +31,16 @@

<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.5" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.0" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.1" />
<PackageReference Include="Serilog.AspNetCore" Version="4.1.0" />
<PackageReference Include="Serilog.Sinks.Seq" Version="5.0.0" />
<PackageReference Include="Serilog.Sinks.Seq" Version="5.0.1" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.5" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.1" />
<PackageReference Include="Serilog.AspNetCore" Version="4.1.0" />
<PackageReference Include="Serilog.Sinks.Seq" Version="5.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Samples/TransactionAttribute/App/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace TransactionAttribute.WebApi
{

#if NETCOREAPP3_1 || NET5_0
#if NET3UP
using Microsoft.Extensions.Hosting;
using Microsoft.AspNetCore.Hosting;
#else
Expand Down
4 changes: 2 additions & 2 deletions Samples/TransactionAttribute/App/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public Startup(IConfiguration configuration)
/// <param name="services"></param>
public void ConfigureServices(IServiceCollection services)
{
#if NETCOREAPP3_1 || NET5_0
#if NET3UP
services.AddControllers(options =>
{
options.Filters.Add(new AutoTransactionHandler());
Expand Down Expand Up @@ -68,7 +68,7 @@ public void ConfigureServices(IServiceCollection services)
/// <param name="app"></param>
public void Configure(IApplicationBuilder app)
{
#if NETCOREAPP3_1 || NET5_0
#if NET3UP
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
<PackageReference Include="Serilog.Sinks.Seq" Version="5.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.0-preview.7.*" />
<PackageReference Include="Serilog.AspNetCore" Version="4.1.0" />
<PackageReference Include="Serilog.Sinks.Seq" Version="5.0.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\Src\SharpArch.Web.AspNetCore\SharpArch.Web.AspNetCore.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="JetBrains.Annotations" Version="2021.1.0" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="3.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="xunit" Version="2.4.1" />
Expand All @@ -31,6 +32,10 @@
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="5.0.5" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="6.0.0-preview.7.*" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\Src\SharpArch.Web.AspNetCore\SharpArch.Web.AspNetCore.csproj" />
<ProjectReference Include="..\App\TransactionAttribute.WebApi.csproj" />
Expand Down
4 changes: 4 additions & 0 deletions Src/SharpArch.Domain/SharpArch.Domain.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
</ItemGroup>

<ItemGroup Label="Package References (.NET 6)" Condition=" '$(TargetFramework)' == 'net6.0' ">
<PackageReference Include="System.ComponentModel.Annotations" Version="6.0.0-preview.4.*" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2021.1.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
Expand Down
2 changes: 1 addition & 1 deletion Src/SharpArch.Infrastructure/CodeBaseLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class CodeBaseLocator
public static string GetAssemblyCodeBasePath(Assembly assembly)
{
if (assembly == null) throw new ArgumentNullException(nameof(assembly));
#if NET5_0
#if NET5_0_OR_GREATER
var uri = new UriBuilder(assembly.Location);
#else
var uri = new UriBuilder(assembly.CodeBase);
Expand Down
13 changes: 0 additions & 13 deletions Src/SharpArch.Infrastructure/Properties/AssemblyInfo.cs

This file was deleted.

4 changes: 4 additions & 0 deletions Src/SharpArch.Infrastructure/SharpArch.Infrastructure.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="5.0.0" />
</ItemGroup>

<ItemGroup Label="Package References (ASP.NET 6)" Condition=" '$(TargetFramework)' == 'net6.0' ">
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0-preview.7.*" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2021.1.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public static IServiceCollection AddNHibernateWithSingleDatabase(
services.AddSingleton(sp =>
{
var logger = GetLogger(sp);

logger.Debug?.Log("Building session factory...");

var sfBuilder = configureSessionFactory(sp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="5.0.0" />
</ItemGroup>

<ItemGroup Label="Package References (Net 6)" Condition=" '$(TargetFramework)' == 'net6.0' ">
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="6.0.0-preview.7.*" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\SharpArch.Domain\SharpArch.Domain.csproj" />
<ProjectReference Include="..\SharpArch.Infrastructure\SharpArch.Infrastructure.csproj" />
Expand Down
4 changes: 4 additions & 0 deletions Src/SharpArch.Web.AspNetCore/SharpArch.Web.AspNetCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup Label="Package References (ASP.NET 6)" Condition=" '$(TargetFramework)' == 'net6.0' ">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\SharpArch.Domain\SharpArch.Domain.csproj" />
<ProjectReference Include="..\SharpArch.Infrastructure\SharpArch.Infrastructure.csproj" />
Expand Down
5 changes: 5 additions & 0 deletions Src/global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"sdk": {
"version": "6.0.100-preview.6.21355.2"
}
}
1 change: 1 addition & 0 deletions VersionHistory.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ BREAKING:
* Added IEquatable<TId> constraint on IEntity<TId>.
* IRavenDbRepository.FindAllAsync now returns Task<TEntity[]>, not Task<IEnumerable<TEntity>>.
* Removed IRavenDbRepository.Session.
* [.NET 6] Temporary disable logging analyzers - https://github.com/NuGet/Home/issues/6279, https://github.com/dotnet/sdk/issues/18148

IMPROVEMENTS:
* TransactionAttribute now implements Equitable<>
Expand Down
4 changes: 3 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ cache:

install:
- ps: ./mssql-setup.ps1
- ps: dotnet tool install Cake.Tool --version 1.1.0 --global
- ps: ./dotnet-install.ps1 -Version 6.0.100-preview.7.21379.14 -InstallDir "C:\Program Files\dotnet"
- ps: dotnet new tool-manifest
- ps: dotnet tool install Cake.Tool --version 1.2.0

build_script:
- ps: dotnet cake
Expand Down
3 changes: 1 addition & 2 deletions build.cake
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// ADDINS
#addin nuget:?package=Cake.Coveralls&version=1.0.1
#addin nuget:?package=Cake.Coveralls&version=1.1.0
#addin nuget:?package=Cake.FileHelpers&version=4.0.1
//#addin nuget:?package=Cake.Issues&version=0.9.1
#addin nuget:?package=Cake.AppVeyor&version=5.0.1
#addin nuget:?package=Cake.ReSharperReports&version=0.11.1

Expand Down
5 changes: 5 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"sdk": {
"version": "6.0.100-preview.7.21379.14"
}
}

0 comments on commit 0cd24c7

Please sign in to comment.