The preprocessor is an unique feature of the X# compiler. In the Clipper times, the preprocessor was used to implement the commands (they were mapped to function calls), and in the VO times the preprocessor was present, but very few people used it.
The simpliest statement is the #ifdef, usable for conditional compilation, and very helpful in the migration from VO:
#ifdef __XSHARP__ super:__FocusPage( int( nIndex ) ) #else super:__FocusPage( nIndex ) #endif
Now, in the X# compiler it is again a very powerful tool. It can be used to implement commands for compatibility with xBase languages like Clipper, FoxPro and Harbour:
#command USE <db> ; [VIA <rdd>] ; [ALIAS <a>] ; [<sh:SHARED>] ; [<ex:EXCLUSIVE>] ; [<ro:READONLY>] ; [<nw:NEW>] ; ; => DBUseArea(<.nw.>, <rdd>, <(db)>, <(a)>, iif(<.sh.> .or. <.ex.>, !<.ex.>, FALSE), <.ro.>)
to be used like this:
USE "C:\dbf\customer.dbf" VIA "DBFCDX" ALIAS test
Source: https://www.xsharp.info/forum/public-chit-chat/561-managed-dbf-using-x-language?start=12 - the second message by Chris Pyrgas
The development team has ported a Harbour app to X# using the preprocessor to translate the way @x,y SAY…GET commands to their own function calls, making it work without changing the original code.
But it can also be used to write less code for MVVM ViewModels:
#command PROPERTY <n> AS <t> GETSET <v> NOTIFY CHANGE =>; PROPERTY <n> AS <t>;; GET;; RETURN SELF:<v>;; END GET;; SET;; IF SELF:<v> <> VALUE;; SELF:<v> := VALUE;; SELF:NotifyPropertyChanged(<"n">);; ENDIF;; END SET;; END PROPERTY
and to be used like this:
PROPERTY x AS INT SET _x NOTIFY CHANGE
Source: https://www.xsharp.info/forum/pearls/216-snippets-in-vs-2017-rc-some-success?start=5 - first and second message by Johan Nel.
You can find the full documentation here: