Skip to content

Commit e27da25

Browse files
authored
💸 Moving to .NET Standard 1.4! (#28)
1 parent d0acc16 commit e27da25

13 files changed

+101
-326
lines changed

HttpClient.Helpers.sln

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 14
4-
VisualStudioVersion = 14.0.25420.1
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.26403.3
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HttpClient.Helpers", "src\HttpClient.Helpers\HttpClient.Helpers.csproj", "{CD2C1552-4AF1-4DC2-B0E6-90CE48D38F27}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HttpClient.Helpers", "src\HttpClient.Helpers\HttpClient.Helpers.csproj", "{E3CE6793-DBBF-4E27-AC2B-D680C4D90300}"
77
EndProject
8-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HttpClient.Helpers.Tests", "tests\HttpClient.Helpers.Tests\HttpClient.Helpers.Tests.csproj", "{B3672F4D-77A9-4E91-83FC-E017E38A0762}"
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HttpClient.Helpers.Tests", "tests\HttpClient.Helpers.Tests\HttpClient.Helpers.Tests.csproj", "{5FAB6B8D-A203-41A8-BDC2-FA4C95DC7E4A}"
99
EndProject
1010
Global
1111
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1212
Debug|Any CPU = Debug|Any CPU
1313
Release|Any CPU = Release|Any CPU
1414
EndGlobalSection
1515
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16-
{CD2C1552-4AF1-4DC2-B0E6-90CE48D38F27}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17-
{CD2C1552-4AF1-4DC2-B0E6-90CE48D38F27}.Debug|Any CPU.Build.0 = Debug|Any CPU
18-
{CD2C1552-4AF1-4DC2-B0E6-90CE48D38F27}.Release|Any CPU.ActiveCfg = Release|Any CPU
19-
{CD2C1552-4AF1-4DC2-B0E6-90CE48D38F27}.Release|Any CPU.Build.0 = Release|Any CPU
20-
{B3672F4D-77A9-4E91-83FC-E017E38A0762}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21-
{B3672F4D-77A9-4E91-83FC-E017E38A0762}.Debug|Any CPU.Build.0 = Debug|Any CPU
22-
{B3672F4D-77A9-4E91-83FC-E017E38A0762}.Release|Any CPU.ActiveCfg = Release|Any CPU
23-
{B3672F4D-77A9-4E91-83FC-E017E38A0762}.Release|Any CPU.Build.0 = Release|Any CPU
16+
{E3CE6793-DBBF-4E27-AC2B-D680C4D90300}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17+
{E3CE6793-DBBF-4E27-AC2B-D680C4D90300}.Debug|Any CPU.Build.0 = Debug|Any CPU
18+
{E3CE6793-DBBF-4E27-AC2B-D680C4D90300}.Release|Any CPU.ActiveCfg = Release|Any CPU
19+
{E3CE6793-DBBF-4E27-AC2B-D680C4D90300}.Release|Any CPU.Build.0 = Release|Any CPU
20+
{5FAB6B8D-A203-41A8-BDC2-FA4C95DC7E4A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21+
{5FAB6B8D-A203-41A8-BDC2-FA4C95DC7E4A}.Debug|Any CPU.Build.0 = Debug|Any CPU
22+
{5FAB6B8D-A203-41A8-BDC2-FA4C95DC7E4A}.Release|Any CPU.ActiveCfg = Release|Any CPU
23+
{5FAB6B8D-A203-41A8-BDC2-FA4C95DC7E4A}.Release|Any CPU.Build.0 = Release|Any CPU
2424
EndGlobalSection
2525
GlobalSection(SolutionProperties) = preSolution
2626
HideSolutionNode = FALSE

appveyor.yml

+18-17
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@
88

99
version: '{build}.0.0-dev'
1010
configuration: Release
11-
os: Visual Studio 2015
11+
os: Visual Studio 2017
1212
pull_requests:
1313
do_not_increment_build_number: true
14+
environment:
15+
project_name: HttpClient.Helpers
16+
library_project_file: 'src\%project_name%\%project_name%.csproj'
17+
tests_project_file: 'tests\%project_name%.Tests\%project_name%.Tests.csproj'
1418

1519
# Override the 'version' if this is a GH-tag-commit -or- this is a custom branch (i.e not 'master').
1620
init:
@@ -23,22 +27,19 @@ init:
2327
iex ((new-object net.webclient).DownloadString('https://gist.githubusercontent.com/PureKrome/0f79e25693d574807939/raw/f5b40256fc2ca77d49f1c7773d28406152544c1e/appveyor-build-info.ps'))
2428
2529
before_build:
26-
- nuget restore
27-
28-
assembly_info:
29-
patch: true
30-
file: AssemblyInfo.*
31-
assembly_version: $(appveyor_build_version)
32-
assembly_file_version: $(appveyor_build_version)
33-
assembly_informational_version: $(appveyor_build_version)
34-
35-
build:
36-
parallel: true
37-
verbosity: minimal
38-
publish_nuget: true
39-
publish_nuget_symbols: false
40-
include_nuget_references: false
41-
30+
- dotnet --info
31+
- dotnet restore
32+
33+
build_script:
34+
- dotnet build -c %CONFIGURATION% /p:Version=%APPVEYOR_BUILD_VERSION%
35+
36+
test_script:
37+
- dotnet test %tests_project_file% -c %CONFIGURATION% -v normal --no-build
38+
- dotnet pack %library_project_file% /p:Version=%APPVEYOR_BUILD_VERSION% --no-build
39+
40+
artifacts:
41+
- path: '**\*.nupkg'
42+
4243
deploy:
4344
- provider: NuGet
4445
server: https://www.myget.org/F/pk-development/api/v2/package

src/HttpClient.Helpers/FakeMessageHandler.cs

+7-4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Text;
77
using System.Threading;
88
using System.Threading.Tasks;
9+
using System.Reflection;
910

1011
namespace WorldDomination.Net.Http
1112
{
@@ -56,7 +57,7 @@ protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage reques
5657

5758
var tcs = new TaskCompletionSource<HttpResponseMessage>();
5859

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

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

165166
var type = typeof(HttpMessageOptions);
166-
var propertyInfo = type.GetProperty("NumberOfTimesCalled");
167+
var propertyInfo = type.GetTypeInfo()
168+
?.GetDeclaredProperty("NumberOfTimesCalled");
169+
//var propertyInfo = type.GetProperty("NumberOfTimesCalled");
167170
if (propertyInfo == null)
168171
{
169172
return;
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,25 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
43
<PropertyGroup>
5-
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6-
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7-
<ProjectGuid>{CD2C1552-4AF1-4DC2-B0E6-90CE48D38F27}</ProjectGuid>
8-
<OutputType>Library</OutputType>
9-
<AppDesignerFolder>Properties</AppDesignerFolder>
10-
<RootNamespace>WorldDomination.Net.Http</RootNamespace>
11-
<AssemblyName>WorldDomination.HttpClient.Helpers</AssemblyName>
12-
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13-
<FileAlignment>512</FileAlignment>
14-
<NuGetPackageImportStamp>df64348f</NuGetPackageImportStamp>
4+
<TargetFramework>netstandard1.4</TargetFramework>
5+
<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>
6+
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
7+
<Company>World-Domination Technologies Pty. Ltd.</Company>
8+
<Authors>Justin Adler and awesome contributors.</Authors>
9+
<PackageId>WorldDomination.HttpClient.Helpers</PackageId>
10+
<Version>0.0.0</Version>
11+
<Product>HttpClient helpers for System.Net.Http.HttpClient</Product>
12+
<Copyright>2014</Copyright>
13+
<PackageLicenseUrl>https://raw.githubusercontent.com/PureKrome/HttpClient.Helpers/master/LICENSE</PackageLicenseUrl>
14+
<PackageProjectUrl>https://github.com/PureKrome/HttpClient.Helpers</PackageProjectUrl>
15+
<PackageIconUrl>http://i.imgur.com/bR4Yf.jpg</PackageIconUrl>
16+
<RepositoryUrl>https://github.com/PureKrome/HttpClient.Helpers</RepositoryUrl>
17+
<PackageTags>httpclient worlddomination worldomination unicorn magicalunicorn magical-unicorn</PackageTags>
1518
</PropertyGroup>
16-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17-
<DebugSymbols>true</DebugSymbols>
18-
<DebugType>full</DebugType>
19-
<Optimize>false</Optimize>
20-
<OutputPath>bin\Debug\</OutputPath>
21-
<DefineConstants>DEBUG;TRACE</DefineConstants>
22-
<ErrorReport>prompt</ErrorReport>
23-
<WarningLevel>4</WarningLevel>
24-
</PropertyGroup>
25-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26-
<DebugType>pdbonly</DebugType>
27-
<Optimize>true</Optimize>
28-
<OutputPath>bin\Release\</OutputPath>
29-
<DefineConstants>TRACE</DefineConstants>
30-
<ErrorReport>prompt</ErrorReport>
31-
<WarningLevel>4</WarningLevel>
32-
</PropertyGroup>
33-
<ItemGroup>
34-
<Reference Include="System" />
35-
<Reference Include="System.Core" />
36-
<Reference Include="Microsoft.CSharp" />
37-
<Reference Include="System.Net.Http" />
38-
<Reference Include="System.Net.Http.Extensions, Version=2.2.29.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
39-
<SpecificVersion>False</SpecificVersion>
40-
<HintPath>..\..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Extensions.dll</HintPath>
41-
</Reference>
42-
<Reference Include="System.Net.Http.Primitives, Version=4.2.29.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
43-
<SpecificVersion>False</SpecificVersion>
44-
<HintPath>..\..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Primitives.dll</HintPath>
45-
</Reference>
46-
<Reference Include="System.Net.Http.WebRequest" />
47-
</ItemGroup>
48-
<ItemGroup>
49-
<Compile Include="FakeMessageHandler.cs" />
50-
<Compile Include="HttpMessageOptions.cs" />
51-
<Compile Include="Properties\AssemblyInfo.cs" />
52-
</ItemGroup>
19+
5320
<ItemGroup>
54-
<None Include="packages.config" />
21+
<None Remove="HttpClient.Helpers.nuspec" />
22+
<None Remove="packages.config" />
5523
</ItemGroup>
56-
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
57-
<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')" />
58-
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
59-
<PropertyGroup>
60-
<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>
61-
</PropertyGroup>
62-
<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'))" />
63-
</Target>
64-
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
65-
Other similar extension points exist, see Microsoft.Common.targets.
66-
<Target Name="BeforeBuild">
67-
</Target>
68-
<Target Name="AfterBuild">
69-
</Target>
70-
-->
24+
7125
</Project>

src/HttpClient.Helpers/HttpMessageOptions.cs

+5-19
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,14 @@ namespace WorldDomination.Net.Http
88
{
99
public class HttpMessageOptions
1010
{
11-
public const string NoValue = "*";
11+
private const string _anyValue = "*";
1212
private HttpContent _httpContent;
1313
private string _httpContentSerialized;
14-
private string _requestUri = NoValue;
1514

1615
/// <summary>
17-
/// Required: End url we are targetting.
16+
/// The endpoint we are trying to call/hit/test.
1817
/// </summary>
19-
public string RequestUri
20-
{
21-
get { return _requestUri; }
22-
set
23-
{
24-
if (string.IsNullOrWhiteSpace(value))
25-
{
26-
throw new ArgumentNullException(nameof(value),
27-
"RequestUri cannot be null/empty/whitespace. Please choose a valid RequestUri.");
28-
}
29-
30-
_requestUri = value;
31-
}
32-
}
18+
public Uri RequestUri { get; set; }
3319

3420
/// <summary>
3521
/// Optional: If not provided, then assumed to be *any* method.
@@ -51,7 +37,7 @@ public HttpContent HttpContent
5137
{
5238
_httpContent = value;
5339
_httpContentSerialized = _httpContent == null
54-
? NoValue
40+
? null
5541
: Task.Run(_httpContent.ReadAsStringAsync).Result;
5642
}
5743
}
@@ -68,7 +54,7 @@ public HttpContent HttpContent
6854

6955
public override string ToString()
7056
{
71-
var httpMethodText = HttpMethod?.ToString() ?? NoValue;
57+
var httpMethodText = HttpMethod?.ToString() ?? _anyValue;
7258

7359
var headers = Headers != null &&
7460
Headers.Any()

src/HttpClient.Helpers/Properties/AssemblyInfo.cs

-36
This file was deleted.

src/HttpClient.Helpers/packages.config

-6
This file was deleted.

0 commit comments

Comments
 (0)