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

Update to Net-standard 2.1 and update test project NuGet packages #3008

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ os:
- osx

sudo: required
dist: trusty
dist: bionic

mono:
- 4.4.2
- 6.8.0

dotnet: 2.1.4
dotnet: 3.1.102

script:
- ./build.sh --verbosity=minimal
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
image: Visual Studio 2017
image: Visual Studio 2019

version: 2.0.0-ci000{build}
configuration: Release
Expand Down
8 changes: 4 additions & 4 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 = "netstandard2.0";
var netCoreTarget = "netcoreapp2.0";
var netStandardTarget = "netstandard2.1";
var netCoreTarget = "netcoreapp3.1";

// Directories
var output = Directory("build");
Expand Down Expand Up @@ -280,13 +280,13 @@ Task("Test")
}

var settings = new ProcessSettings {
Arguments = string.Concat("xunit -configuration ", configuration, " -nobuild"),
Arguments = string.Concat("test --configuration ", configuration, " --no-build"),
WorkingDirectory = project.GetDirectory()
};

if (IsRunningOnUnix())
{
settings.Arguments.Append(string.Concat("-framework ", netCoreTarget));
settings.Arguments.Append(string.Concat("--framework ", netCoreTarget));
}

Information("Executing tests for " + project.GetFilename() + " with arguments: " + settings.Arguments.Render());
Expand Down
6 changes: 3 additions & 3 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/v$DotNetVersion/scripts/obtain/dotnet-install.ps1";
$CakeVersion = "0.37.0"
$DotNetVersion = select-string -Path .\global.json -Pattern '[\d]\.[\d]\.[\d]*' | % {$_.Matches} | % {$_.Value };
$DotNetInstallerUri = "https://dot.net/v1/dotnet-install.ps1";

# Make sure tools folder exists
$PSScriptRoot = $pwd
Expand Down
6 changes: 3 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
# Define directories.
SCRIPT_DIR=$PWD
TOOLS_DIR=$SCRIPT_DIR/tools
CAKE_VERSION=0.24.0
CAKE_VERSION=0.37.0
CAKE_DLL=$TOOLS_DIR/Cake.$CAKE_VERSION/Cake.exe
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
DOTNET_VERSION=$(cat "$SCRIPT_DIR/global.json" | grep -o '[0-9]\.[0-9]\.[0-9]*')
DOTNET_INSTRALL_URI=https://dot.net/v1/dotnet-install.sh

# Make sure the tools folder exist.
if [ ! -d "$TOOLS_DIR" ]; then
Expand Down
3 changes: 2 additions & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"sdk": {
"version": "2.1.4"
"version": "3.1.102",
"rollForward": "minor"
}
}
7 changes: 4 additions & 3 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="AsyncUsageAnalyzers" Version="1.0.0-alpha003">
<PrivateAssets>All</PrivateAssets>
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="16.5.132">
<PrivateAssets>True</PrivateAssets>
</PackageReference>
</ItemGroup>

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

Expand Down
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>netstandard2.0;net452</TargetFrameworks>
<TargetFrameworks>netstandard2.1;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>netstandard2.0;net452</TargetFrameworks>
<TargetFrameworks>netstandard2.1;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>netstandard2.0;net452</TargetFrameworks>
<TargetFrameworks>netstandard2.1;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>netstandard2.0;net452</TargetFrameworks>
<TargetFrameworks>netstandard2.1;netstandard2.0;net452</TargetFrameworks>
</PropertyGroup>
</Project>
4 changes: 2 additions & 2 deletions src/Nancy.Hosting.Self/Nancy.Hosting.Self.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<PropertyGroup>
<Description>Enables hosting Nancy in any application.</Description>
<PackageTags>$(PackageTags);Host</PackageTags>
<TargetFrameworks>netstandard2.0;net452</TargetFrameworks>
<TargetFrameworks>netstandard2.1;netstandard2.0;net452</TargetFrameworks>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' OR '$(TargetFramework)' == 'netstandard2.1'">
<PackageReference Include="System.Security.Principal.Windows">
<Version>4.3.0</Version>
</PackageReference>
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>netstandard2.0;net452</TargetFrameworks>
<TargetFrameworks>netstandard2.1;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>netstandard2.0;net452</TargetFrameworks>
<TargetFrameworks>netstandard2.1;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>Adds Fluent Validation support to Nancy.</Description>
<PackageTags>$(PackageTags);Validation;FluentValidation</PackageTags>
<TargetFrameworks>netstandard2.0;net452</TargetFrameworks>
<TargetFrameworks>netstandard2.1;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>netstandard2.0;net452</TargetFrameworks>
<TargetFrameworks>netstandard2.1;netstandard2.0;net452</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
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 NETSTANDARD2_0
#if NETSTANDARD2_0 || NETSTANDARD2_1
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 NETSTANDARD2_0
#if NETSTANDARD2_0 || NETSTANDARD2_1
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 NETSTANDARD2_0
#if NETSTANDARD2_0 || NETSTANDARD2_1
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 NETSTANDARD2_0
#if NETSTANDARD2_0 || NETSTANDARD2_1
this.stream.Dispose();
#else
this.stream.Close();
Expand Down
15 changes: 13 additions & 2 deletions src/Nancy/Nancy.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<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>netstandard2.0;net452</TargetFrameworks>
<TargetFrameworks>netstandard2.1;netstandard2.0;net452</TargetFrameworks>
</PropertyGroup>

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

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<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" />
Expand All @@ -18,6 +18,17 @@
<PackageReference Include="System.Xml.XmlSerializer" Version="4.3.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.1'">
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="3.1.0" />
<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" />
<PackageReference Include="System.Net.NameResolution" Version="4.3.0" />
<PackageReference Include="System.Security.Claims" Version="4.3.0" />
<PackageReference Include="System.Xml.XmlSerializer" Version="4.3.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
<Reference Include="System.Xml" />
</ItemGroup>
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 NETSTANDARD2_0
#if NETSTANDARD2_0 || NETSTANDARD2_1
#undef SERIALIZABLE
#undef APPDOMAIN_GETASSEMBLIES
#endif
Expand Down Expand Up @@ -4075,7 +4075,7 @@ public void Dispose()
#endregion
}

