mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-03-23 11:14:30 +08:00
This PR refactors a lambda expression that contained unnecessary braces around a single-statement body, converting it into a more concise expression-bodied form to improve readability and maintainability. - Consider simplifying lambda when its body has a single statement: The original lambda used a block body with braces and a single call to Execute, which is verbose for a one-line operation. We removed the braces and semicolon, converting it into an expression-bodied lambda (`static (spc, pair) => Execute(spc, pair.Left, pair.Right)`) to simplify the code and follow best practices. > This Autofix was generated by AI. Please review the change before merging.
GFramework.Godot.SourceGenerators
面向 Godot 场景的源码生成扩展模块,减少模板代码。
主要功能
- 与 Godot 场景相关的编译期生成能力
- 基于 Roslyn 的增量生成器实现
[GetNode]字段注入,减少_Ready()里的GetNode<T>()样板代码
使用建议
- 仅在 Godot + C# 项目中启用
- 非 Godot 项目可只使用 GFramework.SourceGenerators
GetNode 用法
using GFramework.Godot.SourceGenerators.Abstractions;
using Godot;
public partial class TopBar : HBoxContainer
{
[GetNode]
private HBoxContainer _leftContainer = null!;
[GetNode]
private HBoxContainer _rightContainer = null!;
public override void _Ready()
{
__InjectGetNodes_Generated();
OnReadyAfterGetNode();
}
private void OnReadyAfterGetNode()
{
}
}
当未显式填写路径时,生成器会默认将字段名推导为唯一名路径:
_leftContainer->%LeftContainerm_rightContainer->%RightContainer