Skip to content

fix: DisassemblyTextLine/LinearDisassemblyLine Equals(object) cast#21

Merged
tinysec merged 1 commit into
masterfrom
fix/equals-object-cast-typo
Jul 8, 2026
Merged

fix: DisassemblyTextLine/LinearDisassemblyLine Equals(object) cast#21
tinysec merged 1 commit into
masterfrom
fix/equals-object-cast-typo

Conversation

@tinysec

@tinysec tinysec commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Summary

Copy-paste defect carried over from InstructionTextToken: both Equals(object?) overloads cast the other operand with rawOther as InstructionTextToken, which is always null for these struct types, so equality always returned false (and passing an InstructionTextToken recursed into its own Equals(object)). Each must cast to its own type and delegate to the typed Equals. The typed Equals(T?) and the ==/!= operators were already correct.

  • Struct/BNDisassemblyTextLine.cs:133as InstructionTextTokenas DisassemblyTextLine
  • Struct/BNLinearDisassemblyLine.cs:91as InstructionTextTokenas LinearDisassemblyLine

(Struct/BNInstructionTextToken.cs:187 correctly casts to InstructionTextToken — left untouched.)

Mirrors Python's DisassemblyTextLine.__eq__ (function.py:3801) which compares the rendered-line fields.

Verification

  • Binding builds clean (0 warnings, 0 errors).
  • New E2E tests: render the same line twice, assert self-equality + distinct-but-equal instances compare true via Equals(object) and a different line compares false. Before the fix Equals(object) always returned false.

Copy-paste defect from InstructionTextToken: both Equals(object?) overloads
cast the other operand with `rawOther as InstructionTextToken`, which is
always null for these types, so equality always returned false (and passing
an InstructionTextToken recursed into its Equals(object)). Each must cast to
its own type and delegate to the typed Equals. The typed Equals(T?) and the
== / != operators were already correct.

Mirrors Python's DisassemblyTextLine.__eq__ (function.py:3801) which
compares the rendered line fields.
@tinysec tinysec merged commit 636c170 into master Jul 8, 2026
1 check passed
@tinysec tinysec deleted the fix/equals-object-cast-typo branch July 8, 2026 05:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant