Add IlProjection: new-pipeline IL views (raw/structured) with resolved operands#615
Merged
Conversation
Renders the ground-truth IL projections (Raw, Structured) from the replacement pipeline's materialized method data off a MetadataSource — the new-pipeline backing for the annotated-IL view, replacing the old MethodBodyContext -> MethodAnalysis -> AnnotatedILEmitter contract. Operands resolve through the importer's own token resolvers (ResolveMethod / ResolveField / ResolveTypeToken) so callvirt/ldfld/ldstr render as names, not raw tokens; block structure reuses the importer's FindLeaders, so the views share one analysis with the IR import rather than running a parallel CFG/stack pass. Exception-safe by construction (DecompilerResult.Run): a malformed read or a resolver failure surfaces as a diagnostic, never a throw; operand resolution falls back to raw token hex per-instruction. Exposes three IrImporter helpers as internal (FindLeaders, CallerScope, ResolveTypeToken). Non-disruptive: no consumers migrated yet, so it dual-runs beside the old emitter. The per-instruction stack-typed depth and the consumer migration (MemberCodeProvider, harness DumpStages) + deletion of the old infra are follow-ups. Tests: 4 new (offsets/opcodes, resolved call operand, block labels, .try/catch markers); ILInspector.Decompiler.Tests 430 pass. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Structured_LabelsBranchBlocks anchored a regex with $ over output rendered with
Environment.NewLine; on Windows the trailing \r before the line break made the
$ anchor miss (0 matches). Normalize with ReplaceLineEndings("\n") in the test
helper, the repo's convention for line-anchored assertions.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
IlProjectionrenders the ground-truth IL views (Raw,Structured) from the replacement pipeline's materialized method data off aMetadataSource— the new-pipeline backing for the annotated-IL view, replacing the oldMethodBodyContext→MethodAnalysis→AnnotatedILEmittercontract.Design
ResolveMethod/ResolveField/ResolveTypeToken), and block structure reuses the importer'sFindLeaders— so the IL views share the pipeline's analysis rather than running a second CFG/stack pass (the duplication the oldMethodAnalysisrepresented).DecompilerResult.Runwraps it; a malformed read or resolver failure surfaces as a diagnostic, never a throw. Operand resolution falls back to raw token hex per-instruction, so the structure stays ground truth even if one token can't resolve.Pipeline/(noILInspector.Metadatadependency).Output
System.String.IsNullOrEmpty, Raw — operands resolved, branch targets computed:Structured block boundaries (
IL_0000/IL_0003/IL_000D) match the oldAnnotatedILEmitterexactly (Block_0 0000-0002,Block_1 0003-000C,Block_2 000D-000E).Scope
IrImporterhelpers asinternal(FindLeaders,CallerScope,ResolveTypeToken).Follow-ups (per the retirement plan)
MemberCodeProvider(annotated-IL view) and the harnessDumpStagesontoIlProjection, then deleteMethodBodyContext/MethodAnalysis/AnnotatedILEmitter, gated by a corpus parity diff of new-vs-old annotated IL.Tests
4 new (
IlProjectionTests): offsets/opcodes, resolved call operand (not raw hex), branch-block labels,.try/catchmarkers.ILInspector.Decompiler.Tests430 pass.🤖 Generated with Claude Code