Skip to content

Commit 79bdea9

Browse files
committed
隐藏字段的调试信息
1 parent 4c335ab commit 79bdea9

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

WebApiClientCore/ApiResponseContext.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Diagnostics;
23
using System.Diagnostics.CodeAnalysis;
34
using System.Net.Http;
45
using System.Text;
@@ -11,7 +12,10 @@ namespace WebApiClientCore
1112
/// </summary>
1213
public class ApiResponseContext : ApiRequestContext
1314
{
15+
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
1416
private object? result;
17+
18+
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
1519
private Exception? exception;
1620

1721
/// <summary>

WebApiClientCore/HttpApiOptions.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Diagnostics;
23
using System.Text.Encodings.Web;
34
using System.Text.Json;
45
using System.Xml;
@@ -11,10 +12,19 @@ namespace WebApiClientCore
1112
/// </summary>
1213
public class HttpApiOptions
1314
{
15+
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
1416
private JsonSerializerOptions? jsonSerializeOptions;
17+
18+
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
1519
private JsonSerializerOptions? jsonDeserializeOptions;
20+
21+
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
1622
private XmlWriterSettings? xmlSerializeOptions;
23+
24+
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
1725
private XmlReaderSettings? xmlDeserializeOptions;
26+
27+
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
1828
private KeyValueSerializerOptions? keyValueSerializeOptions;
1929

2030
/// <summary>

WebApiClientCore/Serialization/KeyValueSerializerOptions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Diagnostics;
34
using System.Text.Encodings.Web;
45
using System.Text.Json;
56
using System.Text.Json.Serialization;
@@ -14,6 +15,7 @@ public sealed class KeyValueSerializerOptions : KeyNamingOptions
1415
/// <summary>
1516
/// 包装的jsonOptions
1617
/// </summary>
18+
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
1719
private readonly JsonSerializerOptions jsonOptions;
1820

1921
/// <summary>

WebApiClientCore/System.Net.Http/HttpContentExtensions.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ public static async Task<byte[]> ReadAsByteArrayAsync(this HttpContent httpConte
4444
public static Encoding GetEncoding(this HttpContent httpContent)
4545
{
4646
var charSet = httpContent.Headers.ContentType?.CharSet;
47-
return string.IsNullOrEmpty(charSet) ? Encoding.UTF8 : Encoding.GetEncoding(charSet);
47+
if (string.IsNullOrEmpty(charSet) || charSet == Encoding.UTF8.WebName)
48+
{
49+
return Encoding.UTF8;
50+
}
51+
return Encoding.GetEncoding(charSet);
4852
}
4953
}
5054
}

0 commit comments

Comments
 (0)