XFEExtension
【DLL】XFE各类拓展是一个C#的DLL库,旨在优化C#代码中常用语句的使用,并提供更简洁的访问方式,同时提供Xunit测试框架,快速搭建服务器/客户端,免费ChatGPTAPI接口,免费通讯服务器,XFE下载器,新增格式等
关注
0
Fork
0
Star
0
返回提交历史
Modified
README.md
+12
-3
Modified
XFE各类拓展.NetCore.Analyzer/ImplementAutoGenerator.cs
+1
-7
XFEstudio/XFEExtension
移除测试代码,修复README文档的一处问题
52c8594
代码差异
2 个文件
+13
-10
@@ -107,12 +107,21 @@ memorableXFEChatGPT.AskChatGPT("新的对话ID", Guid.NewGuid().ToString(), askC
107
107
108
108
```csharp
109
109
[CreateImpl]
110
abstract class TestAbstractClass
110
abstract class TestAbstractClass(int num)
111
111
{
112
public abstract void TestMethod();
112
public int Num { get; set; } = num;
113
113
}
114
114
115
class
115
class Program
116
{
117
static void Main(string[] args)
118
{
119
var testAbstractClass = new TestAbstractClassImpl(123);
120
Console.WriteLine(testAbstractClass.Num);
121
}
122
}
123
```
124
116
125
---
117
126
118
127
## IO流拓展操作示例
@@ -24,15 +24,9 @@ namespace XFE各类拓展.NetCore.Analyzer
24
24
foreach (var classDeclaration in classDeclarations)
25
25
{
26
26
var className = classDeclaration.Identifier.ValueText;
27
// 向类中添加一个空的Test方法
28
var method = SyntaxFactory.MethodDeclaration(SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.VoidKeyword)), "Test")
29
.AddModifiers(SyntaxFactory.Token(SyntaxKind.PublicKeyword))
30
.WithBody(SyntaxFactory.Block())
31
.NormalizeWhitespace();
32
// 将方法添加到原来的类中
33
var newClass = classDeclaration.AddMembers(method);
34
27
var implementationSyntaxTree = GenerateImplementationSyntaxTree(classDeclaration, usingDirectives);
35
28
context.AddSource($"{className}Impl.g.cs", implementationSyntaxTree.ToString());
29
//添加一个
36
30
}
37
31
}
38
32
}