27 Commits
1.1.0 ... 1.4.0

Author SHA1 Message Date
Tommy Parnell
59887c06c0 fix nuget key 2017-07-05 17:46:03 -04:00
Tommy Parnell
1a82f9db70 Merge pull request #13 from TerribleDev/newproj
Newproj
2017-07-05 17:42:13 -04:00
Tommy Parnell
8b66bdcd92 remove code coverage for now 2017-07-05 17:39:27 -04:00
Tommy Parnell
4ce00cf6bb oldstyle 2017-07-05 17:37:03 -04:00
Tommy Parnell
edfb21960a one more try 2017-07-05 17:33:55 -04:00
Tommy Parnell
4db92f4965 try a seperate build for coverage 2017-07-05 17:31:26 -04:00
Tommy Parnell
65b437f5f3 target multi frame 2017-07-05 17:27:09 -04:00
Tommy Parnell
a75d4fab2a try again 2017-07-05 17:23:38 -04:00
Tommy Parnell
63c25a8c6e add test adapter back 2017-07-05 17:09:51 -04:00
Tommy Parnell
87e9cb4b85 fix xunit 2017-07-05 17:05:52 -04:00
Tommy Parnell
fa1e78cb24 full pdb files 2017-07-05 17:02:49 -04:00
Tommy Parnell
ad7ff272a6 fix script 2017-07-05 16:53:27 -04:00
Tommy Parnell
58f03ea1af build in release 2017-07-05 16:52:26 -04:00
Tommy Parnell
00f8f60971 build with full for coveralls 2017-07-05 16:51:15 -04:00
Tommy Parnell
84742e8f47 build with full for coveralls 2017-07-05 16:51:00 -04:00
Tommy Parnell
bb75e3006e fix coverage script 2017-07-05 16:40:56 -04:00
Tommy Parnell
68956cded5 dont download core 2017-07-05 16:39:51 -04:00
Tommy Parnell
ec67f8ad1d fix ref 2017-07-05 16:38:58 -04:00
Tommy Parnell
2011b935d9 use new proj 2017-07-05 16:37:42 -04:00
Peter Dolkens
526f7b04c8 Fix expected values 2017-07-05 12:00:24 +01:00
Peter Dolkens
9dc6c4a466 Add support for WithoutDefaultPort as WithPort doesn't allow "-1" to be sent to hide DefaultPorts 2017-07-05 11:57:23 +01:00
khyteang-lim
9b1d037a88 Added ToEscapeString() and ToEscapeDataString() (#11)
* Added ToEscapeString() and ToEscapeDataString(), added desciption in readme, and added unit tests

* added changes from PR feedback
2017-01-30 17:42:11 -05:00
Tommy Parnell
be92d91ef6 readd 461 2016-12-13 13:47:17 -05:00
Tommy Parnell
a1527c058c add path and query 2016-12-13 13:44:06 -05:00
Tommy Parnell
908d0e2433 target 45 2016-12-13 10:57:40 -05:00
Tommy Parnell
e9f3e5ed8b target 40 2016-12-06 07:48:41 -05:00
Tommy Parnell
8b053f0f77 minor doc comment 2016-11-12 16:58:01 -05:00
20 changed files with 172 additions and 212 deletions

23
.vscode/launch.json vendored
View File

@@ -1,23 +0,0 @@
{
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceRoot}/bin/Debug/<target-framework>/<project-name.dll>",
"args": [],
"cwd": "${workspaceRoot}",
"externalConsole": false,
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command.pickProcess}"
}
]
}

16
.vscode/tasks.json vendored
View File

@@ -1,16 +0,0 @@
{
"version": "0.1.0",
"command": "dotnet",
"isShellCommand": true,
"args": [],
"tasks": [
{
"taskName": "build",
"args": [
""
],
"isBuildCommand": true,
"problemMatcher": "$msCompile"
}
]
}

View File

@@ -3,9 +3,9 @@ if($env:APPVEYOR_REPO_TAG -eq "true")
"do not publish coverall data on tag builds"
return
}
nuget install OpenCover -Version 4.6.519 -OutputDirectory tools
nuget install coveralls.net -Version 0.7.0 -OutputDirectory tools
nuget install OpenCover -Source https://api.nuget.org/v3/index.json -Version 4.6.519 -OutputDirectory tools
nuget install coveralls.net -Source https://api.nuget.org/v3/index.json -Version 0.7.0 -OutputDirectory tools
.\tools\OpenCover.4.6.519\tools\OpenCover.Console.exe -target:"C:\Program Files\dotnet\dotnet.exe" -targetargs:" test "".\src\UriBuilder.Fluent.UnitTests"" -f net461" -register:user -filter:"+[UriBuilder*]* -[*Tests]*" -returntargetcode -output:opencover_results.xml
.\tools\OpenCover.4.6.519\tools\OpenCover.Console.exe -oldStyle -target:"C:\Program Files\dotnet\dotnet.exe" -targetargs:" test "".\src\UriBuilder.Fluent.UnitTests\UriBuilder.Fluent.UnitTests.csproj"" -f net461 --no-build" -register:user -filter:"+[UriBuilder*]* -[*Tests]*" -returntargetcode -output:opencover_results.xml
.\tools\coveralls.net.0.7.0\tools\csmacnz.Coveralls.exe --opencover -i .\opencover_results.xml

View File

@@ -1,10 +1,15 @@
## UriBuilder.Fluent
# UriBuilder.Fluent
[![Coverage Status](https://coveralls.io/repos/github/TerribleDev/UriBuilder.Fluent/badge.svg)](https://coveralls.io/github/TerribleDev/UriBuilder.Fluent) [![Build status](https://ci.appveyor.com/api/projects/status/cp704w3bgaerufxm/branch/master?svg=true)](https://ci.appveyor.com/project/tparnell8/uribuilder-fluent/branch/master)
This places extension methods over System.UriBuilder to help deal with query string parameters, and create more of a fluent interface. Unlike other projects, this NetStandardLibrary compliant package builds ontop of trusty UriBuilder, does not use custom Uri generators, or have outside dependencies. Unit tests continue to be a first class citizen!
This lets you do things like
## Getting started
Just install the nuget package `install-package UriBuilder.Fluent` and thats it. The extension methods should be available to you!
## Code Example
This lets you do things like
```csharp
@@ -16,8 +21,6 @@ new UriBuilder()
.UseHttps()
.ToString()
```
result: `https://awesome.com/seg?awesome=yodawg&fun=cool,yay`
@@ -35,16 +38,44 @@ result: `https://awesome.com/yo?id=5`
you can even pass a dictionary of parameters
```csharp
var dictionary = new Dictionary<string, string>()
{
var dictionary = new Dictionary<string, string>()
{
["yo"] = "dawg"
};
new UriBuilder("http://awesome.com")
};
new UriBuilder("http://awesome.com")
.WithParameter(dictionary);
http://awesome.com/?yo=dawg
```
result: `http://awesome.com/?yo=dawg`
### ToEscapeString() vs. ToEscapeDataString()
There are two extension methods for performing Uri encoding.
#### ToEscapeString()
Performs encoding only on the Uri query string and returns the Uri as a string.
```csharp
var uri = new UriBuilder("https://awesome.com")
.WithParameter("yo", "dawg<")
.ToEscapeString();
```
## Getting started
result: `http://awesome.com/?yo=dawg%3C`
Just install the nuget package `install-package UriBuilder.Fluent` and thats it. The extension methods should be available to you!
#### ToEscapeDataString()
Performs encoding on the whole Uri and returns the Uri as a string.
```csharp
var uri = new UriBuilder("https://awesome.com")
.WithParameter("yo", "dawg<")
.ToEscapeDataString();
```
result: `http%3A%2F%2Fawesome.com%2F%3Fyo%3Ddawg%3C`

View File

@@ -1,20 +1,19 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
# Visual Studio 15
VisualStudioVersion = 15.0.26430.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{B4EB6F69-0F56-4875-95AD-E4DEB5D18A74}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{AC680F4D-C1B2-4F06-8464-CC987B1F0008}"
ProjectSection(SolutionItems) = preProject
appveyor.yml = appveyor.yml
global.json = global.json
Readme.md = Readme.md
EndProjectSection
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "UriBuilder.Fluent", "src\UriBuilder.Fluent\UriBuilder.Fluent.xproj", "{B8458F59-DEBD-4844-AA29-EE3B4388AA7A}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UriBuilder.Fluent", "src\UriBuilder.Fluent\UriBuilder.Fluent.csproj", "{B8458F59-DEBD-4844-AA29-EE3B4388AA7A}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "UriBuilder.Fluent.UnitTests", "src\UriBuilder.Fluent.UnitTests\UriBuilder.Fluent.UnitTests.xproj", "{F421A9EE-180C-413E-A0CD-665295825646}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UriBuilder.Fluent.UnitTests", "src\UriBuilder.Fluent.UnitTests\UriBuilder.Fluent.UnitTests.csproj", "{F421A9EE-180C-413E-A0CD-665295825646}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

View File

@@ -1,34 +1,28 @@
image: Visual Studio 2017
configuration: Release
version: 1.0.{build}
nuget:
account_feed: true
project_feed: true
artifacts:
- path: 'src\**\*.nupkg'
- path: output\**.nupkg
init:
- git config --global core.autocrlf true
before_build:
- ps: invoke-webrequest https://go.microsoft.com/fwlink/?LinkID=827524 -OutFile core.exe
- ps: .\core.exe /install /quiet /norestart
build_script:
- ps: dotnet restore
- ps: dotnet build -c Release .\src\UriBuilder.Fluent
- ps: dotnet build -c Release .\src\UriBuilder.Fluent.UnitTests
- ps: >-
dotnet restore UriBuilder.Fluent.sln --source https://api.nuget.org/v3/index.json
dotnet build UriBuilder.Fluent.sln --configuration Release
if($env:APPVEYOR_REPO_TAG -eq "true")
{
dotnet pack src\UriBuilder.Fluent\UriBuilder.Fluent.csproj --configuration Release --output ..\..\output /p:Version=$env:APPVEYOR_REPO_TAG_NAME
}
test_script:
- ps: dotnet test -c Release .\src\UriBuilder.Fluent.UnitTests
- ps: .\Coverage.ps1
- ps: .\update-projectjson.ps1
- ps: dotnet restore
- ps: dotnet pack -c Release .\src\UriBuilder.Fluent
- ps: dotnet test -c Release .\src\UriBuilder.Fluent.UnitTests\UriBuilder.Fluent.UnitTests.csproj
deploy:
- provider: NuGet
api_key:
secure: QuVcKEvDkLsmdemVpoGBXiTymN46CzvczrDpTHNf1+tTIjOGufptGDmBD9r5LVtn
secure: bGn7M6dHOJ3QjwYIv7e34tcY/n9cCUZmL1MnM6jRfmnJOOfwlrS+cdRj2n8Wf31n
on:
appveyor_repo_tag: true

View File

@@ -1,6 +0,0 @@
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-preview2-003131"
}
}

