docs(source-generators): 添加源代码生成器文档和相关常量定义

- 新增完整的 GFramework.SourceGenerators 文档,涵盖所有核心特性
- 添加 Log 属性生成器、Config Schema 生成器等详细使用说明
- 添加 ContextAware、GenerateEnumExtensions 等属性生成器文档
- 添加 Godot 专用生成器如 GetNode、BindNodeSignal 等使用指南
- 添加 AutoRegisterModule、AutoUiPage、AutoScene 等自动化工具文档
- 添加诊断信息、性能优势、使用示例和最佳实践章节
- 新增 PathContests 常量类定义 GFramework 项目路径常量
- 添加 ContextRegistrationAnalyzerTests 测试类验证上下文注册分析器
This commit is contained in:
GeWuYou 2026-04-16 21:40:47 +08:00
parent 9f9a421b6c
commit 534818f5f6
9 changed files with 90 additions and 86 deletions

View File

@ -39,7 +39,7 @@ public static class PathContests
/// <summary>
/// GFramework源代码生成器抽象层命名空间
/// </summary>
public const string SourceGeneratorsAbstractionsPath = $"{BaseNamespace}.SourceGenerators.Abstractions";
public const string SourceGeneratorsAbstractionsPath = $"{CoreNamespace}.SourceGenerators.Abstractions";
/// <summary>
/// GFramework Godot源代码生成器抽象层命名空间

View File

@ -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 { }

View File

@ -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 { }

View File

@ -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<T>

View File

@ -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

View File

@ -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<T>

View File

@ -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]

View File

@ -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 { }

View File

@ -89,10 +89,10 @@ GFramework 的 source generators 利用 Roslyn 源代码生成器技术,在编
</PropertyGroup>
<ItemGroup>
<PackageReference Include="GeWuYou.GFramework.Core.SourceGenerators" Version="1.0.0"
<PackageReference Include="GeWuYou.GFramework.Core.SourceGenerators"
PrivateAssets="all"
ExcludeAssets="runtime" />
<PackageReference Include="GeWuYou.GFramework.Game.SourceGenerators" Version="1.0.0"
<PackageReference Include="GeWuYou.GFramework.Game.SourceGenerators"
PrivateAssets="all"
ExcludeAssets="runtime" />
</ItemGroup>
@ -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
```
## 版本兼容性