Skip to content

Commit

Permalink
💸 Moving to .NET Standard 1.4! (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
PureKrome authored May 27, 2017
1 parent d0acc16 commit e27da25
Show file tree
Hide file tree
Showing 13 changed files with 101 additions and 326 deletions.
24 changes: 12 additions & 12 deletions HttpClient.Helpers.sln
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
# Visual Studio 15
VisualStudioVersion = 15.0.26403.3
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HttpClient.Helpers", "src\HttpClient.Helpers\HttpClient.Helpers.csproj", "{CD2C1552-4AF1-4DC2-B0E6-90CE48D38F27}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HttpClient.Helpers", "src\HttpClient.Helpers\HttpClient.Helpers.csproj", "{E3CE6793-DBBF-4E27-AC2B-D680C4D90300}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HttpClient.Helpers.Tests", "tests\HttpClient.Helpers.Tests\HttpClient.Helpers.Tests.csproj", "{B3672F4D-77A9-4E91-83FC-E017E38A0762}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HttpClient.Helpers.Tests", "tests\HttpClient.Helpers.Tests\HttpClient.Helpers.Tests.csproj", "{5FAB6B8D-A203-41A8-BDC2-FA4C95DC7E4A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CD2C1552-4AF1-4DC2-B0E6-90CE48D38F27}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CD2C1552-4AF1-4DC2-B0E6-90CE48D38F27}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CD2C1552-4AF1-4DC2-B0E6-90CE48D38F27}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CD2C1552-4AF1-4DC2-B0E6-90CE48D38F27}.Release|Any CPU.Build.0 = Release|Any CPU
{B3672F4D-77A9-4E91-83FC-E017E38A0762}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B3672F4D-77A9-4E91-83FC-E017E38A0762}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B3672F4D-77A9-4E91-83FC-E017E38A0762}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B3672F4D-77A9-4E91-83FC-E017E38A0762}.Release|Any CPU.Build.0 = Release|Any CPU
{E3CE6793-DBBF-4E27-AC2B-D680C4D90300}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E3CE6793-DBBF-4E27-AC2B-D680C4D90300}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E3CE6793-DBBF-4E27-AC2B-D680C4D90300}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E3CE6793-DBBF-4E27-AC2B-D680C4D90300}.Release|Any CPU.Build.0 = Release|Any CPU
{5FAB6B8D-A203-41A8-BDC2-FA4C95DC7E4A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5FAB6B8D-A203-41A8-BDC2-FA4C95DC7E4A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5FAB6B8D-A203-41A8-BDC2-FA4C95DC7E4A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5FAB6B8D-A203-41A8-BDC2-FA4C95DC7E4A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
35 changes: 18 additions & 17 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@

version: '{build}.0.0-dev'
configuration: Release
os: Visual Studio 2015
os: Visual Studio 2017
pull_requests:
do_not_increment_build_number: true
environment:
project_name: HttpClient.Helpers
library_project_file: 'src\%project_name%\%project_name%.csproj'
tests_project_file: 'tests\%project_name%.Tests\%project_name%.Tests.csproj'

# Override the 'version' if this is a GH-tag-commit -or- this is a custom branch (i.e not 'master').
init:
Expand All @@ -23,22 +27,19 @@ init:
iex ((new-object net.webclient).DownloadString('https://gist.githubusercontent.com/PureKrome/0f79e25693d574807939/raw/f5b40256fc2ca77d49f1c7773d28406152544c1e/appveyor-build-info.ps'))
before_build:
- nuget restore

assembly_info:
patch: true
file: AssemblyInfo.*
assembly_version: $(appveyor_build_version)
assembly_file_version: $(appveyor_build_version)
assembly_informational_version: $(appveyor_build_version)

build:
parallel: true
verbosity: minimal
publish_nuget: true
publish_nuget_symbols: false
include_nuget_references: false

- dotnet --info
- dotnet restore

build_script:
- dotnet build -c %CONFIGURATION% /p:Version=%APPVEYOR_BUILD_VERSION%

test_script:
- dotnet test %tests_project_file% -c %CONFIGURATION% -v normal --no-build
- dotnet pack %library_project_file% /p:Version=%APPVEYOR_BUILD_VERSION% --no-build

artifacts:
- path: '**\*.nupkg'

deploy:
- provider: NuGet
server: https://www.myget.org/F/pk-development/api/v2/package
Expand Down
11 changes: 7 additions & 4 deletions src/HttpClient.Helpers/FakeMessageHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Reflection;

namespace WorldDomination.Net.Http
{
Expand Down Expand Up @@ -56,7 +57,7 @@ protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage reques

var tcs = new TaskCompletionSource<HttpResponseMessage>();

var requestUri = request.RequestUri.AbsoluteUri;
var requestUri = new Uri(request.RequestUri.AbsoluteUri);
var option = new HttpMessageOptions
{
RequestUri = requestUri,
Expand Down Expand Up @@ -141,8 +142,8 @@ private HttpMessageOptions GetExpectedOption(HttpMessageOptions option)
// NOTE: We only compare the *setup* HttpMessageOptions properties if they were provided.
// So if there was no HEADERS provided ... but the real 'option' has some, we still ignore
// and don't compare.
return _lotsOfOptions.Values.SingleOrDefault(x => (x.RequestUri == HttpMessageOptions.NoValue || // Don't care about the Request Uri.
x.RequestUri.Equals(option.RequestUri, StringComparison.OrdinalIgnoreCase)) &&
return _lotsOfOptions.Values.SingleOrDefault(x => (x.RequestUri == null || // Don't care about the Request Uri.
x.RequestUri.AbsoluteUri.Equals(option.RequestUri.AbsoluteUri, StringComparison.OrdinalIgnoreCase)) &&

(x.HttpMethod == null || // Don't care about the HttpMethod.
x.HttpMethod == option.HttpMethod) &&
Expand All @@ -163,7 +164,9 @@ private static void IncrementCalls(HttpMessageOptions options)
}

var type = typeof(HttpMessageOptions);
var propertyInfo = type.GetProperty("NumberOfTimesCalled");
var propertyInfo = type.GetTypeInfo()
?.GetDeclaredProperty("NumberOfTimesCalled");
//var propertyInfo = type.GetProperty("NumberOfTimesCalled");
if (propertyInfo == null)
{
return;
Expand Down
86 changes: 20 additions & 66 deletions src/HttpClient.Helpers/HttpClient.Helpers.csproj
Original file line number Diff line number Diff line change
@@ -1,71 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{CD2C1552-4AF1-4DC2-B0E6-90CE48D38F27}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>WorldDomination.Net.Http</RootNamespace>
<AssemblyName>WorldDomination.HttpClient.Helpers</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<NuGetPackageImportStamp>df64348f</NuGetPackageImportStamp>
<TargetFramework>netstandard1.4</TargetFramework>
<Description>Some simple System.Net.Http.HttpClient helpers to help with your unit tests or when you don't really want to call the endpoint.</Description>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
<Company>World-Domination Technologies Pty. Ltd.</Company>
<Authors>Justin Adler and awesome contributors.</Authors>
<PackageId>WorldDomination.HttpClient.Helpers</PackageId>
<Version>0.0.0</Version>
<Product>HttpClient helpers for System.Net.Http.HttpClient</Product>
<Copyright>2014</Copyright>
<PackageLicenseUrl>https://raw.githubusercontent.com/PureKrome/HttpClient.Helpers/master/LICENSE</PackageLicenseUrl>
<PackageProjectUrl>https://github.com/PureKrome/HttpClient.Helpers</PackageProjectUrl>
<PackageIconUrl>http://i.imgur.com/bR4Yf.jpg</PackageIconUrl>
<RepositoryUrl>https://github.com/PureKrome/HttpClient.Helpers</RepositoryUrl>
<PackageTags>httpclient worlddomination worldomination unicorn magicalunicorn magical-unicorn</PackageTags>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Net.Http.Extensions, Version=2.2.29.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.Primitives, Version=4.2.29.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Primitives.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.WebRequest" />
</ItemGroup>
<ItemGroup>
<Compile Include="FakeMessageHandler.cs" />
<Compile Include="HttpMessageOptions.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>

<ItemGroup>
<None Include="packages.config" />
<None Remove="HttpClient.Helpers.nuspec" />
<None Remove="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets" Condition="Exists('..\..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->

</Project>
24 changes: 5 additions & 19 deletions src/HttpClient.Helpers/HttpMessageOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,14 @@ namespace WorldDomination.Net.Http
{
public class HttpMessageOptions
{
public const string NoValue = "*";
private const string _anyValue = "*";
private HttpContent _httpContent;
private string _httpContentSerialized;
private string _requestUri = NoValue;

/// <summary>
/// Required: End url we are targetting.
/// The endpoint we are trying to call/hit/test.
/// </summary>
public string RequestUri
{
get { return _requestUri; }
set
{
if (string.IsNullOrWhiteSpace(value))
{
throw new ArgumentNullException(nameof(value),
"RequestUri cannot be null/empty/whitespace. Please choose a valid RequestUri.");
}

_requestUri = value;
}
}
public Uri RequestUri { get; set; }

/// <summary>
/// Optional: If not provided, then assumed to be *any* method.
Expand All @@ -51,7 +37,7 @@ public HttpContent HttpContent
{
_httpContent = value;
_httpContentSerialized = _httpContent == null
? NoValue
? null
: Task.Run(_httpContent.ReadAsStringAsync).Result;
}
}
Expand All @@ -68,7 +54,7 @@ public HttpContent HttpContent

public override string ToString()
{
var httpMethodText = HttpMethod?.ToString() ?? NoValue;
var httpMethodText = HttpMethod?.ToString() ?? _anyValue;

var headers = Headers != null &&
Headers.Any()
Expand Down
36 changes: 0 additions & 36 deletions src/HttpClient.Helpers/Properties/AssemblyInfo.cs

This file was deleted.

6 changes: 0 additions & 6 deletions src/HttpClient.Helpers/packages.config

This file was deleted.

Loading

0 comments on commit e27da25

Please sign in to comment.