System.Speech, System.CodeDom and two MEF packages ship IsAotCompatible=True despite IsTrimmable=false, so IL3058 misses them
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 76/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- csharp
- 领域
- build-system, devtools
调研方向
阅读报告中列出的四个项目文件:System.Speech、System.CodeDom 和 System.ComponentModel.Composition.Registration 的 Directory.Build.props 文件,以及 System.Composition.Convention.csproj。检查同类项目如何将 IsAotCompatible 与 IsTrimmable 一起配置,然后一致地将这些项目排除在外。完成标准是它们的包元数据不再声称兼容 AOT,并且报告中的使用方复现会同时产生 IL3058 和 IL2125。
由索引模型根据 Issue 内容生成。
描述
Description
System.Speech, System.CodeDom, System.Composition.Convention and System.ComponentModel.Composition.Registration 11.0.0 ship [assembly: AssemblyMetadata("IsAotCompatible", "True")], but their projects set IsTrimmable=false. So the opt-in reference check VerifyReferenceAotCompatibility (IL3058) treats them as AOT-compatible, while VerifyReferenceTrimCompatibility (IL2125) correctly flags them as not trimmable.
IsAotCompatibleis meant to implyIsTrimmable(#117712 comment).- Their sibling
System.ComponentModel.CompositionsetsIsTrimmable=falseandIsAotCompatible=false, and it gets both warnings, as expected. - Projects use the check as a gate: dotnet/android#13760 turns it on and treats IL3058 as an error. A gate like that lets these four through.
System.Speechuses built-in COM, which NativeAOT does not support (#88220).
Repro: https://github.com/TheCodeTraveler/runtime-aot-metadata-repro
CI run: 45935142457. The run is green only when the bug legs show the bug and the control leg is clean.
metadata: reads the metadata of the 11.0.0 packages.build-bug: consumer build that references the four packages plus two controls.build-control: same settings, controls only. Every IL2125 there has a matching IL3058.
Reproduction Steps
git clone https://github.com/TheCodeTraveler/runtime-aot-metadata-repro
cd runtime-aot-metadata-repro
dotnet build lib-bug -c Release
This needs .NET SDK 11.0.100, which global.json pins. It works on any OS.
lib-bug/BugConsumerLib.csproj is the whole repro, plus one empty class (public static class Placeholder;):
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net11.0-windows</TargetFramework>
<EnableWindowsTargeting>true</EnableWindowsTargeting>
<IsAotCompatible>true</IsAotCompatible>
<VerifyReferenceAotCompatibility>true</VerifyReferenceAotCompatibility>
<VerifyReferenceTrimCompatibility>true</VerifyReferenceTrimCompatibility>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.ComponentModel.Composition" Version="11.0.0" />
<PackageReference Include="System.DirectoryServices" Version="11.0.0" />
<PackageReference Include="System.Speech" Version="11.0.0" />
<PackageReference Include="System.CodeDom" Version="11.0.0" />
<PackageReference Include="System.Composition.Convention" Version="11.0.0" />
<PackageReference Include="System.ComponentModel.Composition.Registration" Version="11.0.0" />
</ItemGroup>
</Project>
The first two references are the controls. Both are correctly opted out.
Expected behavior
- The four packages don't claim
IsAotCompatible, just like their siblingSystem.ComponentModel.Composition. - A consumer with
VerifyReferenceAotCompatibilitygets IL3058 for each of them, next to IL2125.
Actual behavior
Package metadata, from the metadata job:
| 11.0.0 package | IsAotCompatible |
IsTrimmable |
|---|---|---|
| System.Speech (lib and runtimes/win) | True | absent |
| System.CodeDom | True | absent |
| System.Composition.Convention | True | absent |
| System.ComponentModel.Composition.Registration | True | absent |
| System.ComponentModel.Composition (control) | absent | absent |
| System.DirectoryServices (control) | absent | True |
The build-bug job succeeds with 8 warnings (paths trimmed below). All four packages get IL2125, and none of them gets IL3058:
CSC : warning IL3058: Referenced assembly 'System.ComponentModel.Composition' is not built with `true` and may not be compatible with AOT.
CSC : warning IL3058: Referenced assembly 'System.DirectoryServices' is not built with `true` and may not be compatible with AOT.
CSC : warning IL3058: Referenced assembly 'System.Reflection.Context' is not built with `true` and may not be compatible with AOT.
CSC : warning IL2125: Referenced assembly 'System.CodeDom' is not built with `true` and may not be compatible with trimming.
CSC : warning IL2125: Referenced assembly 'System.ComponentModel.Composition' is not built with `true` and may not be compatible with trimming.
CSC : warning IL2125: Referenced assembly 'System.ComponentModel.Composition.Registration' is not built with `true` and may not be compatible with trimming.
CSC : warning IL2125: Referenced assembly 'System.Composition.Convention' is not built with `true` and may not be compatible with trimming.
CSC : warning IL2125: Referenced assembly 'System.Speech' is not built with `true` and may not be compatible with trimming.
System.Reflection.Context is a dependency of Registration, and it is correctly opted out.
Regression?
No. It has been wrong since the metadata first shipped:
- The
IsAotCompatiblemetadata is new in .NET 10 (#118008), and #118149 set the default in the same release. - 10.0.x packages carry the same claim. I checked System.Speech 10.0.11, System.CodeDom 10.0.9 and System.Composition.Convention 10.0.10.
Known Workarounds
None for consumers, because the claim is compiled into the shipped assemblies.
Configuration
- .NET SDK 11.0.100 (pinned with
rollForward: disable), packages 11.0.0. - Consumer TFM
net11.0-windowswithEnableWindowsTargeting. - CI ran on GitHub's
ubuntu-latest(Ubuntu 26.04.1 LTS). A local macOS build that referenced System.Speech, System.CodeDom and System.DirectoryServices gave the same result. - It doesn't depend on the OS or architecture, because the claim is in the package.
- dotnet/runtime main
ab35cfe2(2026-11-26) still has it.
Other information
Root cause. Permalinks are at main ab35cfe2. The v11.0.0 tag has the same code, with the default at Directory.Build.props L57.
src/libraries/Directory.Build.propsdefaultsIsAotCompatible=truefor src and ref projects (L65-L66; #118149, #118222).- The four projects set only
IsTrimmable=false: - #118149 changed
EnableAOTAnalyzer=falsetoIsAotCompatible=falsein the projects that had it.- That is how the siblings System.ComponentModel.Composition, System.Composition.Hosting, System.Composition.TypedParts and System.Configuration.ConfigurationManager got opted out (example).
- These four never had
EnableAOTAnalyzer=false, so they kept the new default.
Microsoft.NET.ILLink.targetsemits each metadata entry from its own property (L24-L31). The result isIsAotCompatible=Truewith noIsTrimmable.- The analyzer accepts any reference whose metadata says
True: RequiresDynamicCodeAnalyzer.cs L182-L186 calls RequiresAnalyzerBase.cs L414-L445.
Recommended fix: opt the four out, the same way #118149 and #118222 opted out their siblings.
- Three of the four have ref projects, so their opt-out goes in the shared
Directory.Build.props. - The diff applies cleanly to main
ab35cfe2(git apply --check). - I did not build dotnet/runtime with it. The control sibling
System.ComponentModel.Compositionalready ships this exact pairing, and the repro shows the result: no AOT claim, and IL3058 fires.
Diff
diff --git a/src/libraries/System.CodeDom/Directory.Build.props b/src/libraries/System.CodeDom/Directory.Build.props
--- a/src/libraries/System.CodeDom/Directory.Build.props
+++ b/src/libraries/System.CodeDom/Directory.Build.props
@@ -4,5 +4,6 @@
<IncludePlatformAttributes>true</IncludePlatformAttributes>
<UnsupportedOSPlatforms>browser;wasi;ios;tvos;maccatalyst</UnsupportedOSPlatforms>
<IsTrimmable>false</IsTrimmable>
+ <IsAotCompatible>false</IsAotCompatible>
</PropertyGroup>
</Project>
\ No newline at end of file
diff --git a/src/libraries/System.ComponentModel.Composition.Registration/Directory.Build.props b/src/libraries/System.ComponentModel.Composition.Registration/Directory.Build.props
--- a/src/libraries/System.ComponentModel.Composition.Registration/Directory.Build.props
+++ b/src/libraries/System.ComponentModel.Composition.Registration/Directory.Build.props
@@ -3,5 +3,6 @@
<PropertyGroup>
<StrongNameKeyId>ECMA</StrongNameKeyId>
<IsTrimmable>false</IsTrimmable>
+ <IsAotCompatible>false</IsAotCompatible>
</PropertyGroup>
</Project>
diff --git a/src/libraries/System.Composition.Convention/src/System.Composition.Convention.csproj b/src/libraries/System.Composition.Convention/src/System.Composition.Convention.csproj
--- a/src/libraries/System.Composition.Convention/src/System.Composition.Convention.csproj
+++ b/src/libraries/System.Composition.Convention/src/System.Composition.Convention.csproj
@@ -3,6 +3,7 @@
<PropertyGroup>
<TargetFrameworks>$(NetCoreAppCurrent);$(NetCoreAppPrevious);$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum)</TargetFrameworks>
<IsTrimmable>false</IsTrimmable>
+ <IsAotCompatible>false</IsAotCompatible>
<StrongNameKeyId>Microsoft</StrongNameKeyId>
<UseCompilerGeneratedDocXmlFile>false</UseCompilerGeneratedDocXmlFile>
<IsPackable>true</IsPackable>
diff --git a/src/libraries/System.Speech/Directory.Build.props b/src/libraries/System.Speech/Directory.Build.props
--- a/src/libraries/System.Speech/Directory.Build.props
+++ b/src/libraries/System.Speech/Directory.Build.props
@@ -4,5 +4,6 @@
<StrongNameKeyId>MicrosoftShared</StrongNameKeyId>
<SupportedOSPlatforms>windows</SupportedOSPlatforms>
<IsTrimmable>false</IsTrimmable>
+ <IsAotCompatible>false</IsAotCompatible>
</PropertyGroup>
</Project>
\ No newline at end of file
- Optional guard (untested idea): a build check that fails when
IsAotCompatibleistrueandIsTrimmableisfalsewould keep this from coming back. Microsoft.XmlSerializer.Generator.csprojalso sets onlyIsTrimmable=false, so it gets the same default. It is an Exe tool, so no compilation references it and it is left out of the diff.
Related
- #117712, #118008, #118149, #118222 and #118180 added the metadata, the default and the check.
- System.Management 11.0.0 claims both
IsTrimmableandIsAotCompatible, but it uses built-in COM (#61960, #88220). It may be worth a look in the same pass. - For context only: we found this while chasing a crash in a fully trimmed app with
BuiltInComInteropSupport=true, where trimming removed[ComImport]interface methods from System.Speech. That is the known, unsupported mix of built-in COM and trimming (dotnet/linker#936, #101128), so it is not part of this report. - Side note: IL2125 and IL3058 print "is not built with `true`". The cause is that SharedStrings.resx L1288 and L1294 put unescaped
<IsTrimmable>and<IsAotCompatible>tags inside<value>. Other entries in that file escape their tags (<safety>).
[!NOTE]
Drafted and posted by Brandon's Claude (AI) on Brandon's behalf.
- 主要语言
- C#
- 星标
- 18.5k
- 派生
- 5.8k
- 平均合并
- 2 天 11 小时
- 30 天内合并 PR
- 607
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
dotnet/runtime 的其他 Issue
-
CookieContainer: when a Set-Cookie has both Expires and Max-Age, the first one wins instead of Max-Age可能已有人在做 @darrellchee 于 1 天前认领。 未关闭area-System.Net bug
难度 2/5 1-3 小时 新手友好度 74/100
dotnet/runtime#138251 · 2 条评论 ·
维护者通常 1 天内回复
-
JIT: Checked `emitExtractEvexPrefix` asserts on AVX10v1 FP16 instructions with no SIMD prefix (`vrndscalesh`, `vcmpph`, ...)可能已有人在做 @dhartglassMSFT 于 1 天前认领。 未关闭area-CodeGen-coreclr untriaged
难度 2/5 1-3 小时 新手友好度 65/100
dotnet/runtime#138181 · 1 条评论 ·
维护者通常 1 天内回复
-
area-System.Collections untriaged
难度 2/5 1-3 小时 新手友好度 82/100
dotnet/runtime#138090 · 1 条评论 ·
维护者通常 1 天内回复
-
area-System.Text.Json untriaged
难度 2/5 1-3 小时 新手友好度 72/100
dotnet/runtime#138089 · 1 条评论 ·
维护者通常 1 天内回复
-
area-Setup untriaged
难度 2/5 1-3 小时 新手友好度 76/100
dotnet/runtime#137376 · 1 条评论 ·
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
Facepunch/sbox-public#12456 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 84/100
mcneel/rhino.inside-revit#1736 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
reactiveui/Primitives#254 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 76/100
Kyrodan/KeeAnywhere#510 ·
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复