optimize<Issue>: simplify crashreport logic while compiling with .NET 6

This commit is contained in:
leo 2021-10-28 16:00:28 +08:00
parent 3628729a93
commit 37ce2cdba6

View file

@ -1,5 +1,6 @@
using System; using System;
using System.Reflection; using System.Reflection;
using System.Text;
using System.Text.Json; using System.Text.Json;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
@ -7,7 +8,6 @@ using System.Text.Json.Serialization;
using System.Net.Http; using System.Net.Http;
#else #else
using System.Net; using System.Net;
using System.Text;
#endif #endif
namespace SourceGit.Models { namespace SourceGit.Models {
@ -46,11 +46,9 @@ namespace SourceGit.Models {
e.StackTrace); e.StackTrace);
#if NET6_0_OR_GREATER #if NET6_0_OR_GREATER
var req = new HttpClient(); var content = new StringContent(JsonSerializer.Serialize(issue), Encoding.UTF8, "application/json");
req.DefaultRequestHeaders.Add("Content-Type", "application/json"); var req = new HttpClient() { Timeout = TimeSpan.FromSeconds(1) };
req.DefaultRequestHeaders.Add("charset", "UTF-8"); req.PostAsync("https://gitee.com/api/v5/repos/sourcegit/issues", content).Wait();
req.Timeout = TimeSpan.FromSeconds(1);
req.PostAsync("https://gitee.com/api/v5/repos/sourcegit/issues", new StringContent(JsonSerializer.Serialize(issue))).Wait();
#else #else
var req = WebRequest.CreateHttp("https://gitee.com/api/v5/repos/sourcegit/issues"); var req = WebRequest.CreateHttp("https://gitee.com/api/v5/repos/sourcegit/issues");
req.Method = "POST"; req.Method = "POST";