Skip to content

fix: make obfuscated modern-.NET output runnable + run every app in tests (#103) - #105

Merged
mcpolo99 merged 6 commits into
developfrom
103-runnable-output-ui-run-tests
Sep 21, 2026
Merged

mcpolo99 merged 6 commits into
developfrom
103-runnable-output-ui-run-tests

Conversation

@mcpolo99

Copy link
Copy Markdown
Owner

Fixes #103

Problem

Obfuscating a modern-.NET app (.NET 5+/10, e.g. a WinForms app) produced only the managed .dll in the output folder — no runnable .exe. On .NET Framework the obfuscated .exe is itself runnable, so this never surfaced there; on modern .NET the launcher is a native apphost and the app also needs its runtimeconfig.json / deps.json, none of which ConfuserEx copied. The reporter (a beginner) had a Confused/ folder that could not be launched at all.

Fix

ConfuserEngine.SaveModules now copies each modern-.NET module's runtime support files — <name>.runtimeconfig.json, <name>.deps.json and the apphost <name>.exe — next to the obfuscated module, so the output directory is directly runnable. It is a no-op on .NET Framework (those files don't exist).

Controlled by a new project option copyRuntimeFiles (default true, added to the .crproj schema). Set it to false to keep the previous "obfuscated modules only" output.

Why the test suite never caught this — and the coverage work

The cross-framework tests only executed .NET Framework .exe subjects; every net6/8/10 app was obfuscated but never launched, and only the rename protection was exercised cross-framework. A "compiles but crashes on startup" bug (exactly #103's class) was structurally invisible.

This PR closes that gap. Every runnable subject app is now actually executed after obfuscation:

  • WinForms & WPF, net3.5 → net10: a new --selftest mode shows the real main window off-screen and invisible, pumps the message loop, then a thread-pool watchdog terminates cleanly (exit 42). A --selftest-crash variant throws once shown; the framework's unhandled-exception handlers catch it and report failure (non-42 exit, CRASH).
  • Console, net6/8/10: run + crash-reporting via the unhandled-exception handler (net2.0–4.8 already execute via the rename tests).
  • Shared, linked self-test hosts (Tests/Shared/*SelfTestHost.cs) keep this out of each of the ~15 subject apps.
  • The UI tests run off-screen with no visible windows and need no interaction, so they run in local-ci on a developer machine (not just the paid GitHub runner).

Housekeeping

Restructured the cross-framework test projects into per-app-type subfolders — Tests/CrossFramework/{Console,WinForms,WPF,Library}/<Tfm>/ and Tests/CrossFramework/Test/ — via git mv (history preserved). Project/assembly names are unchanged; solution paths, project references and shared-file links were updated accordingly.

Verification

Full local CI green on the final tree: lint, full-solution build (incl. the C++/CLI project), 218 tests passed / 0 failed / 1 skipped (the skip is the UI-interactive FlaUI GUI test), and packaging. CrossFramework.Test alone is 55 passing, including all 24 UI self-run + 4 console self-tests. Confirmed the obfuscated net10 console/WinForms/WPF apps launch from the produced output folder.

@mcpolo99
mcpolo99 merged commit 705aebe into develop Sep 21, 2026
3 checks passed
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