GodotDataEditor.Attributes 0.1.0

dotnet add package GodotDataEditor.Attributes --version 0.1.0
                    
NuGet\Install-Package GodotDataEditor.Attributes -Version 0.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="GodotDataEditor.Attributes" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GodotDataEditor.Attributes" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="GodotDataEditor.Attributes" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add GodotDataEditor.Attributes --version 0.1.0
                    
#r "nuget: GodotDataEditor.Attributes, 0.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package GodotDataEditor.Attributes@0.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=GodotDataEditor.Attributes&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=GodotDataEditor.Attributes&version=0.1.0
                    
Install as a Cake Tool

GodotDataEditor

数据编辑器的独立工具链(与任何游戏项目解耦):扫描 C# 程序集 → 产出 schema.json → 由 Godot 侧的 GDScript 编辑器消费。

src/GodotDataEditor.Attributes   共享元数据标记 + profile 契约(netstandard2.0,游戏 / mod / 扫描器都引用它)
src/GodotDataEditor.Scanner      扫描器 CLI(net10.0,不引用任何游戏项目)
samples/GodotDataEditor.SampleTarget   冒烟用的样例目标(自带类别 + profile)

为什么是两个独立项目

  1. 标记要共享:游戏的数据类、mod 自带的数据类、扫描器都要认同一套 [DataCategory] / [DataParam] / [DataName] / …。 放在游戏项目里,mod 与扫描器就得引用游戏工程(把它们拖在一起); 放在这里、netstandard2.0,任何 TFM 都能引用,且它是纯声明,没有运行时设施。
  2. 扫描器必须外置:它要在编辑器进程之外跑(引目标程序集的元数据 → 写 JSON)。 一旦它长在编辑器里,改 C# 就会触发编辑器重载 —— 这正是老数据编辑器那一堆热重载/卸载问题的根源。

作为 NuGet 包使用

两个包发布在 nuget.org:

包 用途
GodotDataEditor.Attributes 共享元数据标记([DataCategory]/[DataParam]/[DataName]/[DataTip] …)与 profile 契约;纯声明,netstandard2.0
GodotDataEditor.Scanner 扫描器(工具包:运行输出在 tools/net10.0/,不产 lib/,不能被当作库引用)
<ItemGroup>
  <PackageReference Include="GodotDataEditor.Attributes" Version="0.1.0" />
  
  <PackageReference Include="GodotDataEditor.Scanner" Version="0.1.0">
    <PrivateAssets>all</PrivateAssets>
    <GeneratePathProperty>true</GeneratePathProperty>
  </PackageReference>
</ItemGroup>

在构建期生成 schema(Inputs/Outputs 交给 MSBuild 判增量,没改数据类就一秒都不多花):

<Target Name="GenerateDataSchema" AfterTargets="Build"
        Inputs="$(TargetPath)" Outputs="$(MSBuildProjectDirectory)/Data/schema.json">
  <Exec Command="dotnet &quot;$(PkgGodotDataEditor_Scanner)/tools/net10.0/GodotDataEditor.Scanner.dll&quot; --assembly &quot;$(TargetPath)&quot; --project &quot;$(MSBuildProjectDirectory)&quot; --out &quot;$(MSBuildProjectDirectory)/Data/schema.json&quot;" />
</Target>

⚠️ 两个包必须同版本:扫描器用强类型反射读标记(GetCustomAttribute<DataCategoryAttribute>()), 版本漂移会变成"扫描器认不出新属性成员"的静默问题(Resolve 还会按程序集名把标记统一到工具自己那一份)。

扫描器用法

# 生成(默认写到 <repoRoot>/Data/schema.json)
dotnet run --project src/GodotDataEditor.Scanner -- --assembly path/to/Game.dll --project path/to/repo

# 与仓库里的 schema 比对(CI:不一致退出码 2)
dotnet run --project src/GodotDataEditor.Scanner -- --assembly path/to/Game.dll --project path/to/repo --check

# 只跑「参数键门禁」,或跳过门禁
dotnet run --project src/GodotDataEditor.Scanner -- --assembly path/to/Game.dll --project path/to/repo --gate-only
dotnet run --project src/GodotDataEditor.Scanner -- --assembly path/to/Game.dll --project path/to/repo --no-gate

参数:

参数 说明
--assembly <目标.dll> 必填。要扫描的程序集(Debug/编辑器构建,含 XML 文档则提示更全)
--profile-type <类型名> 可选。目标程序集里实现 ISchemaProfileProvider 的类型(默认自动发现)
--project <repoRoot> 可选。仓库根(默认当前目录):决定默认输出位置与门禁扫源码的位置
--out <schema.json> 可选。输出路径
--check / --gate-only / --no-gate 见上;退出码 0 正常 / 1 门禁违规 / 2 --check 过期 / 3 用法错误

项目侧要做什么

在游戏(或 mod)程序集里实现一个 profile("本项目的数据长什么样"):

public sealed class GoRollPaSchemaProfile : ISchemaProfileProvider
{
    public SchemaProfile Profile { get; } = new()
    {
        Name = "GoRollPa",
        DataRoot = "res://Data",
        EffectSourceDir = "Script/Event/Effects",   // 参数键门禁要扫的源码目录(相对 repoRoot)
        ParamAccessorType = "EffectParams",          // 运行时按字符串键读参数的那个类型
        Choosers = [ /* 候选源:静态 API / 字面量 / 从某数据类别的字段现算 */ ],
        MemberChoosers = [ /* 哪个类型的哪个成员用哪个候选源(带声明类型,避免同名误判) */ ],
        Unions = [ /* 判别式联合:如 EffectData.Params 按 Type 切到对应 [DataParams] DTO */ ],
    };
}

扫描器只认接口,不认识任何项目类型;换项目只换这份 profile(扫描器一行不改)。

冒烟

dotnet build GodotDataEditor.slnx
dotnet run --project src/GodotDataEditor.Scanner -- \
    --assembly samples/GodotDataEditor.SampleTarget/bin/Debug/netstandard2.0/GodotDataEditor.SampleTarget.dll \
    --project samples/GodotDataEditor.SampleTarget --out samples/schema.json --no-gate

样例目标里有一个类别、一个枚举、一个私有 + [DataParam] 的成员、一个 List、一个 Dictionary —— 覆盖扫描器的主要分支。

关系图

游戏/Mod 程序集 ──引用──► GodotDataEditor.Attributes
        │                        ▲
        │(实现 ISchemaProfileProvider)                    (纯数据,无依赖)
        ▼
GodotDataEditor.Scanner ──扫描──► schema.json ──► GDScript 数据编辑器(addons/data_editor)
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0 105 10/11/2026