<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-Hans-CN">
	<id>https://wiki2.lessokaji.com/index.php?action=history&amp;feed=atom&amp;title=LessokajiWeaver%E7%BC%96%E8%AF%91%E5%90%8E%E5%A4%84%E7%90%86%E5%B7%A5%E5%85%B7</id>
	<title>LessokajiWeaver编译后处理工具 - 版本历史</title>
	<link rel="self" type="application/atom+xml" href="https://wiki2.lessokaji.com/index.php?action=history&amp;feed=atom&amp;title=LessokajiWeaver%E7%BC%96%E8%AF%91%E5%90%8E%E5%A4%84%E7%90%86%E5%B7%A5%E5%85%B7"/>
	<link rel="alternate" type="text/html" href="https://wiki2.lessokaji.com/index.php?title=LessokajiWeaver%E7%BC%96%E8%AF%91%E5%90%8E%E5%A4%84%E7%90%86%E5%B7%A5%E5%85%B7&amp;action=history"/>
	<updated>2026-05-16T16:09:32Z</updated>
	<subtitle>本wiki上该页面的版本历史</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://wiki2.lessokaji.com/index.php?title=LessokajiWeaver%E7%BC%96%E8%AF%91%E5%90%8E%E5%A4%84%E7%90%86%E5%B7%A5%E5%85%B7&amp;diff=1018&amp;oldid=prev</id>
		<title>Artheru：​Initial bilingual draft (auto-published)</title>
		<link rel="alternate" type="text/html" href="https://wiki2.lessokaji.com/index.php?title=LessokajiWeaver%E7%BC%96%E8%AF%91%E5%90%8E%E5%A4%84%E7%90%86%E5%B7%A5%E5%85%B7&amp;diff=1018&amp;oldid=prev"/>
		<updated>2026-05-16T11:42:52Z</updated>

		<summary type="html">&lt;p&gt;Initial bilingual draft (auto-published)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;languages/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 概述 / Overview ==&lt;br /&gt;
LessokajiWeaver 是 MDCS 用到的 ''编译后处理''工具链（基于 Fody）。它在 C# 程序集编译完成后做 IL 注入，自动生成 ''字段代理类''、''属性序列化代码''、''反射加速''等基础设施代码，让插件作者只需写少量声明性属性，剩下的&amp;quot;管道&amp;quot;由 Weaver 自动织入。&lt;br /&gt;
&lt;br /&gt;
LessokajiWeaver is MDCS's post-compile IL-weaving toolchain (Fody-based). It runs after C# assembly compilation and injects IL to generate ''field-proxy classes'', ''property serialisation'', ''reflection accelerators'', etc. Plugin authors write a few declarative attributes; the plumbing is woven in automatically.&lt;br /&gt;
&lt;br /&gt;
== 主要场景 / Main scenarios ==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! 场景 / Scenario !! Weaver 做的 / What Weaver does&lt;br /&gt;
|-&lt;br /&gt;
| Medulla `[AsUpperIO]` / `[AsLowerIO]` 字段 || 生成代理 setter / getter，自动同步到 DObject&lt;br /&gt;
|-&lt;br /&gt;
| Medulla `[AsInitParam]` || 生成 JSON 序列化代码，绑定到启动配置加载&lt;br /&gt;
|-&lt;br /&gt;
| Medulla `[IOObjectMonitor]` || 注册到监控面板 + Web API&lt;br /&gt;
|-&lt;br /&gt;
| CycleGUI `[Cyclic]` 协程方法 || 自动包装为 IEnumerable&amp;lt;Cycle&amp;gt; 安全宿主&lt;br /&gt;
|-&lt;br /&gt;
| Clumsy `[MovementTest]` || 注册到测试 UI 面板&lt;br /&gt;
|-&lt;br /&gt;
| 多语言（i18n）字符串字段 || 生成查表逻辑（见 [[Special:MyLanguage/自动I18N（多语言功能）|自动 I18N]]）&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== 工作流程 / Pipeline ==&lt;br /&gt;
&lt;br /&gt;
  开发者 .cs → csc 编译 → .dll&lt;br /&gt;
                              │&lt;br /&gt;
                              ▼&lt;br /&gt;
                LessokajiWeaver.Fody (post-build)&lt;br /&gt;
                              │&lt;br /&gt;
                              ▼&lt;br /&gt;
                         织入后的 .dll&lt;br /&gt;
                              │&lt;br /&gt;
                              ▼&lt;br /&gt;
                   Medulla / Clumsy 运行时加载&lt;br /&gt;
