mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-11-01 13:13:21 -07:00
optimiz<Net48>: remove dependency Newtonsoft.Json
This commit is contained in:
parent
316344939a
commit
701d18216c
6 changed files with 4 additions and 69 deletions
|
@ -6,7 +6,7 @@ cd src
|
||||||
rmdir /s /q bin
|
rmdir /s /q bin
|
||||||
rmdir /s /q obj
|
rmdir /s /q obj
|
||||||
dotnet publish SourceGit_48.csproj --nologo -c Release -r win-x86 -o ..\publish\net48
|
dotnet publish SourceGit_48.csproj --nologo -c Release -r win-x86 -o ..\publish\net48
|
||||||
ilrepack /ndebug /out:..\publish\SourceGit.exe ..\publish\net48\SourceGit.exe ..\publish\net48\Newtonsoft.Json.dll
|
ilrepack /ndebug /wildcards /out:..\publish\SourceGit.exe ..\publish\net48\SourceGit.exe ..\publish\net48\*.dll
|
||||||
cd ..\publish
|
cd ..\publish
|
||||||
ren SourceGit.exe SourceGit_48.exe
|
ren SourceGit.exe SourceGit_48.exe
|
||||||
rmdir /s /q net48
|
rmdir /s /q net48
|
||||||
|
|
|
@ -5,29 +5,14 @@ using System.Net;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
#if NET48
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
#else
|
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace SourceGit.Models {
|
namespace SourceGit.Models {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 崩溃日志上报
|
/// 崩溃日志上报
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Issue {
|
public class Issue {
|
||||||
#if NET48
|
|
||||||
[JsonProperty(PropertyName = "access_token")]
|
|
||||||
public string AccessToken { get; set; }
|
|
||||||
[JsonProperty(PropertyName = "repo")]
|
|
||||||
public string Repo { get; set; }
|
|
||||||
[JsonProperty(PropertyName = "title")]
|
|
||||||
public string Title { get; set; }
|
|
||||||
[JsonProperty(PropertyName = "body")]
|
|
||||||
public string Body { get; set; }
|
|
||||||
#else
|
|
||||||
[JsonPropertyName("access_token")]
|
[JsonPropertyName("access_token")]
|
||||||
public string AccessToken { get; set; }
|
public string AccessToken { get; set; }
|
||||||
[JsonPropertyName("repo")]
|
[JsonPropertyName("repo")]
|
||||||
|
@ -36,7 +21,6 @@ namespace SourceGit.Models {
|
||||||
public string Title { get; set; }
|
public string Title { get; set; }
|
||||||
[JsonPropertyName("body")]
|
[JsonPropertyName("body")]
|
||||||
public string Body { get; set; }
|
public string Body { get; set; }
|
||||||
#endif
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建Gitee平台ISSUE
|
/// 创建Gitee平台ISSUE
|
||||||
|
@ -64,14 +48,9 @@ namespace SourceGit.Models {
|
||||||
req.Timeout = 1000;
|
req.Timeout = 1000;
|
||||||
|
|
||||||
using (var writer = req.GetRequestStream()) {
|
using (var writer = req.GetRequestStream()) {
|
||||||
#if NET48
|
var data = JsonSerializer.Serialize(issue);
|
||||||
var data = JsonConvert.SerializeObject(issue);
|
|
||||||
var raw = Encoding.UTF8.GetBytes(data);
|
var raw = Encoding.UTF8.GetBytes(data);
|
||||||
writer.Write(raw, 0, raw.Length);
|
writer.Write(raw, 0, raw.Length);
|
||||||
#else
|
|
||||||
var data = JsonSerializer.Serialize(issue);
|
|
||||||
writer.Write(Encoding.UTF8.GetBytes(data));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
req.GetResponse();
|
req.GetResponse();
|
||||||
|
|
|
@ -2,13 +2,8 @@ using Microsoft.Win32;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
#if NET48
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
#else
|
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace SourceGit.Models {
|
namespace SourceGit.Models {
|
||||||
|
|
||||||
|
@ -193,11 +188,7 @@ namespace SourceGit.Models {
|
||||||
instance = new Preference();
|
instance = new Preference();
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
#if NET48
|
|
||||||
instance = JsonConvert.DeserializeObject<Preference>(File.ReadAllText(SAVE_PATH));
|
|
||||||
#else
|
|
||||||
instance = JsonSerializer.Deserialize<Preference>(File.ReadAllText(SAVE_PATH));
|
instance = JsonSerializer.Deserialize<Preference>(File.ReadAllText(SAVE_PATH));
|
||||||
#endif
|
|
||||||
} catch {
|
} catch {
|
||||||
instance = new Preference();
|
instance = new Preference();
|
||||||
}
|
}
|
||||||
|
@ -219,12 +210,7 @@ namespace SourceGit.Models {
|
||||||
public static void Save() {
|
public static void Save() {
|
||||||
var dir = Path.GetDirectoryName(SAVE_PATH);
|
var dir = Path.GetDirectoryName(SAVE_PATH);
|
||||||
if (!Directory.Exists(dir)) Directory.CreateDirectory(dir);
|
if (!Directory.Exists(dir)) Directory.CreateDirectory(dir);
|
||||||
|
|
||||||
#if NET48
|
|
||||||
var data = JsonConvert.SerializeObject(instance, Formatting.Indented);
|
|
||||||
#else
|
|
||||||
var data = JsonSerializer.Serialize(instance, new JsonSerializerOptions() { WriteIndented = true });
|
var data = JsonSerializer.Serialize(instance, new JsonSerializerOptions() { WriteIndented = true });
|
||||||
#endif
|
|
||||||
File.WriteAllText(SAVE_PATH, data);
|
File.WriteAllText(SAVE_PATH, data);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
#if NET48
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
#else
|
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace SourceGit.Models {
|
namespace SourceGit.Models {
|
||||||
|
|
||||||
|
|
|
@ -4,13 +4,8 @@ using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
#if NET48
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
#else
|
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace SourceGit.Models {
|
namespace SourceGit.Models {
|
||||||
|
|
||||||
|
@ -18,22 +13,6 @@ namespace SourceGit.Models {
|
||||||
/// Gitee开放API中Release信息格式
|
/// Gitee开放API中Release信息格式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Version {
|
public class Version {
|
||||||
#if NET48
|
|
||||||
[JsonProperty(PropertyName = "id")]
|
|
||||||
public ulong Id { get; set; }
|
|
||||||
[JsonProperty(PropertyName = "tag_name")]
|
|
||||||
public string TagName { get; set; }
|
|
||||||
[JsonProperty(PropertyName = "target_commitish")]
|
|
||||||
public string CommitSHA { get; set; }
|
|
||||||
[JsonProperty(PropertyName = "prerelease")]
|
|
||||||
public bool PreRelease { get; set; }
|
|
||||||
[JsonProperty(PropertyName = "name")]
|
|
||||||
public string Name { get; set; }
|
|
||||||
[JsonProperty(PropertyName = "body")]
|
|
||||||
public string Body { get; set; }
|
|
||||||
[JsonProperty(PropertyName = "created_at")]
|
|
||||||
public DateTime CreatedAt { get; set; }
|
|
||||||
#else
|
|
||||||
[JsonPropertyName("id")]
|
[JsonPropertyName("id")]
|
||||||
public ulong Id { get; set; }
|
public ulong Id { get; set; }
|
||||||
[JsonPropertyName("tag_name")]
|
[JsonPropertyName("tag_name")]
|
||||||
|
@ -48,7 +27,7 @@ namespace SourceGit.Models {
|
||||||
public string Body { get; set; }
|
public string Body { get; set; }
|
||||||
[JsonPropertyName("created_at")]
|
[JsonPropertyName("created_at")]
|
||||||
public DateTime CreatedAt { get; set; }
|
public DateTime CreatedAt { get; set; }
|
||||||
#endif
|
|
||||||
public string PublishTime {
|
public string PublishTime {
|
||||||
get { return CreatedAt.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss"); }
|
get { return CreatedAt.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss"); }
|
||||||
}
|
}
|
||||||
|
@ -68,11 +47,7 @@ namespace SourceGit.Models {
|
||||||
try {
|
try {
|
||||||
var web = new WebClient() { Encoding = Encoding.UTF8 };
|
var web = new WebClient() { Encoding = Encoding.UTF8 };
|
||||||
var raw = web.DownloadString("https://gitee.com/api/v5/repos/sourcegit/sourcegit/releases/latest");
|
var raw = web.DownloadString("https://gitee.com/api/v5/repos/sourcegit/sourcegit/releases/latest");
|
||||||
#if NET48
|
|
||||||
var ver = JsonConvert.DeserializeObject<Version>(raw);
|
|
||||||
#else
|
|
||||||
var ver = JsonSerializer.Deserialize<Version>(raw);
|
var ver = JsonSerializer.Deserialize<Version>(raw);
|
||||||
#endif
|
|
||||||
var cur = Assembly.GetExecutingAssembly().GetName().Version;
|
var cur = Assembly.GetExecutingAssembly().GetName().Version;
|
||||||
|
|
||||||
var matches = Regex.Match(ver.TagName, @"^v(\d+)\.(\d+).*");
|
var matches = Regex.Match(ver.TagName, @"^v(\d+)\.(\d+).*");
|
||||||
|
|
|
@ -20,6 +20,6 @@
|
||||||
<AssemblyName>SourceGit</AssemblyName>
|
<AssemblyName>SourceGit</AssemblyName>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
<PackageReference Include="System.Text.Json" Version="5.0.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
Loading…
Reference in a new issue