View File

@@ -36,6 +36,17 @@ namespace FluentUriBuilder.Tests
Assert.Equal("http://awesome.com/?awesome=yodawg", url.Uri.ToString());
}
[Fact]
public void PathAndQuery()
{
var url = new UriBuilder().WithPathSegment("/awesome/v1/").WithParameter("awesome", "cool").PathAndQuery();
Assert.Equal("/awesome/v1/?awesome=cool", url);
url = new UriBuilder().WithPathSegment("/awesome/v1").WithParameter("awesome", "cool").PathAndQuery();
Assert.Equal("/awesome/v1?awesome=cool", url);
url = new UriBuilder().WithPathSegment("/awesome/v1").PathAndQuery();
Assert.Equal("/awesome/v1", url);
}
[Fact]
public void TestAddParameterArray()
{
@@ -67,6 +78,22 @@ namespace FluentUriBuilder.Tests
Assert.Equal(url.Port, 22);
}
[Fact]
public void WithoutDefaultPort()
{
var url = new UriBuilder("http://awesome.com:80")
.WithoutDefaultPort();
Assert.Equal("http://awesome.com/", url.Uri.ToString());
url = new UriBuilder("http://awesome.com:443")
.WithoutDefaultPort();
Assert.Equal("http://awesome.com:443/", url.Uri.ToString());
url = new UriBuilder("https://awesome.com:443")
.WithoutDefaultPort();
Assert.Equal("https://awesome.com/", url.Uri.ToString());
}
[Fact]
public void WithHttps()
{
@@ -130,5 +157,21 @@ namespace FluentUriBuilder.Tests
.WithParameter(dictionary);
Assert.Equal("http://awesome.com/?yo=dawg&troll=toll&hammer", url.Uri.ToString());
}
[Fact]
public void TestToEscapedString()
{
var url = new UriBuilder("http://awesome.com")
.WithParameter("yo","dawg<");
Assert.Equal("http://awesome.com/?yo=dawg%3C", url.ToEscapeString());
}
[Fact]
public void TestToEscapedDataString()
{
var url = new UriBuilder("http://awesome.com")
.WithParameter("yo","dawg<");
Assert.Equal("http%3A%2F%2Fawesome.com%2F%3Fyo%3Ddawg%3C", url.ToEscapeDataString());
}
}
}

View File

@@ -5,10 +5,7 @@ using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("UriBuilder.Fluent.UnitTests")]
[assembly: AssemblyTrademark("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from

View File

@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp1.1;net461</TargetFrameworks>
<DebugType>full</DebugType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\UriBuilder.Fluent\UriBuilder.Fluent.csproj" />
</ItemGroup>
</Project>

View File

@@ -1,22 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>f421a9ee-180c-413e-a0cd-665295825646</ProjectGuid>
<RootNamespace>UriBuilder.Fluent.UnitTests</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ActiveDebugProfile>Start</ActiveDebugProfile>
</PropertyGroup>
</Project>

View File

@@ -1,22 +0,0 @@
{
"version": "1.0.0-*",
"testRunner": "xunit",
"dependencies": {
"xunit": "2.2.0-beta2-build3300",
"dotnet-test-xunit": "2.2.0-preview2-build1029",
"UriBuilder.Fluent": "1.0.0-*"
},
"frameworks": {
"net461": {},
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
}
}
}
}
}

View File

@@ -5,10 +5,6 @@ using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("UriBuilder.Fluent")]
[assembly: AssemblyTrademark("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from

View File

@@ -22,6 +22,7 @@ namespace System
/// </summary>
/// <param name="bld"></param>
/// <param name="parameterDictionary"></param>
/// <exception cref="ArgumentNullException"></exception>
/// <returns></returns>
public static UriBuilder WithParameter(this UriBuilder bld, IDictionary<string, string> parameterDictionary)
{
@@ -80,6 +81,17 @@ namespace System
return bld;
}
/// <summary>
/// Removes the port number for default ports
/// </summary>
/// <param name="bld"></param>
/// <returns></returns>
public static UriBuilder WithoutDefaultPort(this UriBuilder bld)
{
if (bld.Uri.IsDefaultPort) bld.Port = -1;
return bld;
}
/// <summary>
/// appends a path segment to the path. Can be called multiple times to append multiple segments
/// </summary>
@@ -126,6 +138,8 @@ namespace System
return bld;
}
public static string PathAndQuery(this UriBuilder bld) => (bld.Path + bld.Query);
/// <summary>
/// Use Https?
/// </summary>
@@ -137,5 +151,20 @@ namespace System
bld.Scheme = predicate ? "https" : "http";
return bld;
}
/// <summary>
/// Escape Url query string
/// </summary>
/// <param name="bld"></param>
/// <returns></returns>
public static string ToEscapeString(this UriBuilder bld) => Uri.EscapeUriString(bld.Uri.ToString());
/// <summary>
/// Escape the whole Url string
/// </summary>
/// <param name="bld"></param>
/// <returns></returns>
public static string ToEscapeDataString(this UriBuilder bld) => Uri.EscapeDataString(bld.Uri.ToString());
}
}

View File

@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Authors>Tommy Parnell</Authors>
<TargetFrameworks>netstandard1.1;net40;net45</TargetFrameworks>
<AssemblyName>UriBuilder.Fluent</AssemblyName>
<PackageId>UriBuilder.Fluent</PackageId>
<PackageTags>Url building;Uri;Uri building;fluent;extension</PackageTags>
<PackageProjectUrl>https://github.com/TerribleDev/UriBuilder.Fluent</PackageProjectUrl>
<DebugType>full</DebugType>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net40' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
</Project>

View File

@@ -1,21 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>b8458f59-debd-4844-aa29-ee3b4388aa7a</ProjectGuid>
<RootNamespace>UriBuilder.Fluent</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>

View File

@@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ActiveDebugProfile>Start</ActiveDebugProfile>
</PropertyGroup>
</Project>

View File

@@ -1,28 +0,0 @@
{
"version": "1.0.0-*",
"packOptions": {
"owners": [
"Tommy Parnell"
],
"projectUrl": "https://github.com/TerribleDev/UriBuilder.Fluent",
"summary": "Fluent extensions for UriBuilder",
"tags": [
"Url building",
"Uri",
"Uri building",
"fluent",
"extension"
]
},
"dependencies": {
"NETStandard.Library": "1.6.0"
},
"authors": [
"Tommy Parnell"
],
"frameworks": {
"netstandard1.1": {
"imports": "dnxcore50"
}
}
}

View File

@@ -1,16 +0,0 @@
$projectJsonFileLocation = "src/UriBuilder.Fluent/project.json"
$newVersion = $env:APPVEYOR_REPO_TAG_NAME
if($newVersion -eq $null)
{
$newVersion = "1.0.0-${env:APPVEYOR_BUILD_NUMBER}"
}
if($newVersion -eq $null)
{
return
}
Write-Host "$projectJsonFileLocation will be update with new version '$newVersion'"
$json = (Get-Content $projectJsonFileLocation -Raw) | ConvertFrom-Json
$json.version = $newVersion
$json | ConvertTo-Json -depth 100 | Out-File $projectJsonFileLocation