-
-
Notifications
You must be signed in to change notification settings - Fork 60
Preprocessor Symbols
Because Sucrose reuses code through Shared Item Projects — where the same source file is physically compiled into many different executables — it relies on preprocessor symbols to make one shared file behave differently per app, per engine, and per platform. Every executable defines a unique symbol in its .csproj, and shared source wraps host-specific code in #if SYMBOL blocks. This page catalogs all three symbol families and explains how they vary shared code.
- How symbols are defined
- Application symbols
- Engine symbols
- Platform symbols
- How shared code uses them
- See also
Each executable defines its symbol via <DefineConstants> in its .csproj:
<!-- Sucrose.Launcher.csproj -->
<DefineConstants>$(DefineConstants);LAUNCHER</DefineConstants>
<!-- Sucrose.Live.MpvPlayer.csproj -->
<DefineConstants>$(DefineConstants);ENGINE;LIVE_MPVPLAYER</DefineConstants>Platform symbols are not set per project — they are set centrally in Directory.Build.targets based on the active PlatformTarget. The combination of an app/engine symbol and a platform symbol uniquely identifies the compilation host of any shared file.
Each non-engine executable defines exactly one application symbol:
| Symbol | Process |
|---|---|
LAUNCHER |
Sucrose.Launcher |
PORTAL |
Sucrose.Portal |
BACKGROUNDOG |
Sucrose.Backgroundog |
COMMANDOG |
Sucrose.Commandog |
WATCHDOG |
Sucrose.Watchdog |
REPORTDOG |
Sucrose.Reportdog |
PROPERTY |
Sucrose.Property |
UNDO |
Sucrose.Undo |
UPDATE |
Sucrose.Update |
(The roles of each of these processes are covered in Architecture Overview.)
Every live engine defines the shared ENGINE symbol plus exactly one LIVE_* symbol identifying which engine it is:
| Symbol(s) | Engine |
|---|---|
ENGINE |
Defined by all engines |
ENGINE + LIVE_WEBVIEW
|
Sucrose.Live.WebView |
ENGINE + LIVE_CEFSHARP
|
Sucrose.Live.CefSharp |
ENGINE + LIVE_MPVPLAYER
|
Sucrose.Live.MpvPlayer |
ENGINE + LIVE_VLCPLAYER
|
Sucrose.Live.VlcPlayer |
ENGINE + LIVE_AURORA
|
Sucrose.Live.Aurora |
ENGINE + LIVE_NEBULA
|
Sucrose.Live.Nebula |
ENGINE + LIVE_VEXANA
|
Sucrose.Live.Vexana |
ENGINE + LIVE_XAVIER
|
Sucrose.Live.Xavier |
The ENGINE symbol lets shared code distinguish "any engine" from the non-engine apps, while the LIVE_* symbol selects engine-specific behavior. (Each engine's technology and supported types are documented under Engines Overview.)
Set in Directory.Build.targets according to the build's PlatformTarget:
| Symbol | Platform | RuntimeIdentifier |
|---|---|---|
X86 |
x86 | win-x86 |
X64 |
x64 | win-x64 |
ARM64 |
ARM64 | win-arm64 |
These are used wherever code must branch on architecture — for example, selecting the correct native binary (libmpv-{arch}.dll) or resolving an installer's {Architecture} placeholder.
Because a shared .cs file is inlined into many hosts, the same file may need different usings, different startup wiring, or different feature toggles depending on who is compiling it. The pattern is a plain C# conditional-compilation block:
#if PORTAL
// Code only compiled into Sucrose.Portal
#endif
#if ENGINE && LIVE_MPVPLAYER
// Code only compiled into the MpvPlayer engine
#endif
#if X64
// x64-only path (e.g. native binary selection)
#endifThis is why the Shared Item Project model is used instead of a single shared DLL: a DLL would compile once with one set of symbols, whereas inlining lets each consumer compile the shared source with its own symbols. When you edit shared code, always consider which hosts will compile each branch.
Getting Started
- Installation
- System Requirements
- Quick Start
- Portal Interface Tour
- Updating Sucrose
- Uninstalling Sucrose
Wallpaper Types
Using Sucrose
- Managing Library
- Using Store
- Customizing Wallpaper
- Multi-Monitor
- Wallpaper Cycling
- Choosing Engines
- Performance Rules
- Theme, Tray & Startup
- Discord Rich Presence
Settings Reference
- Settings Overview
- Settings: General
- Settings: Personal
- Settings: Performance
- Settings: Wallpaper
- Settings: System
- Settings: Other
- Settings: All Keys
Creating Wallpapers
- Create Overview
- Create: Step By Step
- Create: Package Format
- Create: Customization Controls
- Create: JS Bridge
- Create: Audio API
- Create: System API
- Create: Property Listener & Filters
- Create: Web Architecture
- Create: Compatibility
- Create: Example Wallpapers
- Create: Sharing & Publishing
Engine Reference
- Engines Overview
- Engine: MpvPlayer
- Engine: VlcPlayer
- Engine: WebView
- Engine: CefSharp
- Engine: Nebula
- Engine: Vexana
- Engine: Xavier
- Engine: Aurora
- Engine Comparison
Automation & Command Line
Architecture & Internals
- Architecture Overview
- Lifecycle
- Commandog Dispatcher
- Single-Instance Mutexes
- IPC
- Backgroundog Service
- Crash Reporting
- Update Internals
- Property Service
- Undo Internals
Data, Files & Diagnostics
Building & Contributing
- Building From Source
- Repository Layout
- Shared Item Projects
- Code Conventions
- Preprocessor Symbols
- Publish Pipeline
- Bundle Installer Internals
- Extending Sucrose
- Contributing
- Translating with Localizer
- Localization Coverage
- Security Policy
- Privacy & Telemetry
Help & Support