Thanks for raising this. You identified a genuine gap, so I’ve had some fun adding conditional compilation to Objo.
https://feedback.objo.dev/feature/1022
You can now write:
@If DebugBuild Then
Root = New FolderSystemItem("some private local folder used for debugging")
@Else
Root = SpecialFolder.CurrentDirectory
@EndIf
DebugBuild is True when using Run, Debug or Profile from Objo Studio, including remote sessions. It is False when building or publishing an application, and when using the equivalent objo command-line operations.
This is different from an ordinary If statement. The compiler removes the inactive branch before parsing, type checking and generating bytecode. Consequently, the private path in the example above will not appear as a string constant—or anywhere else in the compiled release bytecode.
The syntax also supports @ElseIf, nested blocks and restricted Boolean expressions using DebugBuild, True, False, Not, And, Xor, Or, =, <> and parentheses.
I decided not to add App.IsDebug, because it could ambiguously mean either “was this compiled as a debug build?” or “is a debugger attached right now?” The two cases are deliberately separate:
@If DebugBuild Then controls which source is included at compile time.
System.IsDebuggerAttached is a runtime check indicating whether a debugger is currently attached.
The editor recognises the new directives, including formatting, indentation and code folding. They also have their own customisable syntax style under Settings > Appearance > Compiler Directives, with brown as the default colour.
One small correction regarding SpecialFolder.CurrentDirectory: it returns the process’s current working directory, which is not guaranteed to be the executable’s directory. Use SpecialFolder.Resources for bundled project resources, or System.ExecutablePath when you specifically need the executable’s path.
The complete syntax and permitted expressions will be documented here when the next release drops (not live yet):
https://docs.objo.dev/#/conditional-compilation
Thanks again for the suggestion!