Skip to content
This repository has been archived by the owner on Jan 24, 2021. It is now read-only.

Commit

Permalink
Merge pull request #2870 from blairconrad/netstandard2.0
Browse files Browse the repository at this point in the history
Update to Netstandard2.0 + xUnit 2.4 beta
  • Loading branch information
thecodejunkie committed May 7, 2018
2 parents c2a5254 + 1940ad6 commit a082f04
Show file tree
Hide file tree
Showing 38 changed files with 139 additions and 98 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dist: trusty
mono:
- 4.4.2

dotnet: 1.1.4
dotnet: 2.1.4

script:
- ./build.sh --verbosity=minimal
Expand Down
87 changes: 48 additions & 39 deletions Nancy.sln

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ var nogit = Argument<bool>("nogit", false);
// Variables
var configuration = "Release";
var fullFrameworkTarget = "net452";
var netStandardTarget = "netstandard1.6";
var netCoreTarget = "netcoreapp1.1";
var netStandardTarget = "netstandard2.0";
var netCoreTarget = "netcoreapp2.0";

// Directories
var output = Directory("build");
Expand Down
4 changes: 2 additions & 2 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
$CakeVersion = "0.24.0"
$DotNetVersion = select-string -Path .\global.json -Pattern '[\d]\.[\d]\.[\d]' | % {$_.Matches} | % {$_.Value };
$DotNetInstallerUri = "https://raw.githubusercontent.com/dotnet/cli/rel/1.0.1/scripts/obtain/dotnet-install.ps1";
$DotNetInstallerUri = "https://raw.githubusercontent.com/dotnet/cli/v$DotNetVersion/scripts/obtain/dotnet-install.ps1";

# Make sure tools folder exists
$PSScriptRoot = $pwd
Expand Down Expand Up @@ -45,7 +45,7 @@ if($FoundDotNetCliVersion -ne $DotNetVersion) {
}

(New-Object System.Net.WebClient).DownloadFile($DotNetInstallerUri, "$InstallPath\dotnet-install.ps1");
& $InstallPath\dotnet-install.ps1 -Channel preview -Version $DotNetVersion -InstallDir $InstallPath;
& $InstallPath\dotnet-install.ps1 -Channel Current -Version $DotNetVersion -InstallDir $InstallPath;

Remove-PathVariable "$InstallPath"
$env:PATH = "$InstallPath;$env:PATH"
Expand Down
6 changes: 3 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ SCRIPT_DIR=$PWD
TOOLS_DIR=$SCRIPT_DIR/tools
CAKE_VERSION=0.24.0
CAKE_DLL=$TOOLS_DIR/Cake.$CAKE_VERSION/Cake.exe
DOTNET_VERSION=$(cat global.json | grep -o '[0-9]\.[0-9]\.[0-9]')
DOTNET_INSTRALL_URI=https://raw.githubusercontent.com/dotnet/cli/rel/1.0.1/scripts/obtain/dotnet-install.sh
DOTNET_VERSION=$(cat "$SCRIPT_DIR/global.json" | grep -o '[0-9]\.[0-9]\.[0-9]')
DOTNET_INSTRALL_URI=https://raw.githubusercontent.com/dotnet/cli/v$DOTNET_VERSION/scripts/obtain/dotnet-install.sh

