From 534818f5f6a8d7366d7bd6cd1f774e2ad0757775 Mon Sep 17 00:00:00 2001 From: GeWuYou <95328647+GeWuYou@users.noreply.github.com> Date: Thu, 16 Apr 2026 21:40:47 +0800 Subject: [PATCH] =?UTF-8?q?docs(source-generators):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=BA=90=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90=E5=99=A8=E6=96=87?= =?UTF-8?q?=E6=A1=A3=E5=92=8C=E7=9B=B8=E5=85=B3=E5=B8=B8=E9=87=8F=E5=AE=9A?= =?UTF-8?q?=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增完整的 GFramework.SourceGenerators 文档,涵盖所有核心特性 - 添加 Log 属性生成器、Config Schema 生成器等详细使用说明 - 添加 ContextAware、GenerateEnumExtensions 等属性生成器文档 - 添加 Godot 专用生成器如 GetNode、BindNodeSignal 等使用指南 - 添加 AutoRegisterModule、AutoUiPage、AutoScene 等自动化工具文档 - 添加诊断信息、性能优势、使用示例和最佳实践章节 - 新增 PathContests 常量类定义 GFramework 项目路径常量 - 添加 ContextRegistrationAnalyzerTests 测试类验证上下文注册分析器 --- .../Constants/PathContests.cs | 2 +- .../ContextRegistrationAnalyzerTests.cs | 20 +++--- .../AutoRegisterModuleGeneratorTests.cs | 18 +++--- .../Bases/PriorityGeneratorSnapshotTests.cs | 16 ++--- .../EnumExtensionsGeneratorSnapshotTests.cs | 20 +++--- .../Logging/LoggerGeneratorSnapshotTests.cs | 24 +++---- .../ContextAwareGeneratorSnapshotTests.cs | 4 +- .../Rule/ContextGetGeneratorTests.cs | 62 +++++++++---------- docs/zh-CN/source-generators/index.md | 10 ++- 9 files changed, 90 insertions(+), 86 deletions(-) diff --git a/GFramework.SourceGenerators.Common/Constants/PathContests.cs b/GFramework.SourceGenerators.Common/Constants/PathContests.cs index a9416fbe..cae0748c 100644 --- a/GFramework.SourceGenerators.Common/Constants/PathContests.cs +++ b/GFramework.SourceGenerators.Common/Constants/PathContests.cs @@ -39,7 +39,7 @@ public static class PathContests /// /// GFramework源代码生成器抽象层命名空间 /// - public const string SourceGeneratorsAbstractionsPath = $"{BaseNamespace}.SourceGenerators.Abstractions"; + public const string SourceGeneratorsAbstractionsPath = $"{CoreNamespace}.SourceGenerators.Abstractions"; /// /// GFramework Godot源代码生成器抽象层命名空间 diff --git a/GFramework.SourceGenerators.Tests/Analyzers/ContextRegistrationAnalyzerTests.cs b/GFramework.SourceGenerators.Tests/Analyzers/ContextRegistrationAnalyzerTests.cs index abcb4ccf..20d25f24 100644 --- a/GFramework.SourceGenerators.Tests/Analyzers/ContextRegistrationAnalyzerTests.cs +++ b/GFramework.SourceGenerators.Tests/Analyzers/ContextRegistrationAnalyzerTests.cs @@ -121,7 +121,7 @@ public sealed class ContextRegistrationAnalyzerTests } } - namespace GFramework.SourceGenerators.Abstractions.Rule + namespace GFramework.Core.SourceGenerators.Abstractions.Rule { public sealed class GetModelAttribute : Attribute { } public sealed class GetModelsAttribute : Attribute { } @@ -142,7 +142,7 @@ public sealed class ContextRegistrationAnalyzerTests using GFramework.Core.Abstractions.Model; using GFramework.Core.Abstractions.Systems; using GFramework.Core.Architectures; - using GFramework.SourceGenerators.Abstractions.Rule; + using GFramework.Core.SourceGenerators.Abstractions.Rule; public interface IInventoryModel : IModel { } @@ -180,7 +180,7 @@ public sealed class ContextRegistrationAnalyzerTests using GFramework.Core.Abstractions.Model; using GFramework.Core.Abstractions.Systems; using GFramework.Core.Architectures; - using GFramework.SourceGenerators.Abstractions.Rule; + using GFramework.Core.SourceGenerators.Abstractions.Rule; public interface IInventoryModel : IModel { } @@ -255,7 +255,7 @@ public sealed class ContextRegistrationAnalyzerTests using GFramework.Core.Abstractions.Model; using GFramework.Core.Abstractions.Systems; using GFramework.Core.Architectures; - using GFramework.SourceGenerators.Abstractions.Rule; + using GFramework.Core.SourceGenerators.Abstractions.Rule; public interface IInventoryModel : IModel { } @@ -297,7 +297,7 @@ public sealed class ContextRegistrationAnalyzerTests using GFramework.Core.Abstractions.Model; using GFramework.Core.Abstractions.Systems; using GFramework.Core.Architectures; - using GFramework.SourceGenerators.Abstractions.Rule; + using GFramework.Core.SourceGenerators.Abstractions.Rule; public interface IInventoryModel : IModel { } @@ -337,7 +337,7 @@ public sealed class ContextRegistrationAnalyzerTests using GFramework.Core.Abstractions.Systems; using GFramework.Core.Abstractions.Utility; using GFramework.Core.Architectures; - using GFramework.SourceGenerators.Abstractions.Rule; + using GFramework.Core.SourceGenerators.Abstractions.Rule; public interface IInventoryUtility : IUtility { } @@ -376,7 +376,7 @@ public sealed class ContextRegistrationAnalyzerTests using GFramework.Core.Abstractions.Model; using GFramework.Core.Abstractions.Systems; using GFramework.Core.Architectures; - using GFramework.SourceGenerators.Abstractions.Rule; + using GFramework.Core.SourceGenerators.Abstractions.Rule; public interface IInventoryModel : IModel { } @@ -423,7 +423,7 @@ public sealed class ContextRegistrationAnalyzerTests using GFramework.Core.Abstractions.Model; using GFramework.Core.Abstractions.Systems; using GFramework.Core.Architectures; - using GFramework.SourceGenerators.Abstractions.Rule; + using GFramework.Core.SourceGenerators.Abstractions.Rule; public interface IInventoryModel : IModel { } @@ -477,7 +477,7 @@ public sealed class ContextRegistrationAnalyzerTests using GFramework.Core.Abstractions.Model; using GFramework.Core.Abstractions.Systems; using GFramework.Core.Architectures; - using GFramework.SourceGenerators.Abstractions.Rule; + using GFramework.Core.SourceGenerators.Abstractions.Rule; public interface IInventoryModel : IModel { } @@ -532,7 +532,7 @@ public sealed class ContextRegistrationAnalyzerTests using GFramework.Core.Abstractions.Model; using GFramework.Core.Abstractions.Systems; using GFramework.Core.Architectures; - using GFramework.SourceGenerators.Abstractions.Rule; + using GFramework.Core.SourceGenerators.Abstractions.Rule; public interface IInventoryModel : IModel { } diff --git a/GFramework.SourceGenerators.Tests/Architectures/AutoRegisterModuleGeneratorTests.cs b/GFramework.SourceGenerators.Tests/Architectures/AutoRegisterModuleGeneratorTests.cs index ae44a8ed..5eafa7c2 100644 --- a/GFramework.SourceGenerators.Tests/Architectures/AutoRegisterModuleGeneratorTests.cs +++ b/GFramework.SourceGenerators.Tests/Architectures/AutoRegisterModuleGeneratorTests.cs @@ -14,9 +14,9 @@ public class AutoRegisterModuleGeneratorTests { const string source = """ using System; - using GFramework.SourceGenerators.Abstractions.Architectures; + using GFramework.Core.SourceGenerators.Abstractions.Architectures; - namespace GFramework.SourceGenerators.Abstractions.Architectures + namespace GFramework.Core.SourceGenerators.Abstractions.Architectures { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] public sealed class AutoRegisterModuleAttribute : Attribute { } @@ -70,7 +70,7 @@ public class AutoRegisterModuleGeneratorTests using GFramework.Core.Abstractions.Model; using GFramework.Core.Abstractions.Systems; using GFramework.Core.Abstractions.Utility; - using GFramework.SourceGenerators.Abstractions.Architectures; + using GFramework.Core.SourceGenerators.Abstractions.Architectures; public sealed class PlayerModel : IModel { } public sealed class CombatSystem : ISystem { } @@ -118,7 +118,7 @@ public class AutoRegisterModuleGeneratorTests const string commonSource = """ using System; - namespace GFramework.SourceGenerators.Abstractions.Architectures + namespace GFramework.Core.SourceGenerators.Abstractions.Architectures { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] public sealed class AutoRegisterModuleAttribute : Attribute { } @@ -182,7 +182,7 @@ public class AutoRegisterModuleGeneratorTests const string partASource = """ namespace TestApp { - using GFramework.SourceGenerators.Abstractions.Architectures; + using GFramework.Core.SourceGenerators.Abstractions.Architectures; // Padding ensures this attribute lives later in the file than the attributes in PartB. // The generator should still place it first because PartA sorts before PartB. @@ -207,7 +207,7 @@ public class AutoRegisterModuleGeneratorTests const string partBSource = """ namespace TestApp { - using GFramework.SourceGenerators.Abstractions.Architectures; + using GFramework.Core.SourceGenerators.Abstractions.Architectures; [RegisterSystem(typeof(CombatSystem))] [RegisterModel(typeof(PlayerModel))] @@ -266,9 +266,9 @@ public class AutoRegisterModuleGeneratorTests const string source = """ #nullable enable using System; - using GFramework.SourceGenerators.Abstractions.Architectures; + using GFramework.Core.SourceGenerators.Abstractions.Architectures; - namespace GFramework.SourceGenerators.Abstractions.Architectures + namespace GFramework.Core.SourceGenerators.Abstractions.Architectures { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] public sealed class AutoRegisterModuleAttribute : Attribute { } @@ -320,7 +320,7 @@ public class AutoRegisterModuleGeneratorTests namespace TestApp { using GFramework.Core.Abstractions.Model; - using GFramework.SourceGenerators.Abstractions.Architectures; + using GFramework.Core.SourceGenerators.Abstractions.Architectures; public sealed class PlayerModel : IModel { } diff --git a/GFramework.SourceGenerators.Tests/Bases/PriorityGeneratorSnapshotTests.cs b/GFramework.SourceGenerators.Tests/Bases/PriorityGeneratorSnapshotTests.cs index bb29762a..79da21bb 100644 --- a/GFramework.SourceGenerators.Tests/Bases/PriorityGeneratorSnapshotTests.cs +++ b/GFramework.SourceGenerators.Tests/Bases/PriorityGeneratorSnapshotTests.cs @@ -19,7 +19,7 @@ public class PriorityGeneratorSnapshotTests const string source = """ using System; - namespace GFramework.SourceGenerators.Abstractions.Bases + namespace GFramework.Core.SourceGenerators.Abstractions.Bases { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] public sealed class PriorityAttribute : Attribute @@ -39,7 +39,7 @@ public class PriorityGeneratorSnapshotTests namespace TestApp { - using GFramework.SourceGenerators.Abstractions.Bases; + using GFramework.Core.SourceGenerators.Abstractions.Bases; [Priority(10)] public partial class MySystem @@ -67,7 +67,7 @@ public class PriorityGeneratorSnapshotTests const string source = """ using System; - namespace GFramework.SourceGenerators.Abstractions.Bases + namespace GFramework.Core.SourceGenerators.Abstractions.Bases { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] public sealed class PriorityAttribute : Attribute @@ -87,7 +87,7 @@ public class PriorityGeneratorSnapshotTests namespace TestApp { - using GFramework.SourceGenerators.Abstractions.Bases; + using GFramework.Core.SourceGenerators.Abstractions.Bases; [Priority(-100)] public partial class CriticalSystem @@ -115,7 +115,7 @@ public class PriorityGeneratorSnapshotTests const string source = """ using System; - namespace GFramework.SourceGenerators.Abstractions.Bases + namespace GFramework.Core.SourceGenerators.Abstractions.Bases { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] public sealed class PriorityAttribute : Attribute @@ -144,7 +144,7 @@ public class PriorityGeneratorSnapshotTests namespace TestApp { - using GFramework.SourceGenerators.Abstractions.Bases; + using GFramework.Core.SourceGenerators.Abstractions.Bases; using GFramework.Core.Abstractions.Bases; [Priority(PriorityGroup.High)] @@ -173,7 +173,7 @@ public class PriorityGeneratorSnapshotTests const string source = """ using System; - namespace GFramework.SourceGenerators.Abstractions.Bases + namespace GFramework.Core.SourceGenerators.Abstractions.Bases { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] public sealed class PriorityAttribute : Attribute @@ -193,7 +193,7 @@ public class PriorityGeneratorSnapshotTests namespace TestApp { - using GFramework.SourceGenerators.Abstractions.Bases; + using GFramework.Core.SourceGenerators.Abstractions.Bases; [Priority(20)] public partial class GenericSystem diff --git a/GFramework.SourceGenerators.Tests/Enums/EnumExtensionsGeneratorSnapshotTests.cs b/GFramework.SourceGenerators.Tests/Enums/EnumExtensionsGeneratorSnapshotTests.cs index f9ddf5c0..e70b4020 100644 --- a/GFramework.SourceGenerators.Tests/Enums/EnumExtensionsGeneratorSnapshotTests.cs +++ b/GFramework.SourceGenerators.Tests/Enums/EnumExtensionsGeneratorSnapshotTests.cs @@ -13,7 +13,7 @@ public class EnumExtensionsGeneratorSnapshotTests const string source = """ using System; - namespace GFramework.SourceGenerators.Abstractions.Enums + namespace GFramework.Core.SourceGenerators.Abstractions.Enums { [AttributeUsage(AttributeTargets.Enum)] public sealed class GenerateEnumExtensionsAttribute : Attribute @@ -25,7 +25,7 @@ public class EnumExtensionsGeneratorSnapshotTests namespace TestApp { - using GFramework.SourceGenerators.Abstractions.Enums; + using GFramework.Core.SourceGenerators.Abstractions.Enums; [GenerateEnumExtensions] public enum Status @@ -53,7 +53,7 @@ public class EnumExtensionsGeneratorSnapshotTests const string source = """ using System; - namespace GFramework.SourceGenerators.Abstractions.Enums + namespace GFramework.Core.SourceGenerators.Abstractions.Enums { [AttributeUsage(AttributeTargets.Enum)] public sealed class GenerateEnumExtensionsAttribute : Attribute @@ -65,7 +65,7 @@ public class EnumExtensionsGeneratorSnapshotTests namespace TestApp { - using GFramework.SourceGenerators.Abstractions.Enums; + using GFramework.Core.SourceGenerators.Abstractions.Enums; [GenerateEnumExtensions] public enum Status @@ -92,7 +92,7 @@ public class EnumExtensionsGeneratorSnapshotTests const string source = """ using System; - namespace GFramework.SourceGenerators.Abstractions.Enums + namespace GFramework.Core.SourceGenerators.Abstractions.Enums { [AttributeUsage(AttributeTargets.Enum)] public sealed class GenerateEnumExtensionsAttribute : Attribute @@ -104,7 +104,7 @@ public class EnumExtensionsGeneratorSnapshotTests namespace TestApp { - using GFramework.SourceGenerators.Abstractions.Enums; + using GFramework.Core.SourceGenerators.Abstractions.Enums; [GenerateEnumExtensions] [Flags] @@ -134,7 +134,7 @@ public class EnumExtensionsGeneratorSnapshotTests const string source = """ using System; - namespace GFramework.SourceGenerators.Abstractions.Enums + namespace GFramework.Core.SourceGenerators.Abstractions.Enums { [AttributeUsage(AttributeTargets.Enum)] public sealed class GenerateEnumExtensionsAttribute : Attribute @@ -146,7 +146,7 @@ public class EnumExtensionsGeneratorSnapshotTests namespace TestApp { - using GFramework.SourceGenerators.Abstractions.Enums; + using GFramework.Core.SourceGenerators.Abstractions.Enums; [GenerateEnumExtensions(GenerateIsMethods = false)] public enum Status @@ -173,7 +173,7 @@ public class EnumExtensionsGeneratorSnapshotTests const string source = """ using System; - namespace GFramework.SourceGenerators.Abstractions.Enums + namespace GFramework.Core.SourceGenerators.Abstractions.Enums { [AttributeUsage(AttributeTargets.Enum)] public sealed class GenerateEnumExtensionsAttribute : Attribute @@ -185,7 +185,7 @@ public class EnumExtensionsGeneratorSnapshotTests namespace TestApp { - using GFramework.SourceGenerators.Abstractions.Enums; + using GFramework.Core.SourceGenerators.Abstractions.Enums; [GenerateEnumExtensions(GenerateIsInMethod = false)] public enum Status diff --git a/GFramework.SourceGenerators.Tests/Logging/LoggerGeneratorSnapshotTests.cs b/GFramework.SourceGenerators.Tests/Logging/LoggerGeneratorSnapshotTests.cs index e1263a0f..07bb60a2 100644 --- a/GFramework.SourceGenerators.Tests/Logging/LoggerGeneratorSnapshotTests.cs +++ b/GFramework.SourceGenerators.Tests/Logging/LoggerGeneratorSnapshotTests.cs @@ -13,7 +13,7 @@ public class LoggerGeneratorSnapshotTests const string source = """ using System; - namespace GFramework.SourceGenerators.Abstractions.Logging + namespace GFramework.Core.SourceGenerators.Abstractions.Logging { [AttributeUsage(AttributeTargets.Class)] public sealed class LogAttribute : Attribute @@ -85,7 +85,7 @@ public class LoggerGeneratorSnapshotTests namespace TestApp { - using GFramework.SourceGenerators.Abstractions.Logging; + using GFramework.Core.SourceGenerators.Abstractions.Logging; [Log] public partial class MyService @@ -110,7 +110,7 @@ public class LoggerGeneratorSnapshotTests const string source = """ using System; - namespace GFramework.SourceGenerators.Abstractions.Logging + namespace GFramework.Core.SourceGenerators.Abstractions.Logging { [AttributeUsage(AttributeTargets.Class)] public sealed class LogAttribute : Attribute @@ -182,7 +182,7 @@ public class LoggerGeneratorSnapshotTests namespace TestApp { - using GFramework.SourceGenerators.Abstractions.Logging; + using GFramework.Core.SourceGenerators.Abstractions.Logging; [Log(Name = "CustomLogger")] public partial class MyService @@ -207,7 +207,7 @@ public class LoggerGeneratorSnapshotTests const string source = """ using System; - namespace GFramework.SourceGenerators.Abstractions.Logging + namespace GFramework.Core.SourceGenerators.Abstractions.Logging { [AttributeUsage(AttributeTargets.Class)] public sealed class LogAttribute : Attribute @@ -279,7 +279,7 @@ public class LoggerGeneratorSnapshotTests namespace TestApp { - using GFramework.SourceGenerators.Abstractions.Logging; + using GFramework.Core.SourceGenerators.Abstractions.Logging; [Log(FieldName = "MyLogger")] public partial class MyService @@ -304,7 +304,7 @@ public class LoggerGeneratorSnapshotTests const string source = """ using System; - namespace GFramework.SourceGenerators.Abstractions.Logging + namespace GFramework.Core.SourceGenerators.Abstractions.Logging { [AttributeUsage(AttributeTargets.Class)] public sealed class LogAttribute : Attribute @@ -376,7 +376,7 @@ public class LoggerGeneratorSnapshotTests namespace TestApp { - using GFramework.SourceGenerators.Abstractions.Logging; + using GFramework.Core.SourceGenerators.Abstractions.Logging; [Log(IsStatic = false)] public partial class MyService @@ -401,7 +401,7 @@ public class LoggerGeneratorSnapshotTests const string source = """ using System; - namespace GFramework.SourceGenerators.Abstractions.Logging + namespace GFramework.Core.SourceGenerators.Abstractions.Logging { [AttributeUsage(AttributeTargets.Class)] public sealed class LogAttribute : Attribute @@ -473,7 +473,7 @@ public class LoggerGeneratorSnapshotTests namespace TestApp { - using GFramework.SourceGenerators.Abstractions.Logging; + using GFramework.Core.SourceGenerators.Abstractions.Logging; [Log(AccessModifier = "public")] public partial class MyService @@ -498,7 +498,7 @@ public class LoggerGeneratorSnapshotTests const string source = """ using System; - namespace GFramework.SourceGenerators.Abstractions.Logging + namespace GFramework.Core.SourceGenerators.Abstractions.Logging { [AttributeUsage(AttributeTargets.Class)] public sealed class LogAttribute : Attribute @@ -570,7 +570,7 @@ public class LoggerGeneratorSnapshotTests namespace TestApp { - using GFramework.SourceGenerators.Abstractions.Logging; + using GFramework.Core.SourceGenerators.Abstractions.Logging; [Log] public partial class MyService diff --git a/GFramework.SourceGenerators.Tests/Rule/ContextAwareGeneratorSnapshotTests.cs b/GFramework.SourceGenerators.Tests/Rule/ContextAwareGeneratorSnapshotTests.cs index 415a7f09..e7b352bf 100644 --- a/GFramework.SourceGenerators.Tests/Rule/ContextAwareGeneratorSnapshotTests.cs +++ b/GFramework.SourceGenerators.Tests/Rule/ContextAwareGeneratorSnapshotTests.cs @@ -23,7 +23,7 @@ public class ContextAwareGeneratorSnapshotTests const string source = """ using System; - namespace GFramework.SourceGenerators.Abstractions.Rule + namespace GFramework.Core.SourceGenerators.Abstractions.Rule { [AttributeUsage(AttributeTargets.Class)] public sealed class ContextAwareAttribute : Attribute { } @@ -73,7 +73,7 @@ public class ContextAwareGeneratorSnapshotTests namespace TestApp { - using GFramework.SourceGenerators.Abstractions.Rule; + using GFramework.Core.SourceGenerators.Abstractions.Rule; using GFramework.Core.Abstractions.Rule; [ContextAware] diff --git a/GFramework.SourceGenerators.Tests/Rule/ContextGetGeneratorTests.cs b/GFramework.SourceGenerators.Tests/Rule/ContextGetGeneratorTests.cs index d16806e6..bae2d00c 100644 --- a/GFramework.SourceGenerators.Tests/Rule/ContextGetGeneratorTests.cs +++ b/GFramework.SourceGenerators.Tests/Rule/ContextGetGeneratorTests.cs @@ -12,9 +12,9 @@ public class ContextGetGeneratorTests var source = """ using System; using System.Collections.Generic; - using GFramework.SourceGenerators.Abstractions.Rule; + using GFramework.Core.SourceGenerators.Abstractions.Rule; - namespace GFramework.SourceGenerators.Abstractions.Rule + namespace GFramework.Core.SourceGenerators.Abstractions.Rule { [AttributeUsage(AttributeTargets.Class, Inherited = false)] public sealed class ContextAwareAttribute : Attribute { } @@ -102,9 +102,9 @@ public class ContextGetGeneratorTests { var source = """ using System; - using GFramework.SourceGenerators.Abstractions.Rule; + using GFramework.Core.SourceGenerators.Abstractions.Rule; - namespace GFramework.SourceGenerators.Abstractions.Rule + namespace GFramework.Core.SourceGenerators.Abstractions.Rule { [AttributeUsage(AttributeTargets.Class, Inherited = false)] public sealed class ContextAwareAttribute : Attribute { } @@ -148,7 +148,7 @@ public class ContextGetGeneratorTests [ContextAware] public partial class InventoryPanel { - [global::GFramework.SourceGenerators.Abstractions.Rule.GetModel] + [global::GFramework.Core.SourceGenerators.Abstractions.Rule.GetModel] private IInventoryModel _model = null!; } } @@ -184,9 +184,9 @@ public class ContextGetGeneratorTests var source = """ using System; using System.Collections.Generic; - using GFramework.SourceGenerators.Abstractions.Rule; + using GFramework.Core.SourceGenerators.Abstractions.Rule; - namespace GFramework.SourceGenerators.Abstractions.Rule + namespace GFramework.Core.SourceGenerators.Abstractions.Rule { [AttributeUsage(AttributeTargets.Class, Inherited = false)] public sealed class GetAllAttribute : Attribute { } @@ -291,9 +291,9 @@ public class ContextGetGeneratorTests { var source = """ using System; - using GFramework.SourceGenerators.Abstractions.Rule; + using GFramework.Core.SourceGenerators.Abstractions.Rule; - namespace GFramework.SourceGenerators.Abstractions.Rule + namespace GFramework.Core.SourceGenerators.Abstractions.Rule { [AttributeUsage(AttributeTargets.Class, Inherited = false)] public sealed class GetAllAttribute : Attribute { } @@ -382,9 +382,9 @@ public class ContextGetGeneratorTests { var source = """ using System; - using GFramework.SourceGenerators.Abstractions.Rule; + using GFramework.Core.SourceGenerators.Abstractions.Rule; - namespace GFramework.SourceGenerators.Abstractions.Rule + namespace GFramework.Core.SourceGenerators.Abstractions.Rule { [AttributeUsage(AttributeTargets.Class, Inherited = false)] public sealed class ContextAwareAttribute : Attribute { } @@ -460,9 +460,9 @@ public class ContextGetGeneratorTests { var source = """ using System; - using GFramework.SourceGenerators.Abstractions.Rule; + using GFramework.Core.SourceGenerators.Abstractions.Rule; - namespace GFramework.SourceGenerators.Abstractions.Rule + namespace GFramework.Core.SourceGenerators.Abstractions.Rule { [AttributeUsage(AttributeTargets.Class, Inherited = false)] public sealed class GetAllAttribute : Attribute { } @@ -543,9 +543,9 @@ public class ContextGetGeneratorTests { var source = MarkupTestSource.Parse(""" using System; - using GFramework.SourceGenerators.Abstractions.Rule; + using GFramework.Core.SourceGenerators.Abstractions.Rule; - namespace GFramework.SourceGenerators.Abstractions.Rule + namespace GFramework.Core.SourceGenerators.Abstractions.Rule { [AttributeUsage(AttributeTargets.Class, Inherited = false)] public sealed class GetAllAttribute : Attribute { } @@ -644,9 +644,9 @@ public class ContextGetGeneratorTests { var source = MarkupTestSource.Parse(""" using System; - using GFramework.SourceGenerators.Abstractions.Rule; + using GFramework.Core.SourceGenerators.Abstractions.Rule; - namespace GFramework.SourceGenerators.Abstractions.Rule + namespace GFramework.Core.SourceGenerators.Abstractions.Rule { [AttributeUsage(AttributeTargets.Class, Inherited = false)] public sealed class GetAllAttribute : Attribute { } @@ -753,9 +753,9 @@ public class ContextGetGeneratorTests { var source = """ using System; - using GFramework.SourceGenerators.Abstractions.Rule; + using GFramework.Core.SourceGenerators.Abstractions.Rule; - namespace GFramework.SourceGenerators.Abstractions.Rule + namespace GFramework.Core.SourceGenerators.Abstractions.Rule { [AttributeUsage(AttributeTargets.Class, Inherited = false)] public sealed class ContextAwareAttribute : Attribute { } @@ -845,9 +845,9 @@ public class ContextGetGeneratorTests { var source = """ using System; - using GFramework.SourceGenerators.Abstractions.Rule; + using GFramework.Core.SourceGenerators.Abstractions.Rule; - namespace GFramework.SourceGenerators.Abstractions.Rule + namespace GFramework.Core.SourceGenerators.Abstractions.Rule { [AttributeUsage(AttributeTargets.Field, Inherited = false)] public sealed class GetServiceAttribute : Attribute { } @@ -922,9 +922,9 @@ public class ContextGetGeneratorTests { var source = MarkupTestSource.Parse(""" using System; - using GFramework.SourceGenerators.Abstractions.Rule; + using GFramework.Core.SourceGenerators.Abstractions.Rule; - namespace GFramework.SourceGenerators.Abstractions.Rule + namespace GFramework.Core.SourceGenerators.Abstractions.Rule { [AttributeUsage(AttributeTargets.Field, Inherited = false)] public sealed class GetModelAttribute : Attribute { } @@ -989,9 +989,9 @@ public class ContextGetGeneratorTests var source = MarkupTestSource.Parse(""" using System; using System.Collections.Generic; - using GFramework.SourceGenerators.Abstractions.Rule; + using GFramework.Core.SourceGenerators.Abstractions.Rule; - namespace GFramework.SourceGenerators.Abstractions.Rule + namespace GFramework.Core.SourceGenerators.Abstractions.Rule { [AttributeUsage(AttributeTargets.Field, Inherited = false)] public sealed class GetModelsAttribute : Attribute { } @@ -1060,9 +1060,9 @@ public class ContextGetGeneratorTests { var source = MarkupTestSource.Parse(""" using System; - using GFramework.SourceGenerators.Abstractions.Rule; + using GFramework.Core.SourceGenerators.Abstractions.Rule; - namespace GFramework.SourceGenerators.Abstractions.Rule + namespace GFramework.Core.SourceGenerators.Abstractions.Rule { [AttributeUsage(AttributeTargets.Field, Inherited = false)] public sealed class GetModelAttribute : Attribute { } @@ -1131,9 +1131,9 @@ public class ContextGetGeneratorTests { var source = MarkupTestSource.Parse(""" using System; - using GFramework.SourceGenerators.Abstractions.Rule; + using GFramework.Core.SourceGenerators.Abstractions.Rule; - namespace GFramework.SourceGenerators.Abstractions.Rule + namespace GFramework.Core.SourceGenerators.Abstractions.Rule { [AttributeUsage(AttributeTargets.Field, Inherited = false)] public sealed class GetModelAttribute : Attribute { } @@ -1203,9 +1203,9 @@ public class ContextGetGeneratorTests var source = """ using System; using System.Collections.Generic; - using GFramework.SourceGenerators.Abstractions.Rule; + using GFramework.Core.SourceGenerators.Abstractions.Rule; - namespace GFramework.SourceGenerators.Abstractions.Rule + namespace GFramework.Core.SourceGenerators.Abstractions.Rule { [AttributeUsage(AttributeTargets.Field, Inherited = false)] public sealed class GetModelsAttribute : Attribute { } diff --git a/docs/zh-CN/source-generators/index.md b/docs/zh-CN/source-generators/index.md index c1d65128..1b4638d1 100644 --- a/docs/zh-CN/source-generators/index.md +++ b/docs/zh-CN/source-generators/index.md @@ -89,10 +89,10 @@ GFramework 的 source generators 利用 Roslyn 源代码生成器技术,在编 - - @@ -102,6 +102,7 @@ GFramework 的 source generators 利用 Roslyn 源代码生成器技术,在编 如果你只使用 Godot 生成器或 CQRS 处理器注册生成器,请把上面的包替换为对应的 `GeWuYou.GFramework.Godot.SourceGenerators` 或 `GeWuYou.GFramework.Cqrs.SourceGenerators`。 这些拆分包会同时带上各自需要的 abstractions 程序集,不需要再额外安装单独的 `*.Attributes` 包。 +实际接入时请替换为当前发布版本,或与项目中其余 `GeWuYou.GFramework.*` 包保持同一版本。 ### Config Schema 文件约定 @@ -1235,11 +1236,14 @@ public partial class ServiceComponent : IService ```mermaid graph TD - A[GFramework.SourceGenerators] --> B[GFramework.Core.SourceGenerators.Abstractions] + A[GeWuYou.GFramework.Core.SourceGenerators] --> B[GFramework.Core.SourceGenerators.Abstractions] A --> C[GFramework.SourceGenerators.Common] A --> D[GFramework.Core.Abstractions] A --> E[Microsoft.CodeAnalysis.CSharp] A --> F[Microsoft.CodeAnalysis.Analyzers] + G[GeWuYou.GFramework.Game.SourceGenerators] --> C + H[GeWuYou.GFramework.Godot.SourceGenerators] --> C + I[GeWuYou.GFramework.Cqrs.SourceGenerators] --> C ``` ## 版本兼容性