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

XFEExtension.NetCore.AutoConfig

【DLL】自动实现配置文件的存储

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

XFEstudio/XFEExtension.NetCore.AutoConfig

修复了增量生成器中没有对实例方法InstanceDeleteProfile生成对应的配置文件静态方法DeleteProfile的bug

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

代码差异

3 个文件 +30 -18
Modified XFEExtension.NetCore.AutoConfig.Analyzer/Diagnostics/AutoConfigDiagnostics.cs +2 -1
@@ -5,7 +5,8 @@ using Microsoft.CodeAnalysis.Diagnostics;
5 5 using System.Collections.Immutable;
6 6 using System.Linq;
7 7 using System.Text.RegularExpressions;
8 using XFEExtension.NetCore.AutoConfig.Generator;
8 using XFEExtension.NetCore.AutoConfig.Analyzer.Generator;
9
9 10 namespace XFEExtension.NetCore.AutoConfig.Diagnostics
10 11 {
11 12 [DiagnosticAnalyzer(LanguageNames.CSharp)]
Modified XFEExtension.NetCore.AutoConfig.Analyzer/Generator/ProfilePropertyAutoGenerator.cs +14 -5
@@ -4,7 +4,7 @@ using Microsoft.CodeAnalysis.CSharp.Syntax;
4 4 using System.Collections.Generic;
5 5 using System.Linq;
6 6
7 namespace XFEExtension.NetCore.AutoConfig.Generator;
7 namespace XFEExtension.NetCore.AutoConfig.Analyzer.Generator;
8 8
9 9 [Generator]
10 10 public class ProfilePropertyAutoGenerator : IIncrementalGenerator
@@ -224,19 +224,19 @@ public class ProfilePropertyAutoGenerator : IIncrementalGenerator
224 224 }
225 225 public static bool IsProfilePropertyAttribute(AttributeListSyntax attributeList) => attributeList.Attributes.Any(attribute => attribute.Name.ToString() == "ProfileProperty");
226 226
227 public static List<AttributeSyntax> GetProfilePropertyAttributeList(FieldDeclarationSyntax fieldDeclaration) => fieldDeclaration.AttributeLists.Where(IsProfilePropertyAttribute).SelectMany(attributeList => attributeList.Attributes).ToList();
227 public static List<AttributeSyntax> GetProfilePropertyAttributeList(FieldDeclarationSyntax fieldDeclaration) => [.. fieldDeclaration.AttributeLists.Where(IsProfilePropertyAttribute).SelectMany(attributeList => attributeList.Attributes)];
228 228
229 229 public static bool IsAutoLoadProfileAttribute(AttributeListSyntax attributeList) => attributeList.Attributes.Any(attribute => attribute.Name.ToString() == "AutoLoadProfile");
230 230
231 public static List<AttributeSyntax> GetAutoLoadProfileAttribute(FieldDeclarationSyntax fieldDeclaration) => fieldDeclaration.AttributeLists.Where(IsAutoLoadProfileAttribute).SelectMany(attributeList => attributeList.Attributes).ToList();
231 public static List<AttributeSyntax> GetAutoLoadProfileAttribute(FieldDeclarationSyntax fieldDeclaration) => [.. fieldDeclaration.AttributeLists.Where(IsAutoLoadProfileAttribute).SelectMany(attributeList => attributeList.Attributes)];
232 232
233 233 public static bool IsProfilePropertyAddGetAttribute(AttributeListSyntax attributeList) => attributeList.Attributes.Any(attribute => attribute.Name.ToString() == "ProfilePropertyAddGet");
234 234
235 public static List<AttributeSyntax> GetProfilePropertyAddGetAttributeList(FieldDeclarationSyntax fieldDeclaration) => fieldDeclaration.AttributeLists.Where(IsProfilePropertyAddGetAttribute).SelectMany(attributeList => attributeList.Attributes).ToList();
235 public static List<AttributeSyntax> GetProfilePropertyAddGetAttributeList(FieldDeclarationSyntax fieldDeclaration) => [.. fieldDeclaration.AttributeLists.Where(IsProfilePropertyAddGetAttribute).SelectMany(attributeList => attributeList.Attributes)];
236 236
237 237 public static bool IsProfilePropertyAddSetAttribute(AttributeListSyntax attributeList) => attributeList.Attributes.Any(attribute => attribute.Name.ToString() == "ProfilePropertyAddSet");
238 238
239 public static List<AttributeSyntax> GetProfilePropertyAddSetAttributeList(FieldDeclarationSyntax fieldDeclaration) => fieldDeclaration.AttributeLists.Where(IsProfilePropertyAddSetAttribute).SelectMany(attributeList => attributeList.Attributes).ToList();
239 public static List<AttributeSyntax> GetProfilePropertyAddSetAttributeList(FieldDeclarationSyntax fieldDeclaration) => [.. fieldDeclaration.AttributeLists.Where(IsProfilePropertyAddSetAttribute).SelectMany(attributeList => attributeList.Attributes)];
240 240
241 241 public static FileScopedNamespaceDeclarationSyntax GetFileScopedNamespaceDeclaration(SyntaxNode rootNode)
242 242 {
@@ -368,6 +368,15 @@ public class ProfilePropertyAutoGenerator : IIncrementalGenerator
368 368 /// 配置文件保存方法<br/><br/>
369 369 /// <seealso cref=""{className}.SaveProfile""/> 是根据 <seealso cref=""{className}""/> 生成的保存配置文件的静态方法
370 370 /// </summary>
371 ")));
372 memberDeclarationSyntaxes.Add(SyntaxFactory.MethodDeclaration(SyntaxFactory.ParseTypeName("void"), "DeleteProfile")
373 .WithModifiers(SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.PublicKeyword), SyntaxFactory.Token(SyntaxKind.StaticKeyword)))
374 .WithExpressionBody(SyntaxFactory.ArrowExpressionClause(SyntaxFactory.ParseExpression($"Current.InstanceDeleteProfile()")))
375 .WithSemicolonToken(SyntaxFactory.Token(SyntaxKind.SemicolonToken))
376 .WithLeadingTrivia(SyntaxFactory.ParseLeadingTrivia($@"/// <summary>
377 /// 配置文件删除方法<br/><br/>
378 /// <seealso cref=""{className}.DeleteProfile""/> 是根据 <seealso cref=""{className}""/> 生成的删除配置文件的静态方法
379 /// </summary>
371 380 ")));
372 381 memberDeclarationSyntaxes.Add(SyntaxFactory.MethodDeclaration(SyntaxFactory.ParseTypeName("string"), "ExportProfile")
373 382 .WithModifiers(SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.PublicKeyword), SyntaxFactory.Token(SyntaxKind.StaticKeyword)))
Modified XFEExtension.NetCore.AutoConfig/XFEExtension.NetCore.AutoConfig.csproj +14 -12
@@ -15,19 +15,21 @@
15 15 <RepositoryUrl>https://github.com/XFEstudio/XFEExtension.NetCore.AutoConfig</RepositoryUrl>
16 16 <PackageProjectUrl>https://github.com/XFEstudio/XFEExtension.NetCore.AutoConfig</PackageProjectUrl>
17 17 <PackageTags>XFE;config;profile;auto</PackageTags>
18 <PackageReleaseNotes>## 调整
19
20 修复了初始化导致的路径冲突问题
21
22 ## 新增
23
24
25
26 ## 严重
27
28 无</PackageReleaseNotes>
18 <PackageReleaseNotes>
19 ## 调整
20
21 修复了增量生成器中没有对实例方法InstanceDeleteProfile生成对应的配置文件静态方法DeleteProfile的bug
22
23 ## 新增
24
25
26
27 ## 严重
28
29
30 </PackageReleaseNotes>
29 31 <PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
30 <Version>2.0.5</Version>
32 <Version>2.0.6</Version>
31 33 <GenerateDocumentationFile>True</GenerateDocumentationFile>
32 34 </PropertyGroup>
33 35