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