Symbol to conditionally compile code [SOLVED]

Please post public support tickets here. Note: for private support tickets, please send an email to support@cshtml5.com instead.
rkmore
Posts: 55
Joined: Mon Dec 07, 2015 1:53 pm

Symbol to conditionally compile code [SOLVED]

Postby rkmore » Mon Feb 29, 2016 10:52 am

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

JS-Support @Userware
Site Admin
Posts: 1076
Joined: Tue Apr 08, 2014 3:42 pm

Re: Symbol to conditionally compile code

Postby JS-Support @Userware » Mon Feb 29, 2016 11:04 am

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

rkmore
Posts: 55
Joined: Mon Dec 07, 2015 1:53 pm

Re: Symbol to conditionally compile code

Postby rkmore » Mon Feb 29, 2016 11:55 am

Exactly what I was looking for. Thanks!


Return to “Technical Support”

Who is online

Users browsing this forum: No registered users and 3 guests