Page 1 of 1

Symbol to conditionally compile code [SOLVED]

Posted: Mon Feb 29, 2016 10:52 am
by rkmore
I have some code that is shared between other projects and my CSHTML5 project.

In those cases where I need to tweek the code to compile and run (for example in the the most recent case where I use double.IsInfinity which is not implemented) I would like to add conditional compilation via if endif so that I do not need to fork the code.

Is there a symbol I can use to only compile certain code and to exclude other code when compiling for CSHTML5 ?

RKM

Re: Symbol to conditionally compile code

Posted: Mon Feb 29, 2016 11:04 am
by JS-Support @Userware
Hello RKM,

Sure. You can use either the CSHTML5 symbol, or the CSharpXamlForHtml5 symbol. Both will work.

Here is an example:

Code: Select all


#if CSHTML5

    MessageBox.Show("This is a message in CSHTML5.");
   
#else

    var x = new MessageDialog("This is a message in Universal Windows Platform.");
    x.ShowAsync();
   
#endif



Regards,
JS-Support

Re: Symbol to conditionally compile code

Posted: Mon Feb 29, 2016 11:55 am
by rkmore
Exactly what I was looking for. Thanks!