#544 adding net6.0 target

This commit is contained in:
Todd 2022-06-05 12:02:01 -05:00
parent 869e9c6acd
commit d621980b3c
4 changed files with 20 additions and 10 deletions

View File

@ -19,7 +19,7 @@
<ProjectReference Include="..\..\src\Flurl.Http\Flurl.Http.csproj" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net461' Or '$(TargetFramework)'=='net472' Or '$(TargetFramework)'=='net48'">
<ItemGroup Condition="'$(TargetFramework)'=='net461' Or '$(TargetFramework)'=='net48'">
<Reference Include="System.Net.Http" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>

View File

@ -289,14 +289,12 @@ namespace Flurl.Test.UrlBuilder
Assert.AreEqual(expected, url.ToString());
}
#if !NETCOREAPP1_1
[Test]
public void url_ToString_uses_invariant_culture() {
Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("es-ES");
var url = "http://www.mysite.com".SetQueryParam("x", 1.1);
Assert.AreEqual("http://www.mysite.com?x=1.1", url.ToString());
}
#endif
[Test]
public void can_reset_to_root() {

View File

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net461;net472</TargetFrameworks>
<TargetFrameworks>net6.0;netstandard2.0;net461</TargetFrameworks>
<LangVersion>8.0</LangVersion>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<PackageId>Flurl.Http</PackageId>
@ -48,7 +48,7 @@
<PackageReference Include="System.Text.Json" Version="6.0.4" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net461' Or '$(TargetFramework)'=='net472'">
<ItemGroup Condition="'$(TargetFramework)'=='net461'">
<Reference Include="System.Net.Http" />
<PackageReference Include="System.Text.Json" Version="6.0.4" />
</ItemGroup>

View File

@ -35,6 +35,20 @@ namespace Flurl.Http
new HttpMessage(response).SetHeader(name, value, createContentIfNecessary);
}
#if NET5_0_OR_GREATER // https://github.com/dotnet/docs/blob/main/includes/preprocessor-symbols.md
/// <summary>
/// Associate a FlurlCall object with this request
/// </summary>
internal static void SetFlurlCall(this HttpRequestMessage request, FlurlCall call) {
request?.Options.Set(new HttpRequestOptionsKey<FlurlCall>("FlurlHttpCall"), call);
}
/// <summary>
/// Get the FlurlCall associated with this request, if any.
/// </summary>
internal static FlurlCall GetFlurlCall(this HttpRequestMessage request) =>
request?.Options.TryGetValue(new HttpRequestOptionsKey<FlurlCall>("FlurlHttpCall"), out var call) == true ? call : null;
#else
/// <summary>
/// Associate a FlurlCall object with this request
/// </summary>
@ -46,11 +60,9 @@ namespace Flurl.Http
/// <summary>
/// Get the FlurlCall associated with this request, if any.
/// </summary>
internal static FlurlCall GetFlurlCall(this HttpRequestMessage request) {
if (request?.Properties != null && request.Properties.TryGetValue("FlurlHttpCall", out var obj) && obj is FlurlCall call)
return call;
return null;
}
internal static FlurlCall GetFlurlCall(this HttpRequestMessage request) =>
request?.Properties?.TryGetValue("FlurlHttpCall", out var call) == true ? call as FlurlCall : null;
#endif
private static void SetHeader(this HttpMessage msg, string name, object value, bool createContentIfNecessary) {
switch (name.ToLower()) {