#if NETSTANDARD2_0
#if NETSTANDARD2_0 || NETSTANDARD2_1
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 && !NETSTANDARD2_0)
#if (!NETFX_CORE && (!NETSTANDARD2_0 && !NETSTANDARD2_1))
static class ReverseTypeExtender
{
public static bool IsClass(this Type type)
Expand Down
19 changes: 10 additions & 9 deletions test/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@
<Platforms>AnyCPU</Platforms>
</PropertyGroup>

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

<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1'">
<DefineConstants>$(DefineConstants);CORE</DefineConstants>
<RuntimeFrameworkVersion>3.1.2</RuntimeFrameworkVersion>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'MonoRelease' ">
<DefineConstants>$(DefineConstants);MONO</DefineConstants>
</PropertyGroup>
Expand All @@ -36,11 +41,11 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="FakeItEasy" Version="4.6.0" />
<PackageReference Include="FakeItEasy.Analyzer.CSharp" Version="4.6.0" />
<PackageReference Include="FakeItEasy" Version="6.0.0" />
<PackageReference Include="FakeItEasy.Analyzer.CSharp" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
<PackageReference Include="xunit" Version="2.4.0-beta.1.build3958" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0-beta.1.build3958" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
Expand All @@ -51,8 +56,4 @@
<Reference Include="System.Core" />
<Reference Include="System" />
</ItemGroup>

<ItemGroup>
<DotNetCliToolReference Include="dotnet-xunit" Version="2.4.0-beta.1.build3958" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp2.0;net452</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;netcoreapp2.0;net452</TargetFrameworks>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp2.0;net452</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;netcoreapp2.0;net452</TargetFrameworks>
</PropertyGroup>
</Project>
3 changes: 1 addition & 2 deletions test/Nancy.Embedded.Tests/Nancy.Embedded.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp2.0;net452</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;netcoreapp2.0;net452</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<EmbeddedResource Include="Resources\**\*.*" Exclude="bin\**;obj\**;**\*.xproj;packages\**;@(EmbeddedResource)" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp2.0;net452</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;netcoreapp2.0;net452</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp2.0;net452</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;netcoreapp2.0;net452</TargetFrameworks>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion test/Nancy.Testing.Tests/Nancy.Testing.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp2.0;net452</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;netcoreapp2.0;net452</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion test/Nancy.Tests.Functional/Nancy.Tests.Functional.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp2.0;net452</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;netcoreapp2.0;net452</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand Down
9 changes: 8 additions & 1 deletion test/Nancy.Tests/Nancy.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp2.0;net452</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;netcoreapp2.0;net452</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
Expand All @@ -16,6 +16,13 @@
<PackageReference Include="System.Xml.XmlSerializer" Version="4.3.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.4.0" />
<PackageReference Include="System.Data.Common" Version="4.3.0" />
<PackageReference Include="System.Xml.XmlSerializer" Version="4.3.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="1.3.2" />
<PackageReference Include="System.Collections.Immutable" Version="1.2.0" />
Expand Down