Fix doubled index on macro opcodes in the IL view#3844
Merged
Conversation
The IL view renders a macro opcode like ldarg.0 as the mnemonic (an opcode
reference) followed by the index written as a separate clickable local or
parameter reference. AvaloniaEditTextOutput's omitSuffix path used
TrimEnd('.') to drop the index, but the name ends in the index digit, not a
dot, so it was a no-op: the full "ldarg.0" was written and the index appended
again, producing "ldarg.00" (and likewise ldloc.NN / stloc.NN).
PlainTextOutput and the WPF AvalonEditTextOutput strip everything after the
last dot; the Avalonia port regressed this. Restore that behavior. Only the UI
was affected -- ilspycmd and the disassembler tests use PlainTextOutput.
Assisted-by: Claude:claude-opus-4-8:Claude Code
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.
Problem
In the IL view the macro load/store opcodes render their index twice:
ldarg.0shows asldarg.00,ldloc.1asldloc.11,stloc.0asstloc.00, and so on. This only affects the ILSpy UI;ilspycmd -iland the disassembler tests are unaffected.Cause
MethodBodyDisassembler.WriteOpCodesplits these opcodes so the index can be a clickable local/parameter reference: it writes the mnemonic viaWriteReference(opCode, omitSuffix: true)and then writes the index viaWriteLocalReference.AvaloniaEditTextOutput.WriteReferenceimplementedomitSuffixasopCode.Name.TrimEnd('.'). The name ends in the index digit, not a dot, so that is a no-op: the fullldarg.0is written and the index0is then appended again →ldarg.00.PlainTextOutputand the WPFAvalonEditTextOutputinstead keep the mnemonic up to and including the last dot (Name.Remove(lastDot + 1)); the Avalonia port regressed this. This restores that behavior and adds a regression test forAvaloniaEditTextOutput.🤖 This PR was prepared by Claude Code (claude-opus-4-8) on behalf of @siegfriedpammer.