Vb.Net Repository #IF

Hi,

How do I register custom constants so they show up in intellisense with #IF ?

Thanks,
Rob

Hi Rob,

Roslyn parser shows conditional defines that are defined on a project level.

Here’s sample code :

var solution = VbSolution.DefaultSolution;
solution.SetProjectConditionals(new string[] { "DEBUG=TRUE", "MYCONST=1"}, solution.ProjectId);

These constants will be shown in the intellisense for #if/#elseif

Regards,
Dmitry

Hi Dmitry,

I tried this and I am getting the following error.
image

Hi Rob,

Thank you for reporting this problem,

It looks like this works:
solution.SetProjectConditionals(new string[] {"MYCONST"}
however, this does not:
solution.SetProjectConditionals(new string[] {"MYCONST=1"}
We will fix it shortly.

Kind regards,
Dmitry

Thanks Dmitry, quick question. Why do we need to add =1?

Rob

Hi Rob,

We’ve just pushed a new version (9.5.3) to NuGet, where this issue should be fixed.

Visual Basic supports conditional symbols in the form Name=Value, where Value is optional.
Value can be numeric/boolean/string. If no value is specified, the parser evaluates the conditional symbol as true if it’s set via ProjectConditionals.

Kind regards,
Dmitry

Dmitry, thanks for the update and clarifying.

Rob

1 Like