# Make sure the tools folder exist.
if [ ! -d "$TOOLS_DIR" ]; then
Expand All @@ -22,7 +22,7 @@ if [ ! -d "$SCRIPT_DIR/.dotnet" ]; then
mkdir "$SCRIPT_DIR/.dotnet"
fi
curl -Lsfo "$SCRIPT_DIR/.dotnet/dotnet-install.sh" $DOTNET_INSTRALL_URI
sudo bash "$SCRIPT_DIR/.dotnet/dotnet-install.sh" -c preview --version $DOTNET_VERSION --install-dir .dotnet --no-path
sudo bash "$SCRIPT_DIR/.dotnet/dotnet-install.sh" -c current --version $DOTNET_VERSION --install-dir .dotnet --no-path
export PATH="$SCRIPT_DIR/.dotnet":$PATH
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
export DOTNET_CLI_TELEMETRY_OPTOUT=1
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "1.1.4"
"version": "2.1.4"
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<TargetFramework>netcoreapp2.0</TargetFramework>
<DebugType>portable</DebugType>
<AssemblyName>Nancy.Demo.Hosting.Kestrel</AssemblyName>
<OutputType>Exe</OutputType>
Expand All @@ -12,7 +12,7 @@
<ProjectReference Include="../../src/Nancy.Validation.FluentValidation/Nancy.Validation.FluentValidation.csproj" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.1' ">
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="1.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Owin" Version="1.0.2" />
Expand Down
3 changes: 2 additions & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@
</PackageReference>
</ItemGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.6' ">
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<DefineConstants>$(DefineConstants);CORE</DefineConstants>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<PropertyGroup>
<Description>A basic HTTP authentication provider for Nancy.</Description>
<PackageTags>$(PackageTags);Authentication</PackageTags>
<TargetFrameworks>netstandard1.6;net452</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net452</TargetFrameworks>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<PropertyGroup>
<Description>A forms authentication provider for Nancy.</Description>
<PackageTags>$(PackageTags);Authentication</PackageTags>
<TargetFrameworks>netstandard1.6;net452</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net452</TargetFrameworks>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<PropertyGroup>
<Description>A stateless authentication provider for Nancy.</Description>
<PackageTags>$(PackageTags);Authentication</PackageTags>
<TargetFrameworks>netstandard1.6;net452</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net452</TargetFrameworks>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion src/Nancy.Embedded/Nancy.Embedded.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<PropertyGroup>
<Description>Helpers for serving embedded static content with Nancy.</Description>
<PackageTags>$(PackageTags);Embedded;Static Content</PackageTags>
<TargetFrameworks>netstandard1.6;net452</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net452</TargetFrameworks>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<TargetFramework>net452</TargetFramework>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
<ItemGroup>
<Reference Include="System.Configuration" />
<Reference Include="System.Web" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Nancy.Hosting.Aspnet/Nancy.Hosting.Aspnet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</None>
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
<ItemGroup>
<Reference Include="System.Configuration" />
<Reference Include="System.Web" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Nancy.Metadata.Modules/Nancy.Metadata.Modules.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<PropertyGroup>
<Description>Nancy metadata modules to describe your APIs.</Description>
<PackageTags>$(PackageTags);Metadata</PackageTags>
<TargetFrameworks>netstandard1.6;net452</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net452</TargetFrameworks>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion src/Nancy.Testing/Nancy.Testing.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<Description>Test harness for Nancy applications.</Description>
<PackageTags>$(PackageTags);Testing</PackageTags>
<TargetFrameworks>netstandard1.6;net452</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net452</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<TargetFramework>net452</TargetFramework>
</PropertyGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
<ItemGroup>
<Reference Include="System.ComponentModel.DataAnnotations" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<Description>Adds Fluent Validation support to Nancy.</Description>
<PackageTags>$(PackageTags);Validation;FluentValidation</PackageTags>
<TargetFrameworks>net452;netstandard1.6</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net452</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<Description>Enables using Markdown with Nancy.</Description>
<PackageTags>$(PackageTags);View Engine;Markdown</PackageTags>
<TargetFrameworks>net452;netstandard1.6</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net452</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<ProjectReference Include="../Nancy.ViewEngines.Razor/Nancy.ViewEngines.Razor.csproj" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
<ItemGroup>
<Reference Include="System.Web" />
</ItemGroup>
</Project>
5 changes: 1 addition & 4 deletions src/Nancy.ViewEngines.Razor/Nancy.ViewEngines.Razor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,11 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNet.Razor" Version="2.0.30506" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="1.3.2" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
<PackageReference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" Version="1.0.3" />
<PackageReference Include="System.Collections.Immutable" Version="1.2.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
<ItemGroup>
<Reference Include="System.Configuration" />
<Reference Include="System.IO" />
<Reference Include="System.Reflection" />
Expand Down
2 changes: 1 addition & 1 deletion src/Nancy.ViewEngines.Spark/Nancy.ViewEngines.Spark.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<PackageReference Include="Spark" Version="1.7.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
<ItemGroup>
<Reference Include="System.Configuration" />
<Reference Include="System.Web" />
</ItemGroup>
Expand Down
35 changes: 33 additions & 2 deletions src/Nancy/Conventions/StaticContentConventionBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,19 @@ private static string GetSafeFileName(string path)
return null;
}

private static string GetSafeFullPath(string path)
{
try
{
return Path.GetFullPath(path);
}
catch (Exception)
{
}

return null;
}

