Control-flow flattening
A method body becomes a state machine. A switch picks the next block. Methods that already have exception handlers are left alone.
.NET MAUI · after the build
MauiObfuscate runs on the Release assembly. It renames types and members, flattens control flow, packs string literals, and stops the app when a debugger is attached. XAML, images, and fonts stay as they are.
The pass
The tool does not compile the app and does not need the MAUI workload. It reads the built assembly and its portable PDB, then writes the obfuscated bytes back under the same file name.
Source paths from the PDB decide the file. ViewModels, models, and services are renamed. Views, XAML, platforms, and startup files are not.
Sequence points tie IL back to a source file. A type with no sequence points is left alone unless you list it explicitly.
Names are short and deterministic. Namespaces stay. Virtuals, interface methods, and constructors are not renamed.
The obfuscated bytes replace App.dll. The build output is parked as App.dll.original, with a rename map beside it.
Protections
They run after renaming, on the app and on every dependency you included. Set protections in maui-obfuscation.json to turn one off.
A method body becomes a state machine. A switch picks the next block. Methods that already have exception handlers are left alone.
Literals leave the method body. They sit in one compressed table and come back as the original string at the call.
A module initializer runs before the app. If a debugger is attached, the process stops. A normal launch continues.
What moves
If a file matches a group that is turned off, it stays. That is how a view model sitting under Platforms, or a generated file, is protected. A dependencies entry can rename another assembly, including a wildcard such as MyCompany.*, and updates the calls in the app.
What the app still needs
The public surface of an x:Class type is kept, including properties the XAML binds to. x:Name fields stay even when they are private. [Obfuscation(Exclude = true)] opts a member out.
A public property on an included view model is renamed. If XAML or a string looks that name up, turn the group off or mark the member excluded. The rename map is how you read a stack trace afterwards.