Skip to content

Commit

Permalink
Merge branch 'refactoring/net-core-3' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Duco committed Sep 25, 2019
2 parents 4943871 + 411e443 commit d0720e8
Show file tree
Hide file tree
Showing 31 changed files with 417 additions and 364 deletions.
4 changes: 2 additions & 2 deletions scripts/build/05-Build-Windows.ps1
Expand Up @@ -10,7 +10,7 @@ Param(
)

$nsiPath = "$PSScriptRoot/httplaceholder.nsi"
$binDir = "$srcFolder/HttPlaceholder/bin/release/netcoreapp2.2/win-x64/publish"
$binDir = "$srcFolder/HttPlaceholder/bin/release/netcoreapp3.0/win-x64/publish"
$docsFolder = "$rootFolder/docs"
$installScriptsPath = "$PSScriptRoot/installscripts/windows"

Expand All @@ -25,7 +25,7 @@ Remove-Item $binDir -Force -Confirm:$false -Recurse -ErrorAction Ignore

# Create Windows package
Write-Host "Packing up for Windows" -ForegroundColor Green
& dotnet publish $mainProjectFile --configuration=release --runtime=win-x64
& dotnet publish $mainProjectFile --configuration=release --runtime=win-x64 /p:PublishTrimmed=true
Assert-Cmd-Ok

# Moving install scripts for Windows
Expand Down
4 changes: 2 additions & 2 deletions scripts/build/06-Build-Linux.ps1
Expand Up @@ -9,7 +9,7 @@ Param(
[Parameter(Mandatory = $True)][string]$mainProjectFile
)

$binDir = Join-Path $srcFolder "HttPlaceholder\bin\release\netcoreapp2.2\linux-x64\publish"
$binDir = Join-Path $srcFolder "HttPlaceholder\bin\release\netcoreapp3.0\linux-x64\publish"
$docsFolder = "$rootFolder/docs"

# Patching main .csproj file
Expand All @@ -23,7 +23,7 @@ Remove-Item $binDir -Force -Confirm:$false -Recurse -ErrorAction Ignore

# Create Linux package
Write-Host "Packing up for Linux" -ForegroundColor Green
& dotnet publish $mainProjectFile --configuration=release --runtime=linux-x64
& dotnet publish $mainProjectFile --configuration=release --runtime=linux-x64 /p:PublishTrimmed=true
Assert-Cmd-Ok

# Moving docs folder to bin path
Expand Down
4 changes: 2 additions & 2 deletions scripts/build/07-Build-OsX.ps1
Expand Up @@ -9,7 +9,7 @@ Param(
[Parameter(Mandatory = $True)][string]$mainProjectFile
)

$binDir = Join-Path $srcFolder "HttPlaceholder\bin\release\netcoreapp2.2\osx-x64\publish"
$binDir = Join-Path $srcFolder "HttPlaceholder\bin\release\netcoreapp3.0\osx-x64\publish"
$docsFolder = "$rootFolder/docs"

# Patching main .csproj file
Expand All @@ -23,7 +23,7 @@ Remove-Item $binDir -Force -Confirm:$false -Recurse -ErrorAction Ignore

# Create OS X package
Write-Host "Packing up for OS X" -ForegroundColor Green
& dotnet publish $mainProjectFile --configuration=release --runtime=osx-x64
& dotnet publish $mainProjectFile --configuration=release --runtime=osx-x64 /p:PublishTrimmed=true
Assert-Cmd-Ok

# Moving docs folder to bin path
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/08-Create-OpenAPI-File.ps1
Expand Up @@ -12,5 +12,5 @@ Set-Location $swaggerGenFolder
& dotnet run -c Release
Assert-Cmd-Ok

$swaggerLocation = "$swaggerGenFolder/bin/Release/netcoreapp2.2/swagger.json"
$swaggerLocation = "$swaggerGenFolder/bin/Release/netcoreapp3.0/swagger.json"
Copy-Item $swaggerLocation $distFolder
8 changes: 8 additions & 0 deletions scripts/build/10-Build-Tool.ps1
Expand Up @@ -16,6 +16,14 @@ $propertyGroupNode.PackAsTool = "true"
$csproj.Save($mainProjectFile)

# Building dotnet tool
if ($IsLinux) {
# For some reason, the MySqlConnector NuGet package has last write time set to "1 january 1980", which NuGet doesn't like.
# For now, set the last write time of this package to now to make it work.
Write-Host "Updating MySqlConnector last write time"
& touch "$($env:HOME)/.nuget/packages/mysqlconnector/0.57.0/lib/netcoreapp3.0/MySqlConnector.dll"
Assert-Cmd-Ok
}

& dotnet pack $mainProjectFile -c Tool
Assert-Cmd-Ok

Expand Down
@@ -1,25 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsAsErrors />
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.0.0" />
<PackageReference Include="MSTest.TestFramework" Version="2.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\HttPlaceholder.Application\HttPlaceholder.Application.csproj" />
<ProjectReference Include="..\HttPlaceholder.TestUtilities\HttPlaceholder.TestUtilities.csproj" />
</ItemGroup>

</Project>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsAsErrors />
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.0.0" />
<PackageReference Include="MSTest.TestFramework" Version="2.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\HttPlaceholder.Application\HttPlaceholder.Application.csproj" />
<ProjectReference Include="..\HttPlaceholder.TestUtilities\HttPlaceholder.TestUtilities.csproj" />
</ItemGroup>

</Project>
Expand Up @@ -15,11 +15,11 @@
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="8.4.0" />
<PackageReference Include="IPAddressRange" Version="4.0.0" />
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Http.Features" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Http.Features" Version="3.0.0" />
<PackageReference Include="Microsoft.AspNetCore.WebUtilities" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Primitives" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Primitives" Version="3.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
38 changes: 19 additions & 19 deletions src/HttPlaceholder.Client.Tests/HttPlaceholder.Client.Tests.csproj
@@ -1,19 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<Version>2019.8.24.1234</Version>
<AssemblyVersion>2019.8.24.1234</AssemblyVersion>
<FileVersion>2019.8.24.1234</FileVersion>
<IsPackable>false</IsPackable>
<Configurations>Debug;Release;Tool</Configurations>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.0.0" />
<PackageReference Include="MSTest.TestFramework" Version="2.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\HttPlaceholder.Client\HttPlaceholder.Client.csproj" />
</ItemGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<Version>2019.8.24.1234</Version>
<AssemblyVersion>2019.8.24.1234</AssemblyVersion>
<FileVersion>2019.8.24.1234</FileVersion>
<IsPackable>false</IsPackable>
<Configurations>Debug;Release;Tool</Configurations>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.0.0" />
<PackageReference Include="MSTest.TestFramework" Version="2.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\HttPlaceholder.Client\HttPlaceholder.Client.csproj" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions src/HttPlaceholder.Client/HttPlaceholder.Client.csproj
Expand Up @@ -23,8 +23,8 @@
<DocumentationFile />
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="3.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="NSwag.MSBuild" Version="13.0.6">
<PrivateAssets>all</PrivateAssets>
Expand Down
2 changes: 1 addition & 1 deletion src/HttPlaceholder.Common/HttPlaceholder.Common.csproj
Expand Up @@ -10,7 +10,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.0.0" />
<PackageReference Include="YamlDotNet" Version="6.1.2" />
</ItemGroup>

Expand Down
@@ -1,25 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsAsErrors />
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="Moq" Version="4.13.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.0.0" />
<PackageReference Include="MSTest.TestFramework" Version="2.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\HttPlaceholder.Configuration\HttPlaceholder.Configuration.csproj" />
</ItemGroup>

</Project>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<WarningsAsErrors />
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
<PackageReference Include="Moq" Version="4.13.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.0.0" />
<PackageReference Include="MSTest.TestFramework" Version="2.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\HttPlaceholder.Configuration\HttPlaceholder.Configuration.csproj" />
</ItemGroup>

</Project>
Expand Up @@ -10,7 +10,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
</ItemGroup>

Expand Down
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>
Expand All @@ -12,7 +12,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.0.0" />
<PackageReference Include="MSTest.TestFramework" Version="2.0.0" />
</ItemGroup>
Expand Down
Expand Up @@ -10,7 +10,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
@@ -1,10 +1,12 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HttPlaceholder.Application.Interfaces.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Extensions;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.Extensions.Primitives;

Expand Down Expand Up @@ -46,13 +48,16 @@ public string DisplayUrl

public string GetBody()
{
using (var bodyStream = new MemoryStream())
using (var reader = new StreamReader(bodyStream))
var context = _httpContextAccessor.HttpContext;
using (var reader = new StreamReader(
context.Request.Body,
encoding: Encoding.UTF8,
detectEncodingFromByteOrderMarks: false,
bufferSize: 1024,
leaveOpen: true))
{
_httpContextAccessor.HttpContext.Request.Body.CopyTo(bodyStream);
_httpContextAccessor.HttpContext.Request.Body.Seek(0, SeekOrigin.Begin);
bodyStream.Seek(0, SeekOrigin.Begin);
var body = reader.ReadToEnd();
context.Request.Body.Position = 0;
return body;
}
}
Expand Down Expand Up @@ -115,7 +120,7 @@ public bool TryAddHeader(string key, StringValues values)
public void EnableRewind()
{
var httpContext = _httpContextAccessor.HttpContext;
httpContext.Request.EnableRewind();
httpContext.Request.EnableBuffering();
}

public void ClearResponse()
Expand Down

0 comments on commit d0720e8

Please sign in to comment.