private static string GetContentPath(string requestedPath, string contentPath)
{
contentPath =
Expand Down Expand Up @@ -152,11 +165,29 @@ private static string GetContentPath(string requestedPath, string contentPath)
transformedRequestPath =
GetEncodedPath(transformedRequestPath);
var relativeFileName =
Path.Combine(applicationRootPath, transformedRequestPath);
var fileName =
Path.GetFullPath(Path.Combine(applicationRootPath, transformedRequestPath));
GetSafeFullPath(relativeFileName);
if (fileName == null)
{
context.Trace.TraceLog.WriteLog(x => x.AppendLine(string.Concat("[StaticContentConventionBuilder] The request '", relativeFileName, "' contains an invalid path character")));
return ctx => null;
}
var relatveContentRootPath =
Path.Combine(applicationRootPath, GetEncodedPath(contentPath));
var contentRootPath =
Path.GetFullPath(Path.Combine(applicationRootPath, GetEncodedPath(contentPath)));
GetSafeFullPath(relatveContentRootPath);
if (contentRootPath == null)
{
context.Trace.TraceLog.WriteLog(x => x.AppendLine(string.Concat("[StaticContentConventionBuilder] The request '", fileName, "' is trying to access a path inside the content folder, which contains an invalid path character '", relatveContentRootPath, "'")));
return ctx => null;
}
if (!IsWithinContentFolder(contentRootPath, fileName))
{
Expand Down
4 changes: 2 additions & 2 deletions src/Nancy/Extensions/MemoryStreamExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static class MemoryStreamExtensions
/// <returns>Buffer segment as bytes</returns>
public static ArraySegment<byte> GetBufferSegment(this MemoryStream stream)
{
#if NETSTANDARD1_6
#if NETSTANDARD2_0
ArraySegment<byte> buffer;
if (stream.TryGetBuffer(out buffer))
{
Expand All @@ -29,7 +29,7 @@ public static ArraySegment<byte> GetBufferSegment(this MemoryStream stream)

private static byte[] GetBytes(this MemoryStream stream)
{
#if NETSTANDARD1_6
#if NETSTANDARD2_0
return stream.ToArray(); // This is all we have if TryGetBuffer fails in GetBufferSegment
#else
return stream.GetBuffer();
Expand Down
4 changes: 2 additions & 2 deletions src/Nancy/IO/RequestStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ private void ShiftStreamToFileStreamIfNecessary()
// in NancyWcfGenericService - webRequest.UriTemplateMatch
var old = this.stream;
this.MoveStreamContentsToFileStream();
#if NETSTANDARD1_6
#if NETSTANDARD2_0
old.Dispose();
#else
old.Close();
Expand Down Expand Up @@ -483,7 +483,7 @@ private void MoveStreamContentsToFileStream()

if (this.stream.CanSeek && this.stream.Length == 0)
{
#if NETSTANDARD1_6
#if NETSTANDARD2_0
this.stream.Dispose();
#else
this.stream.Close();
Expand Down
6 changes: 3 additions & 3 deletions src/Nancy/Nancy.csproj
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Description>Nancy is a lightweight web framework for the .Net platform, inspired by Sinatra. Nancy aim at delivering a low ceremony approach to building light, fast web applications.</Description>
<TargetFrameworks>netstandard1.6;net452</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net452</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<EmbeddedResource Include="ErrorHandling\Resources\**\*.*;Diagnostics\Resources\**\*.*;Diagnostics\Views\**\*.*" Exclude="bin\**;obj\**;**\*.xproj;packages\**;@(EmbeddedResource)" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.6' ">
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="1.1.1" />
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="2.0.4" />
<PackageReference Include="Microsoft.Extensions.PlatformAbstractions" Version="1.1.0" />
<PackageReference Include="System.Collections.Specialized" Version="4.3.0" />
<PackageReference Include="System.ComponentModel.TypeConverter" Version="4.3.0" />
Expand Down
6 changes: 3 additions & 3 deletions src/Nancy/TinyIoc/TinyIoC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
#endif


#if NETSTANDARD1_6
#if NETSTANDARD2_0
#undef SERIALIZABLE
#undef APPDOMAIN_GETASSEMBLIES
#endif
Expand Down Expand Up @@ -4075,7 +4075,7 @@ public void Dispose()
#endregion
}

#if NETSTANDARD1_6
#if NETSTANDARD2_0
static class ReverseTypeExtender
{
public static bool IsClass(this Type type)
Expand Down Expand Up @@ -4130,7 +4130,7 @@ public static Assembly Assembly(this Type type)
}
#endif
// reverse shim for WinRT SR changes...
#if (!NETFX_CORE && !NETSTANDARD1_6)
#if (!NETFX_CORE && !NETSTANDARD2_0)
static class ReverseTypeExtender
{
public static bool IsClass(this Type type)
Expand Down
17 changes: 10 additions & 7 deletions test/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
<Platforms>AnyCPU</Platforms>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.1' ">
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">
<DefineConstants>$(DefineConstants);CORE</DefineConstants>
<RuntimeFrameworkVersion>2.0.5</RuntimeFrameworkVersion>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'MonoRelease' ">
Expand Down Expand Up @@ -35,21 +36,23 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="FakeItEasy" Version="4.0.0" />
<PackageReference Include="FakeItEasy.Analyzer.CSharp" Version="4.0.0" />
<PackageReference Include="FakeItEasy" Version="4.3.0" />
<PackageReference Include="FakeItEasy.Analyzer.CSharp" Version="4.3.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
<PackageReference Include="xunit" Version="2.3.0-beta2-build3683" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.0-beta2-build1317" />
<PackageReference Include="xunit" Version="2.4.0-beta.1.build3958" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0-beta.1.build3958" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Runtime" />
<Reference Include="System.Dynamic.Runtime" />
<Reference Include="System.Threading.Tasks" />
<Reference Include="System.Runtime" />
<Reference Include="System.Core" />
<Reference Include="System" />
</ItemGroup>

<ItemGroup>
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.0-beta2-build3683" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.4.0-beta.1.build3958" />
</ItemGroup>
</Project>
Loading

0 comments on commit a082f04

Please sign in to comment.