Skip to content

fix(core): skip rewriting CoreCLR netstandard facades - #102

Merged
mcpolo99 merged 1 commit into
mcpolo99:developfrom
fightroad:fix/coreclr-netstandard-facade
Sep 21, 2026
Merged

mcpolo99 merged 1 commit into
mcpolo99:developfrom
fightroad:fix/coreclr-netstandard-facade

Conversation

@fightroad

Copy link
Copy Markdown

Summary

  • Self-contained .NET publish folders ship a
    etstandard.dll that only type-forwards to System.Runtime / System.Private.CoreLib.
  • The existing netstandard rewrite cleared those forwards and hid System.Object, crashing analysis with Could not resolve type: System.Object (netstandard, ...).
  • Only rewrite when a referenced assembly actually defines System.Object (classic mscorlib case), preserving .NET Standard library support.

Test plan

  • Obfuscate a self-contained .NET 8 win-x64 publish set that previously failed on System.Object
  • Confirm obfuscating a netstandard2.0 library still keeps netstandard-only references

Made with Cursor

…bject.

Co-authored-by: Cursor <cursoragent@cursor.com>

@mcpolo99 mcpolo99 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the change and ran the full local CI with it rebased onto current develop (which now includes the #101 merge).

Local CI: all phases passed — lint, build (incl. C++/CLI), 189 tests passed / 0 failed / 1 skipped (the skip is the UI-interactive Confuser.GUI.Test), and packaging.

Regression paths for this change verified green:

  • CrossFramework.Library.NetStd20 (netstandard2.0 library) builds + covered — the case the second checklist item was about
  • CompressorWithResx.Test (12), VisualBasicRenamingResx.Test (1), 389_MixedCultureCasing.Test (1)

The fix is correct and it also removes a latent NullReferenceException (the old subAss?.Modules foreach would throw when a ref failed to resolve). One nit only: the added comments are heavier than needed — the DefinesSystemObject helper already documents intent. Suggested collapse to a single PR reference below.

Comment on lines +48 to +52
// Classic netstandard facades forward to mscorlib, which actually defines the types.
// Moving those types in keeps the confused module referencing netstandard only.
// CoreCLR publish output is different: netstandard.dll only forwards to System.Runtime,
// and that assembly forwards again to System.Private.CoreLib. Clearing the forwards
// there hides System.Object and breaks later analysis.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Collapse this block to a one-line reference; the code below is self-describing:

Suggested change
// Classic netstandard facades forward to mscorlib, which actually defines the types.
// Moving those types in keeps the confused module referencing netstandard only.
// CoreCLR publish output is different: netstandard.dll only forwards to System.Runtime,
// and that assembly forwards again to System.Private.CoreLib. Clearing the forwards
// there hides System.Object and breaks later analysis.
// https://github.com/mcpolo99/ConfuserExx/pull/102

Comment on lines +63 to +64
// Only rewrite when a referenced assembly actually defines System.Object
// (the mscorlib case). CoreCLR facades only forward it onward.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DefinesSystemObject + the early return already say this; drop the comment:

Suggested change
// Only rewrite when a referenced assembly actually defines System.Object
// (the mscorlib case). CoreCLR facades only forward it onward.


// Remove them because their types has been removed.
foreach (var subAss in allAssemblyRefs) {
// Their types now live on netstandard, so they must not stay cached.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop; Remove(...) is clear enough:

Suggested change
// Their types now live on netstandard, so they must not stay cached.

@mcpolo99
mcpolo99 merged commit 01e0e22 into mcpolo99:develop Sep 21, 2026
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.

2 participants