Skip to content

Commit 8aa329b

Browse files
committed
This closes tmenier#61
1 parent 235d1f6 commit 8aa329b

16 files changed

+304
-10
lines changed

.gitattributes

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
###############################################################################
2+
# Set default behavior to automatically normalize line endings.
3+
###############################################################################
4+
* text=auto

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@ packages
44
*.suo
55
*.nupkg
66
*.DotSettings.user
7+
*.xproj.user
8+
.vs
9+
*.lock.json
10+
*.log

Build/Flurl.Http.nuspec

+15-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package >
33
<metadata>
44
<id>Flurl.Http</id>
5-
<version>0.7.0</version>
5+
<version>0.8.0</version>
66
<title>Flurl.Http</title>
77
<authors>Todd Menier</authors>
88
<projectUrl>http://tmenier.github.io/Flurl</projectUrl>
@@ -13,6 +13,7 @@
1313
A fluent, portable, testable HTTP client library that extends Flurl's URL builder chain.
1414
</description>
1515
<releaseNotes>
16+
0.8.0 - Support for the NETCore (github #61)
1617
0.7.0 - BREAKING CHANGES: https://github.com/tmenier/Flurl/wiki/Release-Notes
1718
0.6.4 - nuspec fix for Xamarin/non-PCL, AllowHttpStatus overloads with HttpStatusCode enum.
1819
0.6.3 - Updated Flurl dependency to 1.0.9.
@@ -34,24 +35,34 @@
3435
0.2.1 - Added support for getting streams and byte arrays.
3536
0.2.0 - Added .NET 4.5 specific version with fewer dependencies.
3637
0.1.3 - Added support for HEAD requests via HeadAsync (thanks to @benb1n).
37-
</releaseNotes>
38+
</releaseNotes>
3839
<tags>httpclient rest json http fluent portable url uri tdd assert async</tags>
3940
<dependencies>
4041
<group targetFramework="net45">
4142
<dependency id="Newtonsoft.Json" version="6.0.3" />
42-
<dependency id="Flurl" version="1.0.10" />
43+
<dependency id="Flurl" version="1.1.0" />
4344
</group>
4445
<group targetFramework="portable-net45+sl50+win+wpa81+wp80">
4546
<dependency id="Microsoft.Bcl.Async" version="1.0.168" />
4647
<dependency id="Microsoft.Net.Http" version="2.2.22" />
4748
<dependency id="PCLStorage" version="0.9.6" />
4849
<dependency id="Newtonsoft.Json" version="6.0.3" />
49-
<dependency id="Flurl" version="1.0.10" />
50+
<dependency id="Flurl" version="1.1.0" />
51+
</group>
52+
<group targetFramework=".NETPlatform5.4">
53+
<dependency id="Flurl" version="1.1.0" />
54+
<dependency id="Newtonsoft.Json" version="8.0.3" />
55+
<dependency id="System.Dynamic.Runtime" version="4.0.10" />
56+
<dependency id="System.IO.FileSystem" version="4.0.0" />
57+
<dependency id="System.Net.Http" version="4.0.0" />
58+
<dependency id="System.Text.RegularExpressions" version="4.0.10" />
59+
<dependency id="System.Threading" version="4.0.10" />
5060
</group>
5161
</dependencies>
5262
</metadata>
5363
<files>
5464
<file src="..\Flurl.Http.NET45\bin\Release\Flurl.Http.*" target="lib\net45" />
5565
<file src="..\Flurl.Http.PCL\bin\Release\Flurl.Http.*" target="lib\portable-net45+sl50+win+wpa81+wp80" />
66+
<file src="..\artifacts\bin\Flurl.Http.NETCore\Release\dotnet5.4\Flurl.Http.*" target="lib\dotnet5.4" />
5667
</files>
5768
</package>

Build/Flurl.nuspec

+9-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package >
33
<metadata>
44
<id>Flurl</id>
5-
<version>1.0.10</version>
5+
<version>1.1.0</version>
66
<title>Flurl</title>
77
<authors>Todd Menier</authors>
88
<projectUrl>http://tmenier.github.io/Flurl</projectUrl>
@@ -13,6 +13,7 @@
1313
A fluent, portable URL builder. To make HTTP calls off the fluent chain, check out Flurl.Http.
1414
</description>
1515
<releaseNotes>
16+
1.1.0 - Support for the NETCore (github #61)
1617
1.0.10 - More flexible kv parsing (github pr #16)
1718
1.0.9 - Decode + as space, optionally encode space as + (github #41)
1819
1.0.8 - Don't trim trailing slash (github #37)
@@ -29,8 +30,15 @@
2930
0.2.0 - Added PCL support.
3031
</releaseNotes>
3132
<tags>fluent portable url uri querystring builder</tags>
33+
<dependencies>
34+
<group targetFramework=".NETPlatform5.4">
35+
<dependency id="System.Linq" version="4.0.0" />
36+
<dependency id="System.Reflection.TypeExtensions" version="4.0.0" />
37+
</group>
38+
</dependencies>
3239
</metadata>
3340
<files>
3441
<file src="..\Flurl\bin\Release\Flurl.*" target="lib\portable-net40+sl50+win+wpa81+wp80+MonoAndroid10+MonoTouch10" />
42+
<file src="..\artifacts\bin\Flurl.NETCore\Release\dotnet5.4\Flurl.*" target="lib\dotnet5.4" />
3543
</files>
3644
</package>

Build/NuGet.exe

2.03 MB
Binary file not shown.

Build/Publish.cmd

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@echo off
2+
3+
set workDir=%1
4+
set publishSpec=%2
5+
set publishDir=%3
6+
7+
cd %workDir%
8+
if not exist "%publishDir%" mkdir "%publishDir%"
9+
call NuGet.exe pack %publishSpec% -OutputDirectory %publishDir%
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
5+
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
6+
</PropertyGroup>
7+
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
8+
<PropertyGroup Label="Globals">
9+
<ProjectGuid>52c8c00d-9bd2-4642-b103-f0a8c564fe05</ProjectGuid>
10+
<RootNamespace>Flurl.Http.NETCore</RootNamespace>
11+
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
12+
<OutputPath Condition="'$(OutputPath)'=='' ">..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
13+
</PropertyGroup>
14+
<PropertyGroup>
15+
<SchemaVersion>2.0</SchemaVersion>
16+
<TypeScriptCompileBlocked>True</TypeScriptCompileBlocked>
17+
</PropertyGroup>
18+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
19+
<ProduceOutputsOnBuild>True</ProduceOutputsOnBuild>
20+
</PropertyGroup>
21+
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
22+
</Project>

Flurl.Http.NETCore/project.json

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"title": "Flurl.Http.NETCore",
3+
4+
"dependencies": {
5+
"Flurl": "1.1.0",
6+
"Newtonsoft.Json": "8.0.3"
7+
},
8+
9+
"compile": [ "../Flurl.Http.Shared/**/*.cs", "../Flurl.Http.NET45/**/*.cs" ],
10+
"compileExclude": [ "../**/AssemblyInfo.cs" ],
11+
12+
"configurations": {
13+
"Release": {
14+
"compilationOptions": {
15+
"optimize": true
16+
}
17+
}
18+
},
19+
20+
"frameworks": {
21+
"dotnet54": {
22+
"dependencies": {
23+
"System.Dynamic.Runtime": "4.0.10",
24+
"System.IO.FileSystem": "4.0.0",
25+
"System.Net.Http": "4.0.0",
26+
"System.Text.RegularExpressions": "4.0.10",
27+
"System.Threading": "4.0.10"
28+
}
29+
}
30+
}
31+
}

Flurl.Http.PCL/Flurl.Http.PCL.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
102102
<PropertyGroup>
103103
<PostBuildEvent>if $(ConfigurationName) == Release (
104-
"$(SolutionDir)Build\nuget.exe" pack "$(SolutionDir)Build\Flurl.Http.nuspec" -o "$(SolutionDir)Publish" -IncludeReferencedProjects
104+
call $(SolutionDir)Build\publish.cmd $(SolutionDir)Build\ Flurl.Http.nuspec $(SolutionDir)Publish &gt;&gt; $(SolutionDir)Build\publish.log
105105
)</PostBuildEvent>
106106
</PropertyGroup>
107107
<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')" />

Flurl.NETCore/Flurl.NETCore.xproj

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
5+
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
6+
</PropertyGroup>
7+
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
8+
<PropertyGroup Label="Globals">
9+
<ProjectGuid>52ce5e08-8f02-4f75-8b64-8e00e3262a0f</ProjectGuid>
10+
<RootNamespace>Flurl.NETCore</RootNamespace>
11+
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
12+
<OutputPath Condition="'$(OutputPath)'=='' ">..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
13+
</PropertyGroup>
14+
<PropertyGroup>
15+
<SchemaVersion>2.0</SchemaVersion>
16+
<TypeScriptCompileBlocked>True</TypeScriptCompileBlocked>
17+
</PropertyGroup>
18+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
19+
<ProduceOutputsOnBuild>True</ProduceOutputsOnBuild>
20+
</PropertyGroup>
21+
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
22+
</Project>
+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
using System;
2+
using System.Collections;
3+
using System.Collections.Generic;
4+
using System.Globalization;
5+
using System.Linq;
6+
using System.Reflection;
7+
8+
namespace Flurl.Util
9+
{
10+
public static class CommonExtensions
11+
{
12+
/// <summary>
13+
/// Converts an object's public properties to a collection of string-based key-value pairs. If the object happens
14+
/// to be an IDictionary, the IDictionary's keys and values converted to strings and returned.
15+
/// </summary>
16+
/// <param name="obj">The object to parse into key-value pairs</param>
17+
/// <returns></returns>
18+
public static IEnumerable<KeyValuePair<string, object>> ToKeyValuePairs(this object obj)
19+
{
20+
if (obj == null)
21+
throw new ArgumentNullException(nameof(obj));
22+
23+
return
24+
(obj is string) ? QueryParamCollection.Parse((string)obj) :
25+
(obj is IEnumerable) ? CollectionToKV((IEnumerable)obj) :
26+
ObjectToKV(obj);
27+
}
28+
29+
/// <summary>
30+
/// Returns a string that represents the current object, using CultureInfo.InvariantCulture where possible.
31+
/// </summary>
32+
public static string ToInvariantString(this object obj)
33+
{
34+
// inspired by: http://stackoverflow.com/a/19570016/62600
35+
36+
var c = obj as IConvertible;
37+
if (c != null)
38+
return c.ToString(CultureInfo.InvariantCulture);
39+
40+
var f = obj as IFormattable;
41+
return f?.ToString(null, CultureInfo.InvariantCulture) ?? obj.ToString();
42+
}
43+
44+
private static IEnumerable<KeyValuePair<string, object>> ObjectToKV(object obj)
45+
{
46+
return from prop in obj.GetType().GetProperties()
47+
let val = prop.GetValue(obj, null)
48+
select new KeyValuePair<string, object>(prop.Name, val);
49+
}
50+
51+
private static IEnumerable<KeyValuePair<string, object>> CollectionToKV(IEnumerable col)
52+
{
53+
// Accepts KeyValuePairs or any aribitray types that contain a property called "Key" or "Name" and a property called "Value".
54+
foreach (var item in col)
55+
{
56+
if (item == null)
57+
continue;
58+
59+
var type = item.GetType();
60+
var keyProp = type.GetProperty("Key") ?? type.GetProperty("key") ?? type.GetProperty("Name") ?? type.GetProperty("name");
61+
if (keyProp == null)
62+
throw new ArgumentException("Cannot parse " + type.Name + " to key-value pair. Type must contain a property called 'Key' or 'Name'.");
63+
64+
var valProp = type.GetProperty("Value") ?? type.GetProperty("value");
65+
if (valProp == null)
66+
throw new ArgumentException("Cannot parse " + type.Name + " to key-value pair. Type must contain a property called 'Value'.");
67+
68+
var key = keyProp.GetValue(item, null);
69+
if (key == null)
70+
continue;
71+
72+
var val = valProp.GetValue(item, null);
73+
yield return new KeyValuePair<string, object>(key.ToInvariantString(), val);
74+
}
75+
}
76+
}
77+
}

Flurl.NETCore/project.json

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"title": "Flurl.NETCore",
3+
4+
"compile": [ "../Flurl/**/*.cs" ],
5+
"compileExclude": [ "../**/AssemblyInfo.cs", "../Flurl/Util/CommonExtensions.cs" ],
6+
7+
"configurations": {
8+
"Release": {
9+
"compilationOptions": {
10+
"optimize": true
11+
}
12+
}
13+
},
14+
15+
"frameworks": {
16+
"dotnet54": {
17+
"dependencies": {
18+
"System.Linq": "4.0.0",
19+
"System.Reflection.TypeExtensions": "4.0.0"
20+
}
21+
}
22+
}
23+
}

0 commit comments

Comments
 (0)