&lt;br /&gt;
工程引用方式（已由 [[Special:MyLanguage/MDCS-plugin-helper|MDCS-plugin-helper]] 模板自动配置）：&lt;br /&gt;
&lt;br /&gt;
In a plugin's .csproj (auto-configured by the plugin-helper template):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;ItemGroup&amp;gt;&lt;br /&gt;
  &amp;lt;PackageReference Include=&amp;quot;Fody&amp;quot; Version=&amp;quot;6.x&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;Reference Include=&amp;quot;LessokajiWeaver.Fody&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;HintPath&amp;gt;..\tools\LessokajiWeaver.Fody.dll&amp;lt;/HintPath&amp;gt;&lt;br /&gt;
  &amp;lt;/Reference&amp;gt;&lt;br /&gt;
  &amp;lt;Reference Include=&amp;quot;LessokajiWeaverUtilities&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;HintPath&amp;gt;..\tools\LessokajiWeaverUtilities.dll&amp;lt;/HintPath&amp;gt;&lt;br /&gt;
  &amp;lt;/Reference&amp;gt;&lt;br /&gt;
&amp;lt;/ItemGroup&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
`FodyWeavers.xml` 在工程根目录：&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;Weavers&amp;gt;&lt;br /&gt;
  &amp;lt;LessokajiWeaver/&amp;gt;&lt;br /&gt;
&amp;lt;/Weavers&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 为什么用 Weaver / Why weave ==&lt;br /&gt;
不用 Weaver 也能用反射做同样的事，但每次访问字段都付反射开销（~100x getter）。Weaver 在编译期把反射调用 ''变成普通 IL''，运行时零开销：&lt;br /&gt;
&lt;br /&gt;
Without Weaver you'd use reflection at runtime, paying ~100× cost per access. Weaver moves the reflection to compile-time, generating direct IL with zero runtime overhead:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
// 开发者写：&lt;br /&gt;
[AsUpperIO]&lt;br /&gt;
public float vCmd;&lt;br /&gt;
&lt;br /&gt;
// 编译后 Weaver 注入相当于：&lt;br /&gt;
private float _vCmd;&lt;br /&gt;
public float vCmd&lt;br /&gt;
{&lt;br /&gt;
    get =&amp;gt; _vCmd;&lt;br /&gt;
    set&lt;br /&gt;
    {&lt;br /&gt;
        _vCmd = value;&lt;br /&gt;
        IOSync.PostToDObject(this, &amp;quot;vCmd&amp;quot;, value);  // 自动 IPC&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 调试 / Debugging ==&lt;br /&gt;
* 织入失败：检查 `bin\&amp;lt;config&amp;gt;\` 下是否有 `FodyWeavers.xml` 编译报错；通常是属性用法错误（如把 `[AsUpperIO]` 加在 readonly 字段上）。&lt;br /&gt;
* 织入产物可视化：用 ILSpy / dnSpy 打开织入后的 dll，查看 setter / getter 注入逻辑。&lt;br /&gt;
* 性能 / Performance: Weaver 不引入额外运行时依赖；增加的体积通常 &amp;lt; 5%。&lt;br /&gt;
&lt;br /&gt;
== 兼容性 / Compatibility ==&lt;br /&gt;
* .NET Framework 4.6.2+ / .NET 6+&lt;br /&gt;
* 必须用 ''Release 模式''发布插件（Weaver 在 Debug 也运行，但 Debug 会保留更多调试符号导致体积偏大）。&lt;br /&gt;
* 与 ''AOT 编译''不兼容（IL 注入依赖 JIT）。&lt;br /&gt;
&lt;br /&gt;
== 与 LessokajiWeaverUtilities 的关系 / Utilities ==&lt;br /&gt;
`LessokajiWeaverUtilities.dll` 是 Weaver 注入代码运行时依赖的小库（attribute 定义 + 工具方法）。插件 csproj 必须引用，但开发者一般不直接调用。&lt;br /&gt;
&lt;br /&gt;
`LessokajiWeaverUtilities.dll` is the runtime support library (attribute definitions + helpers). Plugin csproj must reference it but developers rarely call into it directly.&lt;br /&gt;
&lt;br /&gt;
== 相关页面 / See also ==&lt;br /&gt;
* [[Special:MyLanguage/Medulla|Medulla]] / [[Special:MyLanguage/Medulla软件架构|Medulla软件架构]]&lt;br /&gt;
* [[Special:MyLanguage/自动I18N（多语言功能）|自动I18N（多语言功能）]]&lt;br /&gt;
* [[Special:MyLanguage/如何使用LessokajiWeaver的多语言功能|如何使用LessokajiWeaver的多语言功能]]&lt;br /&gt;
* [[Special:MyLanguage/MDCS引擎适配机器人入门教学|MDCS引擎适配机器人入门教学]]&lt;br /&gt;
&lt;br /&gt;
[[Category:二次开发相关说明]]&lt;/div&gt;</summary>
		<author><name>Artheru</name></author>
	</entry>
</feed>