chore: use Mono.Cecil 0.11.6 - #24050
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates Uno’s build-time tooling to consistently use Mono.Cecil 0.11.6 (to pick up the Portable PDB compressed-integer fix) and adds diagnostics to preserve “before” copies of assemblies/symbols processed by EmbeddedResourceInjectorTask_v0.
Changes:
- Bump
Mono.Cecilpackage references across several validator/tools projects to0.11.6. - Update
Uno.UI.Tasksto useMono.Cecil 0.11.6. - Add “pre-injection” backup copies (
.bk-EmbeddedResourceInjector) for the target assembly and PDB inEmbeddedResourceInjectorTask_v0.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/Uno.XamlTrimmingValidator/Uno.XamlTrimmingValidator.csproj | Update Mono.Cecil dependency to 0.11.6. |
| src/Uno.ResourceTrimmingValidator/Uno.ResourceTrimmingValidator.csproj | Update Mono.Cecil dependency to 0.11.6. |
| src/Uno.ReferenceImplComparer/Uno.ReferenceImplComparer.csproj | Update Mono.Cecil dependency to 0.11.6. |
| src/Uno.NUnitTransformTool/Uno.NUnitTransformTool.csproj | Update Mono.Cecil dependency to 0.11.6. |
| src/SourceGenerators/Uno.UI.Tasks/Uno.UI.Tasks.csproj | Update Mono.Cecil dependency to 0.11.6 for MSBuild task assembly. |
| src/SourceGenerators/Uno.UI.Tasks/EmbeddedResourceInjector/EmbeddedResourceInjectorTask.cs | Add backup copies of the pre-modified assembly/PDB prior to resource injection. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24050/wasm-skia-net9/index.html |
|
|
Context/Duplicates: #24050 (`.pdb` files are hard, mkay?) After "chore: Update to .NET 11 Preview 7", the **Tests - Android+NativeAOT Skia > … > Build Android+NativeAOT Skia Head** step started failing: /home/AzDevOps/.nuget/packages/microsoft.dotnet.ilcompiler/11.0.0-preview.7.26381.103/build/Microsoft.NETCore.Native.targets(359,5): error MSB3073: The command ""/home/AzDevOps/.nuget/packages/runtime.linux-x64.microsoft.dotnet.ilcompiler/11.0.0-preview.7.26381.103/tools/ilc" @"obj/Release/net11.0-android/android-x64/native/SamplesApp.ilc.rsp"" exited with code 1. [/agent/_work/1/s/src/SamplesApp/SamplesApp/SamplesApp.csproj::TargetFramework=net11.0-android] EXEC : error : Invalid compressed integer. [/agent/_work/1/s/src/SamplesApp/SamplesApp/SamplesApp.csproj::TargetFramework=net11.0-android] System.BadImageFormatException: Invalid compressed integer. at System.Reflection.Throw.InvalidCompressedInteger() in /_/src/runtime/src/libraries/System.Reflection.Metadata/src/System/Reflection/Throw.cs:line 179 at System.Reflection.Metadata.SequencePointCollection.Enumerator.MoveNext() in /_/src/runtime/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/SequencePointCollection.cs:line 67 at Internal.TypeSystem.Ecma.PortablePdbSymbolReader.<GetSequencePointsForMethod>d__10.MoveNext() in /_/src/runtime/src/coreclr/tools/Common/TypeSystem/Ecma/SymbolReader/PortablePdbSymbolReader.cs:line 147 at ILCompiler.Logging.MessageOrigin..ctor(MethodIL, Int32) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/MessageOrigin.cs:line 65 at ILCompiler.Dataflow.ReflectionMethodBodyScanner.HandleGetField(MethodIL, Int32, FieldDesc) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/ReflectionMethodBodyScanner.cs:line 230 at ILCompiler.Dataflow.MethodBodyScanner.ScanStfld(MethodIL, Int32, ILOpcode, FieldDesc, Stack`1, Nullable`1[], InterproceduralState&) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/MethodBodyScanner.cs:line 1151 at ILCompiler.Dataflow.MethodBodyScanner.Scan(MethodIL, InterproceduralState&) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/MethodBodyScanner.cs:line 673 at ILCompiler.Dataflow.MethodBodyScanner.InterproceduralScan(MethodIL) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/MethodBodyScanner.cs:line 311 at ILCompiler.Dataflow.ReflectionMethodBodyScanner.InterproceduralScan(MethodIL) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/ReflectionMethodBodyScanner.cs:line 117 at ILCompiler.Dataflow.ReflectionMethodBodyScanner.ScanAndProcessReturnValue(NodeFactory, FlowAnnotations, Logger, MethodIL, List`1&) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/ReflectionMethodBodyScanner.cs:line 137 at ILCompiler.DependencyAnalysis.DataflowAnalyzedMethodNode.GetStaticDependencies(NodeFactory) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/DataflowAnalyzedMethodNode.cs:line 33 at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.GetStaticDependenciesImpl(DependencyNodeCore`1) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DependencyAnalyzer.cs:line 184 at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.ProcessMarkStack() in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DependencyAnalyzer.cs:line 261 at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.ComputeMarkedNodes() in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DependencyAnalyzer.cs:line 309 at ILCompiler.ILScanner.ILCompiler.IILScanner.Scan() in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILScanner.cs:line 157 at ILCompiler.Program.<Run>g__RunScanner|4_0(Program.<>c__DisplayClass4_0&) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler/Program.cs:line 525 at ILCompiler.Program.Run() in /_/src/runtime/src/coreclr/tools/aot/ILCompiler/Program.cs:line 594 at ILCompiler.ILCompilerRootCommand.<>c__DisplayClass263_0.<.ctor>b__0(ParseResult) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler/ILCompilerRootCommand.cs:line 319 /home/AzDevOps/.nuget/packages/microsoft.dotnet.ilcompiler/11.0.0-preview.7.26381.103/build/Microsoft.NETCore.Native.targets(359,5): error MSB3073: The command ""/home/AzDevOps/.nuget/packages/runtime.linux-x64.microsoft.dotnet.ilcompiler/11.0.0-preview.7.26381.103/tools/ilc" @"obj/Release/net11.0-android/android-arm64/native/SamplesApp.ilc.rsp"" exited with code 1. [/agent/_work/1/s/src/SamplesApp/SamplesApp/SamplesApp.csproj::TargetFramework=net11.0-android] We've seen this before! See #24050 for (many!) more details. The TL;DR is that older versions of Mono.Cecil could create "broken" `.pdb` files, which would produce `BadImageFormatException` errors such as the above when processed by `ilc`. *Part* of the fix is to update to a version of Mono.Cecil which fixes this issue: Mono.Cecil 0.11.6. (A similar issue *also* impacts illink, but simply updating Mono.Cecil within Uno appears to be enough to fix the above error.)
Fixes: #24036 Context: #23966 Context: dotnet/macios#26428 Context: dotnet/cecil#504 Context: jbevain/cecil#982 Context: jbevain/cecil@0.11.4...0.11.6 Context: jbevain/cecil@0.10.1...0.11.6 In The Beginning™ was a simple idea: why don't we have an iOS+Native AOT test stage? Thus began #23966, which promptly fell over, caught on fire, and sank into the swamp. There are two issues with #23966: 1. CI was unhappy; it errors out with …/Xamarin.Shared.targets(2073,3): error : No valid iOS code signing keys found in keychain. You need to request a codesigning certificate from https://developer.apple.com. Not sure what's happening there. It doesn't happen locally… 2. It couldn't build locally either! The initial attempt to build locally would fail in `ilc`: # note: using changes from #23966 % TFM=net11.0-ios \ NAOT=1 \ BUILD_SOURCESDIRECTORY=`pwd` \ BUILD_ARTIFACTSTAGINGDIRECTORY=`pwd`/artifacts \ sh build/test-scripts/skia-ios-uitest-build.sh … …/unoplatform/uno/src/SourceGenerators/Uno.UI.Tasks/Content/Uno.UI.Tasks.targets(487,3): warning Failed to resolve assembly `JetBrains.Annotations, Version=4242.42.42.42, Culture=neutral, PublicKeyToken=1010a0d8d6380325`: Failed to resolve assembly: 'JetBrains.Annotations, Version=4242.42.42.42, Culture=neutral, PublicKeyToken=1010a0d8d6380325' EXEC : error Sequence point value is out of range. $HOME/.nuget/packages/microsoft.dotnet.ilcompiler/11.0.0-preview.6.26359.118/build/Microsoft.NETCore.Native.targets(359,5): error MSB3073: The command ""$HOME/.nuget/packages/runtime.osx-arm64.microsoft.dotnet.ilcompiler/11.0.0-preview.6.26359.118/tools/ilc" @"obj/Release/net11.0-ios/ios-arm64/native/SamplesApp.ilc.rsp"" exited with code 1. Thus began a fair bit of investigation, some of which is mentioned in #24036 and dotnet/cecil#504. What happened was a "failure cascade": 1. The `<Csc/>` task produced a `.pdb` file. 2. Uno's `<EmbeddedResourceInjectorTask_v0/>` task would use Cecil to process the assembly and `.pdb` file from (1). Uno was using, at most, Mono.Cecil 0.11.4, which had a bug around the encoding of "compressed" integers within `.pdb` files. (This is later fixed in jbevain/cecil#982, and released as part of Mono.Cecil 0.11.6.) The updated `.pdb` file would contain "Invalid compressed integer" values. 3. Later, `illink` would run, which has it's own separate copy of Mono.Cecil -- from dotnet/cecil -- which would *also* update the `.pdb` files from (2). When `illink` ran, any "Invalid compressed integer" values would be further corrupted. 4. Later still, when `ilc` runs, it would process the `.pdb` files produced by (3), and at this point instead of "silently corrupting" data, it would error out entirely: Error: Sequence point value is out of range. System.BadImageFormatException: Sequence point value is out of range. at System.Reflection.Throw.SequencePointValueOutOfRange() in /_/src/runtime/src/libraries/System.Reflection.Metadata/src/System/Reflection/Throw.cs:line 239 at System.Reflection.Metadata.SequencePointCollection.Enumerator.MoveNext() in /_/src/runtime/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/SequencePointCollection.cs:line 86 at Internal.TypeSystem.Ecma.PortablePdbSymbolReader.<GetSequencePointsForMethod>d__10.MoveNext() in /_/src/runtime/src/coreclr/tools/Common/TypeSystem/Ecma/SymbolReader/PortablePdbSymbolReader.cs:line 147 at ILCompiler.Logging.MessageOrigin..ctor(MethodIL, Int32) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/MessageOrigin.cs:line 65 (Failure cascades are fun!) *Part* of the fix here is to update Uno to use Mono.Cecil 0.11.6, which contains the fix for reading and writing "compressed" integers in `.pdb` files. That is done here. Updating Cecil will *not* fix #23966, but is a partial prerequisite. A full fix will require dotnet/cecil#504 to be merged and released, (currently merged), `illink` updated to use dotnet/cecil#504, and *then* there's dotnet/macios#26428, in which `clang++` crashes when trying to link everything even if we get past the whole `.pdb` mess (which reportedly is fixed in the not-yet-released .NET 11 RC1). (Aside: the `.pdb` mess can be avoided by NOT USING `.pdb` FILES, e.g. buil with `-p:DebugType=none`. However, who wants to do that?) …which still leaves the original "how do we get this building on CI" question… Baby steps!
540aeb1 to
947bda0
Compare
Context/Duplicates: #24050 Context: #24036 (`.pdb` files are hard, mkay?) After "chore: Update to .NET 11 Preview 7", the **Tests - Android+NativeAOT Skia > … > Build Android+NativeAOT Skia Head** step started failing: /home/AzDevOps/.nuget/packages/microsoft.dotnet.ilcompiler/11.0.0-preview.7.26381.103/build/Microsoft.NETCore.Native.targets(359,5): error MSB3073: The command ""/home/AzDevOps/.nuget/packages/runtime.linux-x64.microsoft.dotnet.ilcompiler/11.0.0-preview.7.26381.103/tools/ilc" @"obj/Release/net11.0-android/android-x64/native/SamplesApp.ilc.rsp"" exited with code 1. [/agent/_work/1/s/src/SamplesApp/SamplesApp/SamplesApp.csproj::TargetFramework=net11.0-android] EXEC : error : Invalid compressed integer. [/agent/_work/1/s/src/SamplesApp/SamplesApp/SamplesApp.csproj::TargetFramework=net11.0-android] System.BadImageFormatException: Invalid compressed integer. at System.Reflection.Throw.InvalidCompressedInteger() in /_/src/runtime/src/libraries/System.Reflection.Metadata/src/System/Reflection/Throw.cs:line 179 at System.Reflection.Metadata.SequencePointCollection.Enumerator.MoveNext() in /_/src/runtime/src/libraries/System.Reflection.Metadata/src/System/Reflection/Metadata/PortablePdb/SequencePointCollection.cs:line 67 at Internal.TypeSystem.Ecma.PortablePdbSymbolReader.<GetSequencePointsForMethod>d__10.MoveNext() in /_/src/runtime/src/coreclr/tools/Common/TypeSystem/Ecma/SymbolReader/PortablePdbSymbolReader.cs:line 147 at ILCompiler.Logging.MessageOrigin..ctor(MethodIL, Int32) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Logging/MessageOrigin.cs:line 65 at ILCompiler.Dataflow.ReflectionMethodBodyScanner.HandleGetField(MethodIL, Int32, FieldDesc) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/ReflectionMethodBodyScanner.cs:line 230 at ILCompiler.Dataflow.MethodBodyScanner.ScanStfld(MethodIL, Int32, ILOpcode, FieldDesc, Stack`1, Nullable`1[], InterproceduralState&) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/MethodBodyScanner.cs:line 1151 at ILCompiler.Dataflow.MethodBodyScanner.Scan(MethodIL, InterproceduralState&) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/MethodBodyScanner.cs:line 673 at ILCompiler.Dataflow.MethodBodyScanner.InterproceduralScan(MethodIL) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/MethodBodyScanner.cs:line 311 at ILCompiler.Dataflow.ReflectionMethodBodyScanner.InterproceduralScan(MethodIL) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/ReflectionMethodBodyScanner.cs:line 117 at ILCompiler.Dataflow.ReflectionMethodBodyScanner.ScanAndProcessReturnValue(NodeFactory, FlowAnnotations, Logger, MethodIL, List`1&) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/Dataflow/ReflectionMethodBodyScanner.cs:line 137 at ILCompiler.DependencyAnalysis.DataflowAnalyzedMethodNode.GetStaticDependencies(NodeFactory) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/DependencyAnalysis/DataflowAnalyzedMethodNode.cs:line 33 at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.GetStaticDependenciesImpl(DependencyNodeCore`1) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DependencyAnalyzer.cs:line 184 at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.ProcessMarkStack() in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DependencyAnalyzer.cs:line 261 at ILCompiler.DependencyAnalysisFramework.DependencyAnalyzer`2.ComputeMarkedNodes() in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.DependencyAnalysisFramework/DependencyAnalyzer.cs:line 309 at ILCompiler.ILScanner.ILCompiler.IILScanner.Scan() in /_/src/runtime/src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/ILScanner.cs:line 157 at ILCompiler.Program.<Run>g__RunScanner|4_0(Program.<>c__DisplayClass4_0&) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler/Program.cs:line 525 at ILCompiler.Program.Run() in /_/src/runtime/src/coreclr/tools/aot/ILCompiler/Program.cs:line 594 at ILCompiler.ILCompilerRootCommand.<>c__DisplayClass263_0.<.ctor>b__0(ParseResult) in /_/src/runtime/src/coreclr/tools/aot/ILCompiler/ILCompilerRootCommand.cs:line 319 /home/AzDevOps/.nuget/packages/microsoft.dotnet.ilcompiler/11.0.0-preview.7.26381.103/build/Microsoft.NETCore.Native.targets(359,5): error MSB3073: The command ""/home/AzDevOps/.nuget/packages/runtime.linux-x64.microsoft.dotnet.ilcompiler/11.0.0-preview.7.26381.103/tools/ilc" @"obj/Release/net11.0-android/android-arm64/native/SamplesApp.ilc.rsp"" exited with code 1. [/agent/_work/1/s/src/SamplesApp/SamplesApp/SamplesApp.csproj::TargetFramework=net11.0-android] We've seen this before! See #24050 for (many!) more details. The TL;DR is that older versions of Mono.Cecil could create "broken" `.pdb` files, which would produce `BadImageFormatException` errors such as the above when processed by `ilc`. *Part* of the fix is to update to a version of Mono.Cecil which fixes this issue: Mono.Cecil 0.11.6. (A similar issue *also* impacts illink, but simply updating Mono.Cecil within Uno appears to be enough to fix the above error.)
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
Suppressed comments (2)
src/SourceGenerators/Uno.UI.Tasks/Uno.UI.Tasks.csproj:20
- The PR description says it also updates EmbeddedResourceInjectorTask_v0 to preserve original assembly/PDB files with a
.bk-EmbeddedResourceInjectorextension, but there doesn't appear to be any corresponding code change in this PR. Please either update the PR description to match the actual changes, or include the intended backup behavior change in the diff.
<PackageReference Include="Mono.Cecil" Version="0.11.6" />
src/Uno.XamlTrimmingValidator/Uno.XamlTrimmingValidator.csproj:10
- Per repo contribution requirements, the PR description should include a dedicated issue footer line like
Fixes .../Closes .../Related to ...with the full issue URL. Right now it only lists the issue as a 'Context' link, which may not be picked up for tracking/auto-close.
<ItemGroup>
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-24050/wasm-skia-net9/index.html |
Context: #23966
Context: dotnet/macios#26428
Context: #24036
Context: dotnet/cecil#504
Context: jbevain/cecil#982
Context: jbevain/cecil@0.11.4...0.11.6
Context: jbevain/cecil@0.10.1...0.11.6
In The Beginning™ was a simple idea: why don't we have an iOS+Native AOT test stage? Thus began #23966, which promptly fell over, caught on fire, and sank into the swamp.
There are two issues with #23966:
CI was unhappy; it errors out with
Not sure what's happening there. It doesn't happen locally…
It couldn't build locally either!
The initial attempt to build locally would fail in
ilc:Thus began a fair bit of investigation, some of which is mentioned in #24036 and dotnet/cecil#504.
What happened was a "failure cascade":
The
<Csc/>task produced a.pdbfile.Uno's
<EmbeddedResourceInjectorTask_v0/>task would use Cecil to process the assembly and.pdbfile from (1). Uno was using, at most, Mono.Cecil 0.11.4, which had a bug around the encoding of "compressed" integers within.pdbfiles.(This is later fixed in Add additional ByteBufferTest tests jbevain/cecil#982, and released as part of Mono.Cecil 0.11.6.)
The updated
.pdbfile would contain "Invalid compressed integer" values.Later,
illinkwould run, which has it's own separate copy of Mono.Cecil -- from dotnet/cecil -- which would also update the.pdbfiles from (2). Whenillinkran, any "Invalid compressed integer" values would be further corrupted.Later still, when
ilcruns, it would process the.pdbfiles produced by (3), and at this point instead of "silently corrupting" data, it would error out entirely:(Failure cascades are fun!)
Part of the fix here is to update Uno to use Mono.Cecil 0.11.6, which contains the fix for reading and writing "compressed" integers in
.pdbfiles. That is done here.Additionally, I found it incredibly helpful in debugging all of this to have "before" and "after" versions of the files processed by
<EmbeddedResourceInjectorTask_v0/>. (For too long, I thought that (3) was caused by a Roslyn bug, as I didn't see (2)!)Update the
<EmbeddedResourceInjectorTask_v0/>task so that it preseves the original assembly and.pdbfiles to have a.bk-EmbeddedResourceInjectorextension, e.g.SamplesApp.dll.bk-EmbeddedResourceInjectorandSamplesApp.pdb.bk-EmbeddedResourceInjector.All of this will not fix #23966, but is a partial prerequisite. A full fix will require dotnet/cecil#504 to be merged and released,
illinkupdated to use dotnet/cecil#504, and then there's dotnet/macios#26428, in whichclang++crashes when trying to link everything even if we get past the whole.pdbmess.(Aside: the
.pdbmess can be avoided by NOT USING.pdbFILES, e.g. buil with-p:DebugType=none. However, who wants to do that?)…which still leaves the original "how do we get this building on CI" question…
Baby steps!
PR Type:
🏗️ Build or CI related changes
What changed? 🚀
PR Checklist ✅
Screenshots Compare Test Runresults.