XFEExtension
【DLL】XFE各类拓展是一个C#的DLL库,旨在优化C#代码中常用语句的使用,并提供更简洁的访问方式,同时提供Xunit测试框架,快速搭建服务器/客户端,免费ChatGPTAPI接口,免费通讯服务器,XFE下载器,新增格式等
关注
0
Fork
0
Star
0
返回提交历史
Modified
XFEExtension.NetCore.Analyzer.Test/Program.cs
+5
-13
Modified
XFEExtension.NetCore.Analyzer.Test/TestClass.cs
+3
-0
Modified
XFEExtension.NetCore/StringExtension/StringExtension.cs
+14
-2
Modified
XFEExtension.NetCore/XFEExtension.NetCore.csproj
+3
-3
Modified
XFEExtension.NetCore/XFETransform/StringConverter/ObjectAnalyzer.cs
+22
-4
XFEstudio/XFEExtension
修复对象分析解析空对象的bug[2]
c10a721
代码差异
5 个文件
+47
-22
@@ -1,7 +1,6 @@
1
using System.Text.Json;
1
using System.Diagnostics;
2
using XFEExtension.NetCore.FileExtension;
2
3
using XFEExtension.NetCore.StringExtension;
3
using XFEExtension.NetCore.StringExtension.Json;
4
using XFEExtension.NetCore.XFETransform;
5
4
6
5
namespace XFEExtension.NetCore.Analyzer.Test;
7
6
@@ -14,16 +13,9 @@ internal class Program
14
13
Tags = [["123", "321"], ["1234567", "7654321"]],
15
14
Enum = MyEnum.Test1
16
15
};
17
var json = testClass.ToJson();
18
//var json = JsonSerializer.Serialize(testClass);
19
//testClass.Enum.ToString().CW();
20
//Console.WriteLine(json);
21
//JsonSerializer.Deserialize<TestClass>(json).X();
22
var testString = "this is a t//e/st #//# /# divide : string";
23
var escapeConverter = new EscapeConverter("/", "#", ":");
24
var convertedString = escapeConverter.Convert(testString);
25
Console.WriteLine(convertedString);
26
escapeConverter.Inverse(convertedString).CW();
16
var process = Process.GetProcessesByName("QQ");
17
process.X()?.WriteIn("QQAnalyze.txt");
18
testClass.X()?.WriteIn("TestClassAnalyze.txt");
27
19
}
28
20
}
29
21
enum MyEnum
@@ -4,6 +4,7 @@ internal class TestClass(string name, string description, int age)
4
4
{
5
5
public int id;
6
6
private int data;
7
public EmptyClass EPClass { get; } = new();
7
8
public string Name { get; set; } = name;
8
9
public List<List<string>> Tags { get; set; }
9
10
public bool MyProperty { get; set; }
@@ -11,3 +12,5 @@ internal class TestClass(string name, string description, int age)
11
12
public string Description { get; set; } = description;
12
13
public int Age { get; set; } = age;
13
14
}
15
16
internal class EmptyClass { }
@@ -264,7 +264,13 @@ public static partial class StringExtension
264
264
/// <param name="remarkName">对象别名</param>
265
265
/// <param name="onlyProperty"></param>
266
266
/// <param name="onlyPublic"></param>
267
public static void X(this object? obj, string remarkName = "分析对象", bool onlyProperty = true, bool onlyPublic = true) => Console.WriteLine(XFEConverter.GetObjectInfo(StringConverter.ObjectAnalyzer, remarkName, ObjectPlace.Main, 0, obj?.GetType(), obj, onlyProperty, onlyPublic).OutPutObject());
267
public static string? X(this object? obj, bool onlyProperty = true, bool onlyPublic = true, string remarkName = "分析对象")
268
{
269
var result = XFEConverter.GetObjectInfo(StringConverter.ObjectAnalyzer, remarkName, ObjectPlace.Main, 0, obj?.GetType(), obj, onlyProperty, onlyPublic).OutPutObject();
270
Console.WriteLine(result);
271
return result;
272
}
273
268
274
/// <summary>
269
275
/// 分析对象并输出到跟踪输出
270
276
/// </summary>
@@ -272,7 +278,13 @@ public static partial class StringExtension
272
278
/// <param name="remarkName">对象别名</param>
273
279
/// <param name="onlyProperty"></param>
274
280
/// <param name="onlyPublic"></param>
275
public static void XL(this object? obj, string remarkName = "分析对象", bool onlyProperty = true, bool onlyPublic = true) => Trace.WriteLine(XFEConverter.GetObjectInfo(StringConverter.ObjectAnalyzer, remarkName, ObjectPlace.Main, 0, obj?.GetType(), obj, onlyProperty, onlyPublic).OutPutObject());
281
public static string XL(this object? obj, string remarkName = "分析对象", bool onlyProperty = true, bool onlyPublic = true)
282
{
283
var result = XFEConverter.GetObjectInfo(StringConverter.ObjectAnalyzer, remarkName, ObjectPlace.Main, 0, obj?.GetType(), obj, onlyProperty, onlyPublic).OutPutObject();
284
Trace.WriteLine(result);
285
return result;
286
}
287
276
288
/// <summary>
277
289
/// 字符串实际显示的长度
278
290
/// </summary>
@@ -19,11 +19,11 @@
19
19
<PackageTags>XFE;拓展;GPT;Server;服务器;测试;XFEExtension</PackageTags>
20
20
<PackageReleaseNotes>## 调整
21
21
22
修复单元测试计时器显示问题
22
修复对象分析解析空对象的bug[2]
23
23
24
24
## 新增
25
25
26
添加转义类
26
无
27
27
28
28
## 严重
29
29
@@ -32,7 +32,7 @@
32
32
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
33
33
<PackageLicenseFile>LICENSE</PackageLicenseFile>
34
34
<AssemblyOriginatorKeyFile>..\XFEstudio.pfx</AssemblyOriginatorKeyFile>
35
<Version>2.8.0</Version>
35
<Version>2.8.2</Version>
36
36
<Authors>XFEstudio</Authors>
37
37
</PropertyGroup>
38
38
@@ -21,7 +21,7 @@ public class ObjectAnalyzer : StringConverter
21
21
{
22
22
outPutString += $"{AddObjectPlace(objectInfo)} 空对象 {objectInfo.Name}:null\n";
23
23
}
24
else if(objectInfo.ObjectPlace == ObjectPlace.Enum)
24
else if (objectInfo.ObjectPlace == ObjectPlace.Enum)
25
25
{
26
26
outPutString += $"{AddObjectPlace(objectInfo)} {XFEConverter.OutPutTypeName(objectInfo.Type!)} {objectInfo.Name}:{objectInfo.Value}[{(int)objectInfo.Value}]\n";
27
27
}
@@ -37,15 +37,26 @@ public class ObjectAnalyzer : StringConverter
37
37
outPutString += $"""
38
38
{AddObjectPlace(objectInfo)} {XFEConverter.OutPutTypeName(objectInfo.Type!)} {objectInfo.Name}
39
39
┌────┬────────────────────────────
40
{(objectInfo.SubObjects is not null ? OutPutSubObjects(objectInfo.SubObjects) : "| └─空对象")}
40
{(objectInfo.SubObjects?.Count > 0 ? OutPutSubObjects(objectInfo.SubObjects) : "│ └─空对象")}
41
41
└─────────────────────────────────
42
42
43
43
""";
44
44
}
45
45
else
46
46
{
47
var tabString = string.Empty;
48
for (int k = 0; k < objectInfo.Layer; k++)
49
{
50
tabString += "│ ";
51
}
47
52
if (objectInfo.SubObjects is not null)
48
outPutString += OutPutSubObjects(objectInfo.SubObjects);
53
{
54
if (objectInfo.SubObjects.Count > 0)
55
outPutString += OutPutSubObjects(objectInfo.SubObjects);
56
else
57
outPutString += $"{tabString}│ └─无内容";
58
59
}
49
60
}
50
61
}
51
62
return outPutString;
@@ -84,13 +95,20 @@ public class ObjectAnalyzer : StringConverter
84
95
}
85
96
else
86
97
{
87
outString += $"""
98
if (obj.SubObjects is null)
99
{
100
outString += $"├─{AddObjectPlace(obj)} {XFEConverter.OutPutTypeName(obj.Type!)} {obj.Name}: null\n";
101
}
102
else
103
{
104
outString += $"""
88
105
├─{AddObjectPlace(obj)} {XFEConverter.OutPutTypeName(obj.Type!)} {obj.Name}
89
106
{tabString}├────┬────────────────────────────
90
107
{obj.OutPutObject()}
91
108
{tabString}{currentConnectString}────────────────────────────────
92
109
93
110
""";
111
}
94
112
}
95
113
}
96
114
if (outString.Length > 0 && outString[^1] == '\n')