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

XFEExtension

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

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

XFEstudio/XFEExtension

更新了TODO待办任务提醒的处理方式和相关配置

在README.md文件中,增加了对XFEExtension库和XUnit测试框架的描述,以及如何在csproj文件中设置配置和使用TODO待办任务提醒的示例代码。在XFEExtension.NetCore.Analyzer.Test.csproj文件中,修改了TodoListWarningLevel的值,并将TodoList的值设为false。在AnalyzerReleases.Shipped.md和AnalyzerReleases.Unshipped.md文件中,添加了新的规则,用于处理TODO待办任务提醒的诊断。在ProfileExtensionDiagnostics.cs文件中,移除了PropertyOrFieldNotStaticId相关的代码,并在SupportedDiagnostics中移除了对应的引用。在TodoCommentAnalyzerDiagnostics.cs文件中,添加了对正则表达式的引用,修改了对TODO待办任务提醒的处理方式,现在可以根据TODO后的数字来设置警告等级,并对应修改了警告等级的获取方式。在GeneratorOptions.cs文件中,修改了EnableTodoList和TodoListWarningLevel的名称和类型,并对应修改了在GetOptions方法中的处理方式。在XFEExtension.NetCore.csproj文件中,更新了包的版本号,并在发布说明中添加了对新功能的描述。

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

代码差异

8 个文件 +103 -35
Modified README.md +34 -1
@@ -2,7 +2,7 @@
2 2
3 3 ## 描述
4 4
5 XFEExtension是一个C#的DLL库,旨在优化C#代码中常用语句的使用,并提供更简洁的访问方式,同时提供Xunit测试框架,快速搭建服务器/客户端,免费ChatGPTAPI接口,免费通讯服务器,XFE下载器,新增格式等
5 XFEExtension是一个C#的DLL库,旨在优化C#代码中常用语句的使用,并提供更简洁的访问方式,同时提供XUnit测试框架,快速搭建服务器/客户端,免费ChatGPTAPI接口,免费通讯服务器,XFE下载器,新增格式等
6 6
7 7 ## 用途
8 8
@@ -14,10 +14,43 @@ XFEExtension库适用于各种C#项目,特别适合在需要提高代码可读
14 14
15 15 - **加速开发:** 通过减少样板代码,XFEExtension可以加速项目的开发过程,同时提高代码的可维护性。
16 16
17 ---
18
19 ## 设置csproj文件配置
20
21 ```xml
22 <PropertyGroup>
23 //设置是否启用自动配置文件
24 <AutoProfile>true</AutoProfile>
25 //设置是否启用自动路径
26 <AutoPath>true</AutoPath>
27 //设置是否启用TODO待办任务提醒
28 <TodoList>true</TodoList>
29 //设置待办任务的提示级别
30 <TodoListWarningLevel>3</TodoListWarningLevel>
31 </PropertyGroup>
32 ```
33
34 ---
35
17 36 # 示例(使用前记得进行相应的引用)
18 37
19 38 ---
20 39
40 ## TODO待办任务提醒
41
42 ```csharp
43 //TODO: 这是一个待办任务,使用默认提示级别
44
45 //TODO:1 这是一个待办任务,使用提示级别
46
47 //TODO:3 这是一个待办任务,使用错误提示级别
48
49 //提示级别:0-隐藏,1-提示,2-警告,3-错误
50 ```
51
52 ---
53
21 54 ## 自动实现配置文件的存储
22 55
23 56 #### 基础用法
Modified XFEExtension.NetCore.Analyzer.Test/XFEExtension.NetCore.Analyzer.Test.csproj +2 -1
@@ -6,7 +6,8 @@
6 6 <Nullable>enable</Nullable>
7 7 <OutputType>Exe</OutputType>
8 8 <AutoPath>false</AutoPath>
9 <TodoListWarningLevel>Info</TodoListWarningLevel>
9 <TodoListWarningLevel>1</TodoListWarningLevel>
10 <TodoList>false</TodoList>
10 11 <AutoProfile>false</AutoProfile>
11 12 </PropertyGroup>
12 13
Modified XFEExtension.NetCore.Analyzer/AnalyzerReleases.Shipped.md +9 -1
@@ -5,4 +5,12 @@
5 5 Rule ID | Category | Severity | Notes
6 6 --------|----------|----------|-------
7 7 XFE0002 | XFEExtension.NetCore.Analyzer.Diagnostics | Error | ProfileExtensionDiagnostics, [Documentation](https://www.xfegzs.com/codespace/diagnostics/XFE0002.html)
8 XFW0001 | XFEExtension.NetCore.Analyzer.Diagnostics | Warning | ProfileExtensionDiagnostics, [Documentation](https://www.xfegzs.com/codespace/diagnostics/XFW0001.html)
8 XFW0001 | XFEExtension.NetCore.Analyzer.Diagnostics | Warning | ProfileExtensionDiagnostics, [Documentation](https://www.xfegzs.com/codespace/diagnostics/XFW0001.html)
9
10 ## Release 2.10.4
11
12 ### New Rules
13
14 Rule ID | Category | Severity | Notes
15 --------|----------|----------|-------
16 TODO | XFEExtension.NetCore.Analyzer.Diagnostics | `Dynamic` | TodoCommentAnalyzerDiagnostics, [Documentation](https://www.xfegzs.com/codespace/diagnostics/TODO.html)
Modified XFEExtension.NetCore.Analyzer/AnalyzerReleases.Unshipped.md +0 -1
@@ -7,5 +7,4 @@ Rule ID | Category | Severity | Notes
7 7 --------|----------|----------|-------
8 8 TODO | XFEExtension.NetCore.Analyzer.Diagnostics | `Dynamic` | TodoCommentAnalyzerDiagnostics, [Documentation](https://www.xfegzs.com/codespace/diagnostics/TODO.html)
9 9 XFE0002 | XFEExtension.NetCore.Analyzer.Diagnostics | Error | ProfileExtensionDiagnostics, [Documentation](https://www.xfegzs.com/codespace/diagnostics/XFE0002.html)
10 XFE0003 | XFEExtension.NetCore.Analyzer.Diagnostics | Error | ProfileExtensionDiagnostics, [Documentation](https://www.xfegzs.com/codespace/diagnostics/XFE0003.html)
11 10 XFW0001 | XFEExtension.NetCore.Analyzer.Diagnostics | Warning | ProfileExtensionDiagnostics, [Documentation](https://www.xfegzs.com/codespace/diagnostics/XFW0001.html)
Modified XFEExtension.NetCore.Analyzer/Diagnostics/ProfileExtensionDiagnostics.cs +1 -11
@@ -12,7 +12,6 @@ namespace XFEExtension.NetCore.Analyzer.Diagnostics
12 12 public class ProfileExtensionDiagnostics : DiagnosticAnalyzer
13 13 {
14 14 public const string AddGetNoResultErrorId = "XFE0002";
15 public const string PropertyOrFieldNotStaticId = "XFE0003";
16 15 public const string AddSetNoSetResultWarningId = "XFW0001";
17 16
18 17 public static readonly DiagnosticDescriptor AddGetNoResultError = new DiagnosticDescriptor(AddGetNoResultErrorId,
@@ -33,16 +32,7 @@ namespace XFEExtension.NetCore.Analyzer.Diagnostics
33 32 "设置了自定义的Set方法但是没有对实际字段进行操作.",
34 33 "https://www.xfegzs.com/codespace/diagnostics/XFW0001.html");
35 34
36 public static readonly DiagnosticDescriptor PropertyOrFieldNotStatic = new DiagnosticDescriptor(PropertyOrFieldNotStaticId,
37 "配置属性或字段不是静态的",
38 "配置类的{0}不是静态的:'{1}'",
39 "XFEExtension.NetCore.Analyzer.Diagnostics",
40 DiagnosticSeverity.Error,
41 true,
42 "配置类的属性或字段不是静态的.",
43 "https://www.xfegzs.com/codespace/diagnostics/XFE0003.html");
44
45 public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => ImmutableArray.Create(AddGetNoResultError, AddSetNoSetResultWarning, PropertyOrFieldNotStatic);
35 public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics => ImmutableArray.Create(AddGetNoResultError, AddSetNoSetResultWarning);
46 36
47 37 public override void Initialize(AnalysisContext context)
48 38 {
Modified XFEExtension.NetCore.Analyzer/Diagnostics/TodoCommentAnalyzerDiagnostics.cs +37 -12
@@ -4,6 +4,7 @@ using Microsoft.CodeAnalysis.Diagnostics;
4 4 using System;
5 5 using System.Collections.Immutable;
6 6 using System.Linq;
7 using System.Text.RegularExpressions;
7 8
8 9 namespace XFEExtension.NetCore.Analyzer.Diagnostics
9 10 {
@@ -20,7 +21,7 @@ namespace XFEExtension.NetCore.Analyzer.Diagnostics
20 21 "TODO��������",
21 22 "��������{0}",
22 23 "XFEExtension.NetCore.Analyzer.Diagnostics",
23 (DiagnosticSeverity)Enum.Parse(typeof(DiagnosticSeverity),GeneratorOptions.TodoListWarningLevel.ToString()),
24 GetSeverityFromInt(GeneratorOptions.TodoListWarningLevel),
24 25 true,
25 26 "TODO�Ĵ�������.",
26 27 "https://www.xfegzs.com/codespace/diagnostics/TODO.html");
@@ -37,22 +38,46 @@ namespace XFEExtension.NetCore.Analyzer.Diagnostics
37 38
38 39 private void AnalyzeSyntaxTree(SyntaxTreeAnalysisContext context)
39 40 {
40 if (!GeneratorOptions.EnableTodoList)
41 if (!GeneratorOptions.TodoList)
41 42 return;
42 43 var root = context.Tree.GetRoot(context.CancellationToken);
43 44 var todoComments = root.DescendantTrivia().Where(trivia => trivia.IsKind(SyntaxKind.SingleLineCommentTrivia) && trivia.ToString().Contains("TODO:"));
44 45 foreach (var todoComment in todoComments)
45 46 {
46 var descriptor = new DiagnosticDescriptor(TodoCommentId,
47 "TODO��������",
48 "��������{0}",
49 "XFEExtension.NetCore.Analyzer.Diagnostics",
50 (DiagnosticSeverity)Enum.Parse(typeof(DiagnosticSeverity),GeneratorOptions.TodoListWarningLevel.ToString()),
51 true,
52 "TODO�Ĵ�������.",
53 "https://www.xfegzs.com/codespace/diagnostics/TODO.html");
54 var diagnostic = Diagnostic.Create(descriptor, todoComment.GetLocation(), todoComment.ToString().Replace("//", "").Replace("TODO:", ""));
55 context.ReportDiagnostic(diagnostic);
47 var match = Regex.Match(todoComment.ToString(), @"//TODO:\s*(\d)?\s*(.*)");
48 if (match.Success)
49 {
50 var level = match.Groups[1].Value != "" ? int.Parse(match.Groups[1].Value) : GeneratorOptions.TodoListWarningLevel;
51 var task = match.Groups[2].Value;
52
53 var descriptor = new DiagnosticDescriptor(TodoCommentId,
54 "TODO��������",
55 "��������{0}",
56 "XFEExtension.NetCore.Analyzer.Diagnostics",
57 GetSeverityFromInt(level),
58 true,
59 "TODO�Ĵ�������.",
60 "https://www.xfegzs.com/codespace/diagnostics/TODO.html");
61 var diagnostic = Diagnostic.Create(descriptor, todoComment.GetLocation(), task);
62 context.ReportDiagnostic(diagnostic);
63 }
64 }
65 }
66
67 private static DiagnosticSeverity GetSeverityFromInt(int level)
68 {
69 switch (level)
70 {
71 case 0:
72 return DiagnosticSeverity.Hidden;
73 case 1:
74 return DiagnosticSeverity.Info;
75 case 2:
76 return DiagnosticSeverity.Warning;
77 case 3:
78 return DiagnosticSeverity.Error;
79 default:
80 return DiagnosticSeverity.Warning;
56 81 }
57 82 }
58 83 }
Modified XFEExtension.NetCore.Analyzer/GeneratorOptions.cs +6 -5
@@ -7,8 +7,8 @@ namespace XFEExtension.NetCore.Analyzer
7 7 public static bool AutoProfile { get; set; } = true;
8 8 public static bool AutoPath { get; set; } = true;
9 9 public static bool AutoImplement { get; set; } = true;
10 public static bool EnableTodoList { get; set; } = true;
11 public static string TodoListWarningLevel { get; set; } = "Warning";
10 public static bool TodoList { get; set; } = true;
11 public static int TodoListWarningLevel { get; set; } = 2;
12 12 public static void GetOptions(GeneratorExecutionContext context)
13 13 {
14 14 if (context.AnalyzerConfigOptions.GlobalOptions.TryGetValue("build_property.AutoProfile", out var autoProfile))
@@ -17,10 +17,11 @@ namespace XFEExtension.NetCore.Analyzer
17 17 AutoPath = autoPath.ToLower() == "true";
18 18 if (context.AnalyzerConfigOptions.GlobalOptions.TryGetValue("build_property.AutoImplement", out var autoImplement))
19 19 AutoImplement = autoImplement.ToLower() == "true";
20 if (context.AnalyzerConfigOptions.GlobalOptions.TryGetValue("build_property.EnableTodoList", out var enableTodoList))
21 EnableTodoList = enableTodoList.ToLower() == "true";
20 if (context.AnalyzerConfigOptions.GlobalOptions.TryGetValue("build_property.TodoList", out var todoList))
21 TodoList = todoList.ToLower() == "true";
22 22 if (context.AnalyzerConfigOptions.GlobalOptions.TryGetValue("build_property.TodoListWarningLevel", out var todoListWarningLevel))
23 TodoListWarningLevel = todoListWarningLevel;
23 if (int.TryParse(todoListWarningLevel, out var warningLevel))
24 TodoListWarningLevel = warningLevel;
24 25 }
25 26 }
26 27 }
Modified XFEExtension.NetCore/XFEExtension.NetCore.csproj +14 -3
@@ -19,11 +19,22 @@
19 19 <PackageTags>XFE;拓展;GPT;Server;服务器;测试;XFEExtension</PackageTags>
20 20 <PackageReleaseNotes>## 调整
21 21
22 更新了GPT的模型,现在新增GPT-4o模型
22
23 23
24 24 ## 新增
25 25
26
26 现在TODO任务可以单独提醒,并可以让用户自己设置警告等级
27
28 在README.md文件中,增加了对XFEExtension库和XUnit测试框架的描述,以及如何在csproj文件中设置配置和使用TODO待办任务提醒的示例代码。
29
30 在AnalyzerReleases.Shipped.md和AnalyzerReleases.Unshipped.md文件中,添加了新的规则,用于处理TODO待办任务提醒的诊断。
31
32 在ProfileExtensionDiagnostics.cs文件中,移除了PropertyOrFieldNotStaticId相关的代码,并在SupportedDiagnostics中移除了对应的引用。
33
34 在TodoCommentAnalyzerDiagnostics.cs文件中,添加了对正则表达式的引用,修改了对TODO待办任务提醒的处理方式,现在可以根据TODO后的数字来设置警告等级,并对应修改了警告等级的获取方式。
35
36 在GeneratorOptions.cs文件中,修改了EnableTodoList和TodoListWarningLevel的名称和类型,并对应修改了在GetOptions方法中的处理方式。在XFEExtension.NetCore.csproj文件中,更新了包的版本号,并在发布说明中添加了对新功能的描述。
37
27 38
28 39 ## 严重
29 40
@@ -32,7 +43,7 @@
32 43 <PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
33 44 <PackageLicenseFile>LICENSE</PackageLicenseFile>
34 45 <AssemblyOriginatorKeyFile>..\XFEstudio.pfx</AssemblyOriginatorKeyFile>
35 <Version>2.10.3</Version>
46 <Version>2.10.4</Version>
36 47 <Authors>XFEstudio</Authors>
37 48 </PropertyGroup>
38 49