Skip to content

Commit

Permalink
#544 adding net6.0 target
Browse files Browse the repository at this point in the history
  • Loading branch information
tmenier committed Jun 5, 2022
1 parent 869e9c6 commit d621980
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Test/Flurl.Test/Flurl.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 0 additions & 2 deletions Test/Flurl.Test/UrlBuilder/UrlBuildingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,14 +289,12 @@ public void can_remove_path(string original, string expected) {
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() {
Expand Down
4 changes: 2 additions & 2 deletions src/Flurl.Http/Flurl.Http.csproj
Original file line number Diff line number Diff line change
@@ -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>
Expand Down Expand Up @@ -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>
Expand Down
22 changes: 17 additions & 5 deletions src/Flurl.Http/HttpMessageExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,20 @@ public static void SetHeader(this HttpResponseMessage response, string name, obj
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>
Expand All @@ -46,11 +60,9 @@ internal static void SetFlurlCall(this HttpRequestMessage request, FlurlCall cal
/// <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()) {
Expand Down

0 comments on commit d621980

Please sign in to comment.