Compiler directive
A compiler directive is a source-level instruction that controls compilation or directs related tooling without being an ordinary executable statement.
.NET MAUI in Action
A compiler directive is a source-code instruction that controls compilation behavior, including conditional compilation for selected platforms.
- How it is used
- Controls which platform-specific code is compiled into a .NET MAUI app, especially for native handler customization.
- How deep it goes
- Demonstrates #if branches within handler mapping and contrasts them with partial classes and runtime platform checks.
- Examples
- Uses a BorderlessEntry with Android, Windows, iOS, and Mac Catalyst native border-removal branches.
- What you can do after
- Apply it via .NET MAUI to compile native control customizations only for their intended platforms.
Learn Go with Pocket-Sized Projects
A compiler directive is a source-level instruction that affects compilation or directs related tooling without being an ordinary executable statement.
- How it is used
- Uses a compiler directive to embed a corpus file into a Go program for endpoint-related game functionality.
- How deep it goes
- Explains directive syntax, package-scope placement, compiler handling, and blank imports, but does not develop directive implementation internals.
- Examples
- Demonstrates //go:embed corpus/english.txt, a package-level string variable, and a blank import of embed.
- What you can do after
- Apply it via Go's embed package to include a regular file's contents in compiled source.
Read how Learn Go with Pocket-Sized Projects explains compiler directive →
Related concepts
- platformconfigures · A platform is a foundational computing system, environment, or online service that provides capabilities or infrastructure for building, running, delivering, or interacting with applications and services.
- EntryHandlerconfigures · EntryHandler is the .NET MAUI handler that maps Entry views to platform-specific native text-input controls.
- instructionkind of · An instruction is a directive that specifies an action, task, operation, constraint, or expected behavior for a person or computational system.
- template actionincludes · A template action is a delimited instruction in a template that evaluates data, expressions, control flow, definitions, or function calls.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

