Skip to content

fix Diffable C# export crash on PrivateScope fields - #630

Merged
SamboyCoding merged 1 commit into
SamboyCoding:developmentfrom
ada-l0velace:fix-privatescope-fields
Nov 28, 2026
Merged

SamboyCoding merged 1 commit into
SamboyCoding:developmentfrom
ada-l0velace:fix-privatescope-fields

Conversation

@ada-l0velace

@ada-l0velace ada-l0velace commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Cpp2IL reads the metadata successfully, but Diffable C# export aborts when it encounters a field with PrivateScope visibility. The field formatter has no matching case and throws.

Example error, using a synthetic field name:

ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
(Parameter 'Unknown visibility for field Sample.Holder.value: PrivateScope')

PrivateScope is a valid metadata value with access bits set to zero. For example, Obfuz's RVA allocator creates backing fields with:

FieldAttributes.InitOnly | FieldAttributes.Static | FieldAttributes.HasFieldRVA

No accessibility bits are supplied, so their visibility is PrivateScope.

Render these fields as private, matching the existing method formatter. Instead of aborting export, a synthetic integer field can now be displayed as:

private int value;
// Or, with Static and InitOnly:
private static readonly int value;

This is a C# display approximation. Original attributes remain unchanged, and invalid visibility values still throw.

Added formatter and actual Diffable tests using the existing public fixture.

@coveralls

coveralls commented Nov 11, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 46156130757

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Coverage increased (+10.0%) to 39.954%

Details

  • Coverage increased (+10.0%) from the base build.
  • Patch coverage: 1 of 1 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 15384
Covered Lines: 6631
Line Coverage: 43.1%
Relevant Branches: 11975
Covered Branches: 4300
Branch Coverage: 35.91%
Branches in Coverage %: Yes
Coverage Strength: 153644.5 hits per line

💛 - Coveralls

@SamboyCoding
SamboyCoding force-pushed the fix-privatescope-fields branch from 6733230 to d2dee1f Compare November 28, 2026 14:43
@SamboyCoding
SamboyCoding merged commit ded7266 into SamboyCoding:development Nov 28, 2026
8 checks passed
@ada-l0velace
ada-l0velace deleted the fix-privatescope-fields branch November 29, 2026 12:11
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.

3 participants