Skip to content

Commit

Permalink
add tfm net8.0;
Browse files Browse the repository at this point in the history
  • Loading branch information
stratosblue committed Nov 15, 2023
1 parent 6c9e7c1 commit d7c2887
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 62 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/PublishNugetPackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.x'
dotnet-version: '8.0.x'
- name: restore dependencies
run: dotnet restore
- name: build
Expand Down
10 changes: 7 additions & 3 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>

<LangVersion>latest</LangVersion>

Expand All @@ -14,13 +14,17 @@
<PropertyGroup Condition="$(TargetFramework) == 'net7.0'">
<McrDotNetVersion>7.0.*</McrDotNetVersion>
</PropertyGroup>


<PropertyGroup Condition="$(TargetFramework) == 'net8.0'">
<McrDotNetVersion>8.0.*</McrDotNetVersion>
</PropertyGroup>

<!--Package Info-->
<PropertyGroup>
<PackageIdPrefix>Cuture.Http</PackageIdPrefix>
<Authors>Stratos</Authors>

<Version>2.7.2</Version>
<Version>2.8.0</Version>

<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/cuture/Cuture.Http</PackageProjectUrl>
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
- Http相关的常用工具类及拓展方法;
- DynamicJSON(基于`dynamic``json`快速访问);
- 请求构建工具,直接使用原始请求数据(如从Fiddler中复制)复现请求;
- 目标框架为`.Net6.0`;
- 目标框架为`.Net6.0+`;

### Note
- 编码相关问题的处理参见[官方文档](https://docs.microsoft.com/zh-cn/dotnet/api/system.text.codepagesencodingprovider)
Expand Down
10 changes: 1 addition & 9 deletions src/Cuture.Http/DefaultHttpRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,7 @@ public class DefaultHttpRequest : HttpRequestMessage, IHttpRequest
/// <inheritdoc/>
public HttpRequestExecutionOptions ExecutionOptions
{
get
{
if (_options is null)
{
_options = HttpRequestExecutionOptions.Default.Clone();
}

return _options;
}
get => _options ??= HttpRequestExecutionOptions.Default.Clone();
set => _options = value;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Cuture.Http/DynamicJSON/Undefined.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ static bool Result(object? resultValue, out object? result)
}
}

private Exception GetInvalidOperationException() => new InvalidOperationException($"\"{_name}\" is undefined.");
private InvalidOperationException GetInvalidOperationException() => new InvalidOperationException($"\"{_name}\" is undefined.");

#endregion Override

Expand Down
27 changes: 5 additions & 22 deletions src/Cuture.Http/Extensions/HttpResponseMessageExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,7 @@ public static async Task DownloadToStreamAsync(this Task<HttpRequestExecuteState
CancellationToken token,
int bufferSize = HttpRequestGlobalOptions.DefaultDownloadBufferSize)
{
if (requestTask is null)
{
throw new ArgumentNullException(nameof(requestTask));
}
ArgumentNullException.ThrowIfNull(requestTask);

if (bufferSize < 1)
{
Expand Down Expand Up @@ -342,15 +339,8 @@ public static async Task DownloadToStreamWithProgressAsync(this Task<HttpRequest
CancellationToken token,
int bufferSize = HttpRequestGlobalOptions.DefaultDownloadBufferSize)
{
if (requestTask is null)
{
throw new ArgumentNullException(nameof(requestTask));
}

if (progressCallback is null)
{
throw new ArgumentNullException(nameof(progressCallback));
}
ArgumentNullException.ThrowIfNull(requestTask);
ArgumentNullException.ThrowIfNull(progressCallback);

if (bufferSize < 1)
{
Expand Down Expand Up @@ -443,15 +433,8 @@ public static async Task DownloadToStreamWithProgressAsync(this Task<HttpRequest
CancellationToken token,
int bufferSize = HttpRequestGlobalOptions.DefaultDownloadBufferSize)
{
if (requestTask is null)
{
throw new ArgumentNullException(nameof(requestTask));
}

if (progressCallback is null)
{
throw new ArgumentNullException(nameof(progressCallback));
}
ArgumentNullException.ThrowIfNull(requestTask);
ArgumentNullException.ThrowIfNull(progressCallback);

if (bufferSize < 1)
{
Expand Down
15 changes: 2 additions & 13 deletions src/Cuture.Http/ReuseableHttpRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,7 @@ public class ReuseableHttpRequest : IHttpRequest
/// <inheritdoc/>
public HttpRequestExecutionOptions ExecutionOptions
{
get
{
if (_options is null)
{
_options = HttpRequestExecutionOptions.Default.Clone();
}

return _options;
}
get => _options ??= HttpRequestExecutionOptions.Default.Clone();
set => _options = value;
}

Expand Down Expand Up @@ -164,10 +156,7 @@ protected virtual void Dispose(bool disposing)
{
_disposedValue = true;

if (Content is not null)
{
Content.Dispose();
}
Content?.Dispose();
}
}

Expand Down
7 changes: 2 additions & 5 deletions src/Cuture.Http/Util/CookieUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,7 @@ public static string Clean(string? cookieText, bool mergeSameKey = true)
/// <returns></returns>
public static string Merge(string? srcCookie, string? addonCookie, bool mergeSameKey = true)
{
if (srcCookie == null)
{
srcCookie = string.Empty;
}
srcCookie ??= string.Empty;
if (string.IsNullOrWhiteSpace(addonCookie))
{
return srcCookie;
Expand Down Expand Up @@ -199,4 +196,4 @@ private static bool IsIgnoreKey(ReadOnlySpan<char> key)
}

#endregion 方法
}
}
4 changes: 2 additions & 2 deletions tests/Cuture.Http.Test/Cuture.Http.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.*" />
<PackageReference Include="MSTest.TestAdapter" Version="2.*" />
<PackageReference Include="MSTest.TestFramework" Version="2.*" />
<PackageReference Include="MSTest.TestAdapter" Version="3.*" />
<PackageReference Include="MSTest.TestFramework" Version="3.*" />
<PackageReference Include="Titanium.Web.Proxy" Version="3.1.*" />
</ItemGroup>

Expand Down
4 changes: 2 additions & 2 deletions tests/Cuture.Http.Test/DynamicJSON/JSONCreateTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public void ShouldSuccessForClass()
[TestMethod]
public void ShouldSuccessForNull()
{
Assert.AreEqual(null, JSON.create(null));
Assert.AreEqual(null, JSON.create("null"));
Assert.AreEqual<dynamic>(null, JSON.create(null));
Assert.AreEqual<dynamic>(null, JSON.create("null"));
}

[TestMethod]
Expand Down
2 changes: 1 addition & 1 deletion tests/Cuture.Http.Test/DynamicJSON/JSONModifyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void ShouldModifyArraySuccess()

json.MyProperty6 = null;

Assert.AreEqual(null, json.MyProperty6);
Assert.AreEqual<dynamic>(null, json.MyProperty6);

json.MyProperty6 = origin.MyProperty6.ToArray();

Expand Down
4 changes: 2 additions & 2 deletions tests/Cuture.Http.Test/DynamicJSON/JSONParseTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ public class JSONParseTest
[TestMethod]
public void ShouldSuccessForNull()
{
Assert.AreEqual(null, JSON.parse(null));
Assert.AreEqual(null, JSON.parse("null"));
Assert.AreEqual<dynamic>(null, JSON.parse(null));
Assert.AreEqual<dynamic>(null, JSON.parse("null"));
}

[TestMethod]
Expand Down

0 comments on commit d7c2887

Please sign in to comment.