Asteroid.CodeBuilder
1.1.0
.NET 10.0
This package targets .NET 10.0. The package is compatible with this framework or higher.
.NET Standard 2.0
This package targets .NET Standard 2.0. The package is compatible with this framework or higher.
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Asteroid.CodeBuilder --version 1.1.0
NuGet\Install-Package Asteroid.CodeBuilder -Version 1.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="Asteroid.CodeBuilder" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Asteroid.CodeBuilder" Version="1.1.0" />
<PackageReference Include="Asteroid.CodeBuilder" />
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 Asteroid.CodeBuilder --version 1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Asteroid.CodeBuilder, 1.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 Asteroid.CodeBuilder@1.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=Asteroid.CodeBuilder&version=1.1.0
#tool nuget:?package=Asteroid.CodeBuilder&version=1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Asteroid.CodeBuilder
Asteroid.CodeBuilder 通过结构化 fluent 节点 API 构建 C# 源码,面向 Roslyn 生成器和可选
编辑器工具。
包以 netstandard2.0 兼容编译器宿主,以 net10.0 支持当前外部工具和编辑器 addon。
它不依赖 Asteroid 运行时模块或 Godot。
游戏运行时项目不直接引用此包。分析器和生成器包可以将 netstandard2.0 程序集作为编译器
宿主依赖携带。
上手路径
FileBuilder.New(hintName)起文件,builder.Root.Using(ns)/FileNamespace(ns)声明头部;Decl.*/builder.Root.Class(...)声明类型与成员,CodeNodeExtensions(AsPublic、WithGet、Implement、Inherit等)配置修饰与成员;- 方法体走
St.*语句节点(St.Line/St.If/St.For/St.While/St.Block),表达式走Exp.*节点(Exp.Invoke/Exp.Assign/Exp.New/Exp.Ternary/运算符族等); builder.ToCode(cancellationToken)出文本。
可执行示例见仓库 examples/CodeBuilder/(dotnet run --example <name>,含生成产物校验):
FullPropertyExample 属性全形态、GeneratorPathExample 生成器推荐路径。
表达式字符串纪律
表达式字符串始终显式构造:标识符使用 Exp.Id,字符串字面量使用 Exp.String,只有
有意插入原始源码时才使用 Exp.Raw。string 永不隐式转换为 ExpNode。
- 字面量转义归发射器:字符串/字符字面量的内容转义由 CodeBuilder 负责(普通模式转义反斜杠/引号/控制字符;逐字模式双引号翻倍;原始字符串自动垫高定界符过引号连击)——含
\ | ; " 换行等毒字符的内容直接传Exp.String即可,无需调用方预处理。插值串的花括号视为有意插值孔,不转义。 Exp.Raw只留给无节点形态的叶子(default!、关键字、已解析的类型名 token); 含运算符/调用/构造/强转的语法串必须节点化。
语义陷阱速查
Property构造即带 get+set:只配WithGet会留下空 set——get-only 用GetterProperty或显式Setter.Enabled = false;Exp.Line自带行尾分号:Raw片段自带;会叠加成;;;Exp.Raw多行内容只缩进首行:整段方法体必须走St.*节点树;Exp.New恒带参数括号:定长数组用Exp.NewArrayByType(Exp.SizedArrayType(...));- 特性名渲染剥
Attribute后缀(XxxAttribute→[Xxx]); - 指名实参形态随宿主切换:方法
name:,特性name =; - 基类走
Inherit(Implement是接口族),单接口同行需InheritImplementGroup.MultiLine = false; - 类型名必须结构化(
Exp.Namespace(ns).Qa(...)/TypeNameRecord),字符串路径不参与 NameScopes 简化。
机制详解(构建生命周期、NameScopes、发射纪律)见 DESIGN.md。
| Product | Versions 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 is compatible. 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.
-
net10.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 |
|---|---|---|
| 3.1.0 | 47 | 11/18/2026 |
| 2.0.0 | 112 | 10/26/2026 |
| 1.9.0 | 117 | 10/17/2026 |
| 1.8.0 | 124 | 10/13/2026 |
| 1.7.0 | 112 | 10/6/2026 |
| 1.6.0 | 119 | 9/27/2026 |
| 1.5.0 | 113 | 9/25/2026 |
| 1.4.0 | 107 | 9/25/2026 |
| 1.3.0 | 111 | 9/25/2026 |
| 1.2.1 | 127 | 9/12/2026 |
| 1.2.0 | 131 | 9/10/2026 |
| 1.1.0 | 134 | 9/8/2026 |
| 1.0.7 | 136 | 9/8/2026 |
| 1.0.6 | 123 | 8/30/2026 |
| 1.0.5 | 138 | 8/21/2026 |
| 1.0.4 | 131 | 8/13/2026 |
| 1.0.3 | 127 | 8/13/2026 |
| 1.0.2 | 145 | 5/16/2026 |
| 1.0.1 | 152 | 5/15/2026 |
| 1.0.0 | 136 | 5/15/2026 |