XFEExtension
【DLL】XFE各类拓展是一个C#的DLL库,旨在优化C#代码中常用语句的使用,并提供更简洁的访问方式,同时提供Xunit测试框架,快速搭建服务器/客户端,免费ChatGPTAPI接口,免费通讯服务器,XFE下载器,新增格式等
关注
0
Fork
0
Star
0
返回提交历史
Added
XFEExtension.NetCore.Analyzer.Test/UpdatableMemoryListener.cs
+13
-0
Modified
XFEExtension.NetCore.Analyzer/Generator/ImplementAutoGenerator.cs
+11
-3
XFEstudio/XFEExtension
fix-修复自动实现类的构造器中带有之前构造器主体的bug
96a3909
代码差异
2 个文件
+24
-3
@@ -0,0 +1,13 @@
1
using XFEExtension.NetCore.ImplExtension;
2
3
namespace XFEExtension.NetCore.Analyzer.Test;
4
5
[CreateImpl]
6
public abstract class UpdatableMemoryListener
7
{
8
internal UpdatableMemoryListener(params int[] args)
9
{
10
foreach (var arg in args)
11
Console.WriteLine(arg);
12
}
13
}
@@ -45,11 +45,19 @@ namespace XFEExtension.NetCore.Analyzer.Generator
45
45
implementationClass = SyntaxFactory.ClassDeclaration($"{className}Impl")
46
46
.AddModifiers(SyntaxFactory.Token(SyntaxKind.InternalKeyword), SyntaxFactory.Token(SyntaxKind.SealedKeyword))
47
47
.AddBaseListTypes(SyntaxFactory.SimpleBaseType(SyntaxFactory.ParseTypeName(className)))
48
//.AddMembers(classDeclaration.Members.OfType<ConstructorDeclarationSyntax>().Select(constructor =>
49
//{
50
// return constructor.WithIdentifier(SyntaxFactory.Identifier($"{className}Impl"))
51
// .WithInitializer(SyntaxFactory.ConstructorInitializer(SyntaxKind.BaseConstructorInitializer, SyntaxFactory.ArgumentList(SyntaxFactory.SeparatedList(constructor.ParameterList.Parameters.Select(parameter =>
52
// SyntaxFactory.Argument(SyntaxFactory.IdentifierName(parameter.Identifier)))))));
53
//}).ToArray())
48
54
.AddMembers(classDeclaration.Members.OfType<ConstructorDeclarationSyntax>().Select(constructor =>
49
55
{
50
return constructor.WithIdentifier(SyntaxFactory.Identifier($"{className}Impl"))
51
.WithInitializer(SyntaxFactory.ConstructorInitializer(SyntaxKind.BaseConstructorInitializer, SyntaxFactory.ArgumentList(SyntaxFactory.SeparatedList(constructor.ParameterList.Parameters.Select(parameter =>
52
SyntaxFactory.Argument(SyntaxFactory.IdentifierName(parameter.Identifier)))))));
56
return SyntaxFactory.ConstructorDeclaration($"{className}Impl")
57
.AddModifiers(SyntaxFactory.Token(SyntaxKind.InternalKeyword))
58
.WithBody(SyntaxFactory.Block())
59
.WithParameterList(constructor.ParameterList)
60
.WithInitializer(SyntaxFactory.ConstructorInitializer(SyntaxKind.BaseConstructorInitializer, SyntaxFactory.ArgumentList(SyntaxFactory.SeparatedList(constructor.ParameterList.Parameters.Select(parameter => SyntaxFactory.Argument(SyntaxFactory.IdentifierName(parameter.Identifier)))))));
53
61
}).ToArray())
54
62
.WithLeadingTrivia(SyntaxFactory.ParseLeadingTrivia($@"/// <summary>
55
63
/// <seealso cref=""{className}Impl""/> 是根据 <seealso cref=""{className}""/> 自动生成的实现类