Merge pull request #441 from tmenier/dev

Flurl 2.8.2
This commit is contained in:
Todd Menier 2019-04-28 12:32:59 -04:00 committed by GitHub
commit 52288ba30d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 121 additions and 29 deletions

58
.editorconfig Normal file
View File

@ -0,0 +1,58 @@
# core settings
# https://editorconfig.org
root = true
[*.cs]
indent_style = tab
indent_size = 4
trim_trailing_whitespace = true
# VS/.NET extensions
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference
# language style
dotnet_style_predefined_type_for_locals_parameters_members = true
dotnet_style_predefined_type_for_member_access = true
dotnet_style_require_accessibility_modifiers = always
dotnet_style_readonly_field = true
dotnet_style_prefer_auto_properties = true
dotnet_style_prefer_conditional_expression_over_assignment = true
dotnet_style_prefer_conditional_expression_over_return = true
dotnet_style_coalesce_expression = true
dotnet_style_null_propagation = true
csharp_style_var_for_built_in_types = true
csharp_style_var_when_type_is_apparent = true
csharp_style_var_elsewhere = true
csharp_style_expression_bodied_methods = true
csharp_style_expression_bodied_properties = true
csharp_style_expression_bodied_indexers = true
csharp_style_expression_bodied_accessors = true
csharp_style_pattern_matching_over_is_with_cast_check = true
csharp_style_pattern_matching_over_as_with_null_check = true
csharp_style_inlined_variable_declaration = true
csharp_prefer_simple_default_expression = true
csharp_style_pattern_local_over_anonymous_function = true
csharp_style_conditional_delegate_call = true
csharp_prefer_braces = false
dotnet_sort_system_directives_first = true
dotnet_separate_import_directive_groups = false
# formatting
csharp_new_line_before_open_brace = types
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
csharp_indent_case_contents = true
csharp_indent_switch_labels = true
csharp_space_after_cast = false
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_method_call_parameter_list_parentheses = false
csharp_space_before_colon_in_inheritance_clause = true
csharp_space_after_colon_in_inheritance_clause = true
csharp_space_around_binary_operators = before_and_after
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
csharp_space_between_method_call_name_and_opening_parenthesis = false
csharp_space_between_method_call_empty_parameter_list_parentheses = false
csharp_preserve_single_line_blocks = true

2
.gitignore vendored
View File

@ -13,3 +13,5 @@ publish
TestResult.xml
*.bak
.idea
lcov.info
coverage.json

View File

@ -3,10 +3,10 @@
@call dotnet restore -v m ../
@if ERRORLEVEL 1 (
echo Error! Restoring dependicies failed.
echo Error! Restoring dependencies failed.
exit /b 1
) else (
echo Restoring dependicies was successful.
echo Restoring dependencies was successful.
)
@set project=..\src\Flurl.Http.CodeGen\Flurl.Http.CodeGen.csproj

View File

@ -1,3 +1,5 @@
@cd ..\test\Flurl.Test\
@call dotnet test -c Release
@cd ..\..\Build\
@call dotnet test -c Release /p:CollectCoverage=true /p:Threshold=75 /p:Exclude="[NUnit3.*]*" ..\test\Flurl.Test\
@if ERRORLEVEL 1 (
echo Error! Tests for Flurl failed.
exit /b 1
)

1
Build/test.coverage.cmd Executable file
View File

@ -0,0 +1 @@
dotnet test -c Release /p:CollectCoverage=true /p:Threshold=75 /p:Exclude="[NUnit3.*]*" /p:CoverletOutputFormat=lcov /p:CoverletOutput=../../lcov ../test/Flurl.Test/

11
Build/test.coverage.sh Executable file
View File

@ -0,0 +1,11 @@
#!/bin/bash
set -euo pipefail
SCRIPT_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo "!!WARNING!! This script generates test coverage file and runs tests for netstandard and netcoreapp targets"
dotnet test -c Release /p:CollectCoverage=true /p:Threshold=75 \
/p:Exclude="[NUnit3.*]*" \
/p:CoverletOutputFormat=lcov /p:CoverletOutput="${SCRIPT_ROOT}/../../lcov" \
"${SCRIPT_ROOT}/../test/Flurl.Test/"

View File

@ -3,4 +3,8 @@ set -euo pipefail
SCRIPT_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
dotnet test -c Release "${SCRIPT_ROOT}/../Test/Flurl.Test/"
echo "!!WARNING!! This script for pipeline test running and checking code coverage for netstandard and netcoreapp targets"
dotnet test -c Release /p:CollectCoverage=true /p:Threshold=75 \
/p:Exclude="[NUnit3.*]*" \
"${SCRIPT_ROOT}/../test/Flurl.Test/"

View File

@ -28,7 +28,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{B6BF9238
ProjectSection(SolutionItems) = preProject
appveyor.yml = appveyor.yml
Build\build.cmd = Build\build.cmd
Build\build.sh = Build\build.sh
Build\Flurl.netstandard.sln = Build\Flurl.netstandard.sln
Build\test.cmd = Build\test.cmd
Build\test.coverage.cmd = Build\test.coverage.cmd
Build\test.coverage.sh = Build\test.coverage.sh
Build\test.sh = Build\test.sh
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PackageTester.NET45", "PackageTesters\PackageTester.NET45\PackageTester.NET45.csproj", "{63FD500A-7449-46E6-92C3-24CE92E817C7}"

View File

@ -42,4 +42,4 @@ Or get just the stand-alone URL builder without the HTTP features:
For updates and announcements, [follow @FlurlHttp on Twitter](https://twitter.com/intent/user?screen_name=FlurlHttp).
For detailed documentation, please visit the [main site](https://flurl.io).
For detailed documentation, please visit the [main site](https://flurl.dev).

View File

@ -6,6 +6,10 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.msbuild" Version="2.5.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
<PackageReference Include="NUnit" Version="3.9.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.9.0" />

View File

@ -38,35 +38,33 @@ namespace Flurl.Test.Http
Assert.IsFalse(fac.Get("http://api2.com/foo").Settings.CookiesEnabled);
}
[Test]
public void ConfigureClient_is_thread_safe() {
[Test]
public async Task ConfigureClient_is_thread_safe() {
var fac = new PerHostFlurlClientFactory();
var sequence = new List<int>();
var task1 = Task.Run(() => fac.ConfigureClient("http://api.com", c => {
sequence.Add(1);
Thread.Sleep(200);
Thread.Sleep(5000);
sequence.Add(3);
}));
Thread.Sleep(50);
await Task.Delay(200);
// modifies same client as task1, should get blocked until task1 is done
var task2 = Task.Run(() => fac.ConfigureClient("http://api.com", c => {
var task2 = Task.Run(() => fac.ConfigureClient("http://api.com", c => {
sequence.Add(4);
}));
Thread.Sleep(50);
await Task.Delay(200);
// modifies different client, should run immediately
var task3 = Task.Run(() => fac.ConfigureClient("http://api2.com", c => {
sequence.Add(2);
}));
// modifies different client, should run immediately
var task3 = Task.Run(() => fac.ConfigureClient("http://api2.com", c => {
sequence.Add(2);
}));
Task.WaitAll(task1, task2, task3);
CollectionAssert.AreEqual(new[] { 1, 2, 3, 4 }, sequence);
await Task.WhenAll(task1, task2, task3);
Assert.AreEqual("1,2,3,4", string.Join(",", sequence));
}
}
}

View File

@ -375,6 +375,14 @@ namespace Flurl.Test
Assert.AreEqual("http://www.mysite.com/a+b?c+d=1+2", url.ToString(true));
}
[Test] // #437
public void interprets_encoded_plus_as_plus() {
var urlStr = "http://google.com/search?q=param_with_%2B";
var url = new Url(urlStr);
var paramValue = url.QueryParams["q"];
Assert.AreEqual("param_with_+", paramValue);
}
[TestCase("http://www.mysite.com/more", true)]
[TestCase("http://www.mysite.com/more?x=1&y=2", true)]
[TestCase("http://www.mysite.com/more?x=1&y=2#frag", true)]

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net45;net46;netstandard1.1;netstandard1.3;netstandard2.0;</TargetFrameworks>
@ -8,11 +8,11 @@
<Version>2.4.1</Version>
<Authors>Todd Menier</Authors>
<Description>A fluent, portable, testable HTTP client library.</Description>
<PackageProjectUrl>https://flurl.io</PackageProjectUrl>
<PackageProjectUrl>https://flurl.dev</PackageProjectUrl>
<PackageIconUrl>https://pbs.twimg.com/profile_images/534024476296376320/IuPGZ_bX_400x400.png</PackageIconUrl>
<PackageLicenseUrl>https://raw.githubusercontent.com/tmenier/Flurl/master/LICENSE</PackageLicenseUrl>
<RepositoryUrl>https://github.com/tmenier/Flurl.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageTags>httpclient rest json http fluent url uri tdd assert async</PackageTags>
<PackageReleaseNotes>https://github.com/tmenier/Flurl/releases</PackageReleaseNotes>
<IncludeProjectPriFile>false</IncludeProjectPriFile>

View File

@ -5,14 +5,14 @@
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netstandard1.0;netstandard1.3;netstandard2.0;</TargetFrameworks>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<PackageId>Flurl</PackageId>
<Version>2.8.1</Version>
<Version>2.8.2</Version>
<Authors>Todd Menier</Authors>
<Description>A fluent, portable URL builder. To make HTTP calls off the fluent chain, check out Flurl.Http.</Description>
<PackageProjectUrl>https://flurl.io</PackageProjectUrl>
<PackageProjectUrl>https://flurl.dev</PackageProjectUrl>
<PackageIconUrl>https://pbs.twimg.com/profile_images/534024476296376320/IuPGZ_bX_400x400.png</PackageIconUrl>
<PackageLicenseUrl>https://raw.githubusercontent.com/tmenier/Flurl/master/LICENSE</PackageLicenseUrl>
<RepositoryUrl>https://github.com/tmenier/Flurl.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageTags>fluent url uri querystring builder</PackageTags>
<PackageReleaseNotes>https://github.com/tmenier/Flurl/releases</PackageReleaseNotes>
<IncludeProjectPriFile>false</IncludeProjectPriFile>

View File

@ -144,8 +144,7 @@ namespace Flurl
if (string.IsNullOrEmpty(s))
return s;
s = Uri.UnescapeDataString(s);
return interpretPlusAsSpace ? s.Replace("+", " ") : s;
return Uri.UnescapeDataString(interpretPlusAsSpace ? s.Replace("+", " ") : s);
}
private const int MAX_URL_LENGTH = 65519;