diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 0000000..63a917e --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,44 @@ +name: PR Build +on: + pull_request: + branches: + - master +jobs: + # dotnet test + build-test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Setup .NET Core + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 7.x.x + - name: Build + run: make build + - name: Test + run: make test + pack: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Setup .NET Core + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 7.x.x + - name: Pack + run: VERSION=0.0.1 make pack + - name: Upload Build Artifacts + uses: actions/upload-artifact@v3 + with: + name: pr-build-${{ github.event.pull_request.number }}-${{ github.sha }} + path: ./output/** + check-format: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Setup .NET Core + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 7.x.x + - name: Check Format + run: make check-format \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..f83290b --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,70 @@ +name: Publish +on: + push: + branches: + - master +jobs: + check-format: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Setup .NET Core + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 7.x.x + - name: Check Format + run: make check-format + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Setup .NET Core + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 7.x.x + - name: Build + run: make build + - name: Test + run: make test + - name: Upload Coveralls + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + path-to-lcov: ./src/UriBuilder.Fluent.UnitTests/coverage.info + tag: + needs: [check-format, test] + outputs: + tagVersion: ${{ steps.tagVersion.outputs.new_tag }} + runs-on: ubuntu-latest + environment: main + steps: + - name: Checkout source code + uses: actions/checkout@v3 + - name: Bump version and push tag + uses: anothrNick/github-tag-action@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + WITH_V: false + DEFAULT_BUMP: minor + id: tagVersion + build: + env: + VERSION: ${{ needs.tag.outputs.tagVersion }} + NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} + runs-on: ubuntu-latest + needs: [check-format, test, tag] + steps: + - uses: actions/checkout@v2 + - name: Setup .NET Core + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 7.x.x + - name: Build and Pack + run: make pack + - name: Upload Build Artifacts + uses: actions/upload-artifact@v3 + with: + name: release-build-${{ needs.tag.outputs.tagVersion }} + path: ./output/** + - name: Publish to NuGet + run: make publish \ No newline at end of file diff --git a/.gitignore b/.gitignore index 4e56123..5a1ed6c 100644 --- a/.gitignore +++ b/.gitignore @@ -148,6 +148,7 @@ publish/ # NuGet Packages *.nupkg +*.snupkg # The packages folder can be ignored because of Package Restore **/packages/* # except build/, which is used as an MSBuild target. @@ -242,4 +243,9 @@ ModelManifest.xml .paket/paket.exe # FAKE - F# Make -.fake/ \ No newline at end of file +.fake/ +.idea +coverage.opencover.xml +coverage.json +coverage.info +output \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..a184cb5 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "dotnet.defaultSolution": "UriBuilder.Fluent.sln" +} \ No newline at end of file diff --git a/Coverage.ps1 b/Coverage.ps1 deleted file mode 100644 index be155c2..0000000 --- a/Coverage.ps1 +++ /dev/null @@ -1,11 +0,0 @@ -if($env:APPVEYOR_REPO_TAG -eq "true") -{ - "do not publish coverall data on tag builds" - return -} -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 -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 \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9729215 --- /dev/null +++ b/Makefile @@ -0,0 +1,21 @@ +clean: + dotnet clean && rm -rf ./**/bin ./**/obj && rm -rf output +build: clean restore + dotnet build --no-restore +restore: clean + dotnet restore +test: + dotnet test /p:CollectCoverage=true +release-build: clean restore + dotnet build -c Release --no-restore +pack: release-build + dotnet pack src/UriBuilder.Fluent/UriBuilder.Fluent.csproj --configuration Release --output output +publish: + dotnet nuget push output/*.nupkg --source https://api.nuget.org/v3/index.json --skip-duplicate --api-key $(NUGET_API_KEY) + dotnet nuget push output/*.snupkg --source https://api.nuget.org/v3/index.json --skip-duplicate --api-key $(NUGET_API_KEY) +coveralls-push: + dotnet tool install -g coveralls.net + coverallsnet --opencover -i UriBuilder.Fluent.UnitTests/coverage.opencover.xml --useRelativePaths +check-format: + dotnet format --verify-no-changes +default: clean build \ No newline at end of file diff --git a/UriBuilder.Fluent.sln b/UriBuilder.Fluent.sln index 78c1153..c0111ab 100644 --- a/UriBuilder.Fluent.sln +++ b/UriBuilder.Fluent.sln @@ -1,40 +1,34 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26430.14 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{B4EB6F69-0F56-4875-95AD-E4DEB5D18A74}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{BE84C3E5-BA06-4A89-A786-62423FF4A87F}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{AC680F4D-C1B2-4F06-8464-CC987B1F0008}" - ProjectSection(SolutionItems) = preProject - appveyor.yml = appveyor.yml - Readme.md = Readme.md - EndProjectSection +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UriBuilder.Fluent", "src\UriBuilder.Fluent\UriBuilder.Fluent.csproj", "{81D561B6-AB75-4A65-B770-20EEF16E6AF7}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UriBuilder.Fluent", "src\UriBuilder.Fluent\UriBuilder.Fluent.csproj", "{B8458F59-DEBD-4844-AA29-EE3B4388AA7A}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UriBuilder.Fluent.UnitTests", "src\UriBuilder.Fluent.UnitTests\UriBuilder.Fluent.UnitTests.csproj", "{F421A9EE-180C-413E-A0CD-665295825646}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UriBuilder.Fluent.UnitTests", "src\UriBuilder.Fluent.UnitTests\UriBuilder.Fluent.UnitTests.csproj", "{87BEA737-87E0-4114-986F-6080FA58B187}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B8458F59-DEBD-4844-AA29-EE3B4388AA7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B8458F59-DEBD-4844-AA29-EE3B4388AA7A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B8458F59-DEBD-4844-AA29-EE3B4388AA7A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B8458F59-DEBD-4844-AA29-EE3B4388AA7A}.Release|Any CPU.Build.0 = Release|Any CPU - {F421A9EE-180C-413E-A0CD-665295825646}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F421A9EE-180C-413E-A0CD-665295825646}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F421A9EE-180C-413E-A0CD-665295825646}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F421A9EE-180C-413E-A0CD-665295825646}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {81D561B6-AB75-4A65-B770-20EEF16E6AF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {81D561B6-AB75-4A65-B770-20EEF16E6AF7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {81D561B6-AB75-4A65-B770-20EEF16E6AF7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {81D561B6-AB75-4A65-B770-20EEF16E6AF7}.Release|Any CPU.Build.0 = Release|Any CPU + {87BEA737-87E0-4114-986F-6080FA58B187}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {87BEA737-87E0-4114-986F-6080FA58B187}.Debug|Any CPU.Build.0 = Debug|Any CPU + {87BEA737-87E0-4114-986F-6080FA58B187}.Release|Any CPU.ActiveCfg = Release|Any CPU + {87BEA737-87E0-4114-986F-6080FA58B187}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection GlobalSection(NestedProjects) = preSolution - {B8458F59-DEBD-4844-AA29-EE3B4388AA7A} = {B4EB6F69-0F56-4875-95AD-E4DEB5D18A74} - {F421A9EE-180C-413E-A0CD-665295825646} = {B4EB6F69-0F56-4875-95AD-E4DEB5D18A74} + {81D561B6-AB75-4A65-B770-20EEF16E6AF7} = {BE84C3E5-BA06-4A89-A786-62423FF4A87F} + {87BEA737-87E0-4114-986F-6080FA58B187} = {BE84C3E5-BA06-4A89-A786-62423FF4A87F} EndGlobalSection EndGlobal diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 61ca19d..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,28 +0,0 @@ -image: Visual Studio 2022 -configuration: Release -version: 7.0.{build} -artifacts: -- path: output\**.nupkg - -init: - - git config --global core.autocrlf true - -build_script: -- 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\UriBuilder.Fluent.UnitTests.csproj - -deploy: -- provider: NuGet - api_key: - secure: //tKHlb2yqAtpxnR6p9IAtXwQNaq8UYYyIFSD0QVF3XnEasIxG2gTWdmWuG87fUX - on: - appveyor_repo_tag: true \ No newline at end of file diff --git a/global.json b/global.json new file mode 100644 index 0000000..36e1a9e --- /dev/null +++ b/global.json @@ -0,0 +1,7 @@ +{ + "sdk": { + "version": "7.0.0", + "rollForward": "latestMajor", + "allowPrerelease": false + } +} \ No newline at end of file diff --git a/src/UriBuilder.Fluent.UnitTests/ExtensionTests.cs b/src/UriBuilder.Fluent.UnitTests/ExtensionTests.cs index 8296516..90d9cd1 100644 --- a/src/UriBuilder.Fluent.UnitTests/ExtensionTests.cs +++ b/src/UriBuilder.Fluent.UnitTests/ExtensionTests.cs @@ -35,7 +35,7 @@ namespace FluentUriBuilder.Tests .WithParameter("awesome", "yodawg"); Assert.Equal("http://awesome.com/?awesome=yodawg", url.Uri.ToString()); } - + [Fact] public void PathAndQuery() { @@ -99,7 +99,7 @@ namespace FluentUriBuilder.Tests public void WithPort() { var url = new UriBuilder().WithPort(22); - Assert.Equal(url.Port, 22); + Assert.Equal(22, url.Port); } [Fact] @@ -122,14 +122,14 @@ namespace FluentUriBuilder.Tests public void WithHttps() { var url = new UriBuilder().UseHttps(true); - Assert.Equal(url.Scheme, "https"); + Assert.Equal("https", url.Scheme); } [Fact] public void WithHttp() { var url = new UriBuilder().UseHttps(false); - Assert.Equal(url.Scheme, "http"); + Assert.Equal("http", url.Scheme); } [Fact] @@ -137,7 +137,7 @@ namespace FluentUriBuilder.Tests { //the jesus scheme? var url = new UriBuilder().WithScheme("jesus"); - Assert.Equal(url.Scheme, "jesus"); + Assert.Equal("jesus", url.Scheme); } [Fact] @@ -145,7 +145,7 @@ namespace FluentUriBuilder.Tests { //the jesus scheme? var url = new UriBuilder().WithHost("yodawg.com"); - Assert.Equal(url.Host, "yodawg.com"); + Assert.Equal("yodawg.com", url.Host); } [Fact] @@ -220,15 +220,15 @@ namespace FluentUriBuilder.Tests public void TestToEscapedString() { var url = new UriBuilder("http://awesome.com") - .WithParameter("yo","dawg<"); + .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<"); + .WithParameter("yo", "dawg<"); Assert.Equal("http%3A%2F%2Fawesome.com%2F%3Fyo%3Ddawg%3C", url.ToEscapeDataString()); } } diff --git a/src/UriBuilder.Fluent.UnitTests/Properties/AssemblyInfo.cs b/src/UriBuilder.Fluent.UnitTests/Properties/AssemblyInfo.cs deleted file mode 100644 index b73dd37..0000000 --- a/src/UriBuilder.Fluent.UnitTests/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -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. - - -// 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 -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("f421a9ee-180c-413e-a0cd-665295825646")] diff --git a/src/UriBuilder.Fluent.UnitTests/ThrowsTests.cs b/src/UriBuilder.Fluent.UnitTests/ThrowsTests.cs index 07bec03..5321475 100644 --- a/src/UriBuilder.Fluent.UnitTests/ThrowsTests.cs +++ b/src/UriBuilder.Fluent.UnitTests/ThrowsTests.cs @@ -17,16 +17,21 @@ namespace FluentUriBuilder.Tests Assert.Throws(() => tstObj.WithPathSegment(null)); Assert.Throws(() => tstObj.WithScheme(null)); Assert.Throws(() => tstObj.WithHost(null)); - Assert.Throws(() => tstObj.WithParameter((IEnumerable>) null)); + Assert.Throws(() => tstObj.WithParameter((IEnumerable>)null)); Assert.Throws(() => tstObj.WithFragment(fragmentDictionary: null)); Assert.Throws(() => tstObj.WithPort(-1)); UriBuilder nullPtr = null; - Assert.Throws(()=>nullPtr.WithFragment("yo", "dawg")); - Assert.Throws(()=>nullPtr.WithParameter("yo", "dawg")); - Assert.Throws(()=>nullPtr.WithPathSegment("yo")); - Assert.Throws(()=>nullPtr.WithScheme("yo")); - Assert.Throws(()=>nullPtr.WithFragment("yo")); - Assert.Throws(()=>nullPtr.WithoutDefaultPort()); + Assert.Throws(() => nullPtr.WithFragment("yo", "dawg")); + Assert.Throws(() => nullPtr.WithFragment(new Dictionary())); + Assert.Throws(() => nullPtr.WithParameter("yo", "dawg")); + Assert.Throws(() => nullPtr.WithPathSegment("yo")); + Assert.Throws(() => nullPtr.WithScheme("yo")); + Assert.Throws(() => nullPtr.WithFragment("yo")); + Assert.Throws(() => nullPtr.WithoutDefaultPort()); + Assert.Throws(() => nullPtr.WithoutDefaultPort()); + Assert.Throws(() => nullPtr.WithPort(1)); + Assert.Throws(() => nullPtr.WithHost("yo")); + Assert.Throws(() => nullPtr.UseHttps()); } } } \ No newline at end of file diff --git a/src/UriBuilder.Fluent.UnitTests/UriBuilder.Fluent.UnitTests.csproj b/src/UriBuilder.Fluent.UnitTests/UriBuilder.Fluent.UnitTests.csproj index 5c3ff37..f11ebcf 100644 --- a/src/UriBuilder.Fluent.UnitTests/UriBuilder.Fluent.UnitTests.csproj +++ b/src/UriBuilder.Fluent.UnitTests/UriBuilder.Fluent.UnitTests.csproj @@ -1,13 +1,33 @@ - + + - netstandard2.0;netstandard2.1 + net7.0 + enable + disable + + false + lcov + - - - + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + - \ No newline at end of file + + diff --git a/src/UriBuilder.Fluent.UnitTests/Usings.cs b/src/UriBuilder.Fluent.UnitTests/Usings.cs new file mode 100644 index 0000000..8c927eb --- /dev/null +++ b/src/UriBuilder.Fluent.UnitTests/Usings.cs @@ -0,0 +1 @@ +global using Xunit; \ No newline at end of file diff --git a/src/UriBuilder.Fluent/TerribleDevUriExtensions.cs b/src/UriBuilder.Fluent/TerribleDevUriExtensions.cs index 00dc527..83dabce 100644 --- a/src/UriBuilder.Fluent/TerribleDevUriExtensions.cs +++ b/src/UriBuilder.Fluent/TerribleDevUriExtensions.cs @@ -1,12 +1,9 @@ -using System; -using System.Collections.Generic; -using System.Linq; +using System.Collections.Generic; using System.Text; -using System.Threading.Tasks; namespace System { - public static partial class TerribleDevUriExtensions + public static class TerribleDevUriExtensions { /// /// Appends a query string parameter with a key, and many values. Multiple values will be comma seperated. If only 1 value is passed and its null or value, the key will be added to the QS. @@ -14,10 +11,10 @@ namespace System /// /// /// + /// /// public static UriBuilder WithParameter(this UriBuilder bld, string key, params string[] values) => bld.WithParameter(key, valuesEnum: values); - /// /// Appends query strings from a list of key-value pairs (usually a dictionary). /// @@ -48,18 +45,19 @@ namespace System /// /// /// + /// /// public static UriBuilder WithParameter(this UriBuilder bld, string key, IEnumerable valuesEnum) { - if(bld == null) + if (bld == null) { throw new ArgumentNullException(nameof(bld)); } - if(string.IsNullOrWhiteSpace(key)) + if (string.IsNullOrWhiteSpace(key)) { throw new ArgumentNullException(nameof(key)); } - if(valuesEnum == null) + if (valuesEnum == null) { valuesEnum = new string[0]; } @@ -74,6 +72,7 @@ namespace System /// /// /// + /// /// public static UriBuilder WithFragment(this UriBuilder bld, string key, params string[] values) => bld.WithFragment(key, valuesEnum: values); @@ -86,7 +85,7 @@ namespace System /// public static UriBuilder WithFragment(this UriBuilder bld, IDictionary fragmentDictionary) { - if(bld == null) + if (bld == null) { throw new ArgumentNullException(nameof(bld)); } @@ -94,7 +93,7 @@ namespace System { throw new ArgumentNullException(nameof(fragmentDictionary)); } - foreach(var item in fragmentDictionary) + foreach (var item in fragmentDictionary) { bld.WithFragment(item.Key, item.Value); } @@ -107,18 +106,19 @@ namespace System /// /// /// + /// /// public static UriBuilder WithFragment(this UriBuilder bld, string key, IEnumerable valuesEnum) { - if(bld == null) + if (bld == null) { throw new ArgumentNullException(nameof(bld)); } - if(string.IsNullOrWhiteSpace(key)) + if (string.IsNullOrWhiteSpace(key)) { throw new ArgumentNullException(nameof(key)); } - if(valuesEnum == null) + if (valuesEnum == null) { valuesEnum = new string[0]; } @@ -133,14 +133,15 @@ namespace System /// /// /// Throws if port is less than one + /// /// public static UriBuilder WithPort(this UriBuilder bld, int port) { - if(bld == null) + if (bld == null) { throw new ArgumentNullException(nameof(bld)); } - if(port < 1) + if (port < 1) { throw new ArgumentOutOfRangeException(nameof(port)); } @@ -155,7 +156,7 @@ namespace System /// public static UriBuilder WithoutDefaultPort(this UriBuilder bld) { - if(bld == null) + if (bld == null) { throw new ArgumentNullException(nameof(bld)); } @@ -175,11 +176,11 @@ namespace System /// public static UriBuilder WithPathSegment(this UriBuilder bld, string pathSegment) { - if(bld == null) + if (bld == null) { throw new ArgumentNullException(nameof(bld)); } - if(string.IsNullOrWhiteSpace(pathSegment)) + if (string.IsNullOrWhiteSpace(pathSegment)) { throw new ArgumentNullException(nameof(pathSegment)); } @@ -197,7 +198,7 @@ namespace System /// public static UriBuilder WithScheme(this UriBuilder bld, string scheme) { - if(bld == null) + if (bld == null) { throw new ArgumentNullException(nameof(bld)); } @@ -218,7 +219,7 @@ namespace System /// public static UriBuilder WithHost(this UriBuilder bld, string host) { - if(bld == null) + if (bld == null) { throw new ArgumentNullException(nameof(bld)); } @@ -237,10 +238,11 @@ namespace System /// /// /// default true, if false sets scheme to http + /// /// public static UriBuilder UseHttps(this UriBuilder bld, bool predicate = true) { - if(bld == null) + if (bld == null) { throw new ArgumentNullException(nameof(bld)); } @@ -252,6 +254,7 @@ namespace System /// Escape Url query string /// /// + /// /// public static string ToEscapeString(this UriBuilder bld) => Uri.EscapeUriString(bld.Uri.ToString()); @@ -259,26 +262,28 @@ namespace System /// Escape the whole Url string /// /// + /// /// public static string ToEscapeDataString(this UriBuilder bld) => Uri.EscapeDataString(bld.Uri.ToString()); /// /// Appends x-www-form-urlencoded key and valuesEnum into initialValue. /// + /// private static string AppendKeyValue(this string intitialValue, string key, IEnumerable valuesEnum) { var sb = new StringBuilder($"{intitialValue}{key}"); var validValueHit = false; - foreach(var value in valuesEnum) + foreach (var value in valuesEnum) { var toSValue = value?.ToString(); - if(string.IsNullOrWhiteSpace(toSValue)) continue; + if (string.IsNullOrWhiteSpace(toSValue)) continue; // we can't just have an = sign since its valid to have query string paramters with no value; - if(!validValueHit) toSValue = "=" + value; + if (!validValueHit) toSValue = "=" + value; validValueHit = true; sb.Append($"{toSValue},"); } - return sb.ToString().TrimEnd(','); + return sb.ToString().TrimEnd(','); } } } \ No newline at end of file diff --git a/src/UriBuilder.Fluent/TerribleDevUriExtensions_NetCore.cs b/src/UriBuilder.Fluent/TerribleDevUriExtensions_NetCore.cs deleted file mode 100644 index 04e746b..0000000 --- a/src/UriBuilder.Fluent/TerribleDevUriExtensions_NetCore.cs +++ /dev/null @@ -1,34 +0,0 @@ -#if NETSTANDARD2_1_OR_GREATER - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace System -{ - public static partial class TerribleDevUriExtensions - { - /// - /// Appends query strings from dictionary - /// - /// - /// - /// - /// - public static UriBuilder WithParameter(this UriBuilder bld, IEnumerable<(string, string)> parameterDictionary) - { - if (bld == null) { - throw new ArgumentNullException(nameof(bld)); - } - if (parameterDictionary == null) throw new ArgumentNullException(nameof(parameterDictionary)); - foreach (var item in parameterDictionary) { - bld.WithParameter(item.Item1, item.Item2); - } - return bld; - } - } -} - -#endif \ No newline at end of file diff --git a/src/UriBuilder.Fluent/UriBuilder.Fluent.csproj b/src/UriBuilder.Fluent/UriBuilder.Fluent.csproj index 95cbbde..648a092 100644 --- a/src/UriBuilder.Fluent/UriBuilder.Fluent.csproj +++ b/src/UriBuilder.Fluent/UriBuilder.Fluent.csproj @@ -2,37 +2,29 @@ Tommy Parnell - netstandard2.0;netstandard2.1 UriBuilder.Fluent UriBuilder.Fluent Url building;Uri;Uri building;fluent;extension https://github.com/TerribleDev/UriBuilder.Fluent - 7.0.0.0 - 7.0.0.0 - 7.0.0 UriBulider.Fluent.png + netstandard2.0 + true + true + true + snupkg + + This package adds 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, and has no outside dependencies! + - - - - - - - - This package adds 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, and has no outside dependencies! - - True - True - - +