XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFEExtension

【DLL】XFE各类拓展是一个C#的DLL库,旨在优化C#代码中常用语句的使用,并提供更简洁的访问方式,同时提供Xunit测试框架,快速搭建服务器/客户端,免费ChatGPTAPI接口,免费通讯服务器,XFE下载器,新增格式等

公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/XFEExtension

修复对象分析解析空对象的bug[3]

d3c8b5a
XFE工作室室长 <mail@xfegzs.com>
提交于

代码差异

5 个文件 +28 -18
Modified XFEExtension.NetCore.Analyzer.Test/Program.cs +2 -4
@@ -1,5 +1,4 @@
1 1 using System.Diagnostics;
2 using XFEExtension.NetCore.FileExtension;
3 2 using XFEExtension.NetCore.StringExtension;
4 3
5 4 namespace XFEExtension.NetCore.Analyzer.Test;
@@ -13,9 +12,8 @@ internal class Program
13 12 Tags = [["123", "321"], ["1234567", "7654321"]],
14 13 Enum = MyEnum.Test1
15 14 };
16 var process = Process.GetProcessesByName("QQ");
17 process.X()?.WriteIn("QQAnalyze.txt");
18 testClass.X()?.WriteIn("TestClassAnalyze.txt");
15 var process = Process.GetProcessById(13880);
16 process.X();
19 17 }
20 18 }
21 19 enum MyEnum
Modified XFEExtension.NetCore.Analyzer.Test/TestClass.cs +1 -0
@@ -5,6 +5,7 @@ internal class TestClass(string name, string description, int age)
5 5 public int id;
6 6 private int data;
7 7 public EmptyClass EPClass { get; } = new();
8 public ushort OS { get; set; }
8 9 public string Name { get; set; } = name;
9 10 public List<List<string>> Tags { get; set; }
10 11 public bool MyProperty { get; set; }
Modified XFEExtension.NetCore/XFEExtension.NetCore.csproj +2 -2
@@ -19,7 +19,7 @@
19 19 <PackageTags>XFE;拓展;GPT;Server;服务器;测试;XFEExtension</PackageTags>
20 20 <PackageReleaseNotes>## 调整
21 21
22 修复对象分析解析空对象的bug[2]
22 修复对象分析解析空对象的bug[3]
23 23
24 24 ## 新增
25 25
@@ -32,7 +32,7 @@
32 32 <PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
33 33 <PackageLicenseFile>LICENSE</PackageLicenseFile>
34 34 <AssemblyOriginatorKeyFile>..\XFEstudio.pfx</AssemblyOriginatorKeyFile>
35 <Version>2.8.2</Version>
35 <Version>2.8.3</Version>
36 36 <Authors>XFEstudio</Authors>
37 37 </PropertyGroup>
38 38
Modified XFEExtension.NetCore/XFETransform/StringConverter/ObjectAnalyzer.cs +20 -9
@@ -19,12 +19,16 @@ public class ObjectAnalyzer : StringConverter
19 19 {
20 20 if (objectInfo.Value is null)
21 21 {
22 outPutString += $"{AddObjectPlace(objectInfo)} 空对象 {objectInfo.Name}:null\n";
22 outPutString += $"{AddObjectPlace(objectInfo)} {XFEConverter.OutPutTypeName(objectInfo.Type!)} {objectInfo.Name}:null\n";
23 23 }
24 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 }
28 else if (objectInfo.Value is string str && str == string.Empty)
29 {
30 outPutString += $"{AddObjectPlace(objectInfo)} {XFEConverter.OutPutTypeName(objectInfo.Type!)} {objectInfo.Name}:string.Empty\n";
31 }
28 32 else
29 33 {
30 34 outPutString += $"{AddObjectPlace(objectInfo)} {XFEConverter.OutPutTypeName(objectInfo.Type!)} {objectInfo.Name}:{objectInfo.Value}\n";
@@ -34,13 +38,20 @@ public class ObjectAnalyzer : StringConverter
34 38 {
35 39 if (objectInfo.Layer == 0)
36 40 {
37 outPutString += $"""
38 {AddObjectPlace(objectInfo)} {XFEConverter.OutPutTypeName(objectInfo.Type!)} {objectInfo.Name}
39 ┌────┬────────────────────────────
40 {(objectInfo.SubObjects?.Count > 0 ? OutPutSubObjects(objectInfo.SubObjects) : "│ └─空对象")}
41 └─────────────────────────────────
42
43 """;
41 if (objectInfo.SubObjects?.Count > 0)
42 {
43 outPutString += $"""
44 {AddObjectPlace(objectInfo)} {XFEConverter.OutPutTypeName(objectInfo.Type!)} {objectInfo.Name}
45 ┌────┬────────────────────────────
46 {OutPutSubObjects(objectInfo.SubObjects)}
47 └─────────────────────────────────
48
49 """;
50 }
51 else
52 {
53 outPutString += $"{AddObjectPlace(objectInfo)} {XFEConverter.OutPutTypeName(objectInfo.Type!)} {objectInfo.Name}: null";
54 }
44 55 }
45 56 else
46 57 {
@@ -97,7 +108,7 @@ public class ObjectAnalyzer : StringConverter
97 108 {
98 109 if (obj.SubObjects is null)
99 110 {
100 outString += $"├─{AddObjectPlace(obj)} {XFEConverter.OutPutTypeName(obj.Type!)} {obj.Name}: null\n";
111 outString += $"{currentConnectString}{AddObjectPlace(obj)} {XFEConverter.OutPutTypeName(obj.Type!)} {obj.Name}: null\n";
101 112 }
102 113 else
103 114 {
Modified XFEExtension.NetCore/XFETransform/XFEConverter.cs +3 -3
@@ -17,7 +17,7 @@ public class XFEConverter
17 17 /// <returns></returns>
18 18 public static bool IsBasicType(Type type)
19 19 {
20 return type == typeof(string) || type == typeof(int) || type == typeof(double) || type == typeof(float) || type == typeof(decimal) || type == typeof(long) || type == typeof(short) || type == typeof(byte) || type == typeof(bool) || type == typeof(char) || type == typeof(DateTime);
20 return type == typeof(string) || type == typeof(int) || type == typeof(double) || type == typeof(float) || type == typeof(decimal) || type == typeof(long) || type == typeof(short) || type == typeof(byte) || type == typeof(bool) || type == typeof(char) || type == typeof(nint) || type == typeof(uint) || type == typeof(ulong) || type == typeof(ushort) || type == typeof(sbyte) || type == typeof(DateTime);
21 21 }
22 22
23 23 /// <summary>
@@ -25,7 +25,7 @@ public class XFEConverter
25 25 /// </summary>
26 26 /// <param name="originString">原文本</param>
27 27 /// <returns></returns>
28 public static string ConvertBasicTypeToCodeType(string originString) => originString.ToLower().Replace("int32", "int").Replace("int64", "long").Replace("int16", "short").Replace("boolean", "bool").Replace("datetime", "DateTime");
28 public static string ConvertBasicTypeToCodeType(string originString) => originString.ToLower().Replace("int32", "int").Replace("intptr", "nint").Replace("int64", "long").Replace("int16", "short").Replace("boolean", "bool").Replace("datetime", "DateTime");
29 29
30 30 /// <summary>
31 31 /// 输出类型名称
@@ -63,7 +63,7 @@ public class XFEConverter
63 63 {
64 64 if (value is null || type is null)
65 65 {
66 return new ObjectInfoImpl(stringConverter, name, objectPlace, layer, null, true);
66 return new ObjectInfoImpl(stringConverter, name, objectPlace, layer, type, true);
67 67 }
68 68 var isBasicType = IsBasicType(type);
69 69 if (isBasicType)