Are you saying that the parameters ARE evaluated ? Then I would have
to differ because I have confirmed the opposite (which is to say that
I believe I was right in my assertion).
I used the following code :
---
private void Form1_Load(object sender, EventArgs e)
{
DebugOut(GetName(1));
}
[Conditional("DEBUG")]
public void DebugOut(string msg)
{
System.IO.File.WriteAllText("c:\\DebugOut.txt", msg);
}
public string GetName(int idx)
{
System.IO.File.WriteAllText("c:\\GetName.txt", "Getname was
called.");
if (idx == 1)
return "xx";
else
return "xxx";
}
---
In Debug build, both files are created because the DEBUG constant is
defined. In a Release build, neither file is created. This is a pretty
common use of Conditional compilation constants, for instance, to turn
off Logging functionality in Release builds.
On Nov 6, 8:01 am, oddvark <[EMAIL PROTECTED]> wrote:
> Well, this is a bit old now, but I have confirmed that the parameters
> evaluated.
>
> Thanks!
>
> On Oct 29, 11:32 am, Cerebrus <[EMAIL PROTECTED]> wrote:
>
>
>
> > Why don't you try it and let us know, instead ? I don't do much
> > conditional stuff, but my guess would be : No. What sayest thou ?
>
> > Why, you ask ? I'd say it was because the method call would be
> > compiled to IL only in a Debug build.
>
> > On Oct 29, 11:25 pm,oddvark<[EMAIL PROTECTED]> wrote:
>
> > > Hi,
>
> > > If a method is marked condtional and has a parameter, is the parameter
> > > not evaluated if the condition is false?
>
> > > for example (pseudo code):
>
> > > ===============
> > > [Conditional : Debug]
>
> > > public void DebugOut(string message)
> > > {
> > > xxxx
>
> > > }
>
> > > xxxx
>
> > > DebugOut( GetSongName(1) )
>
> > > ==============
>
> > > Does GetSongName still get called if Debug is false?
>
> > > Thanks.- Hide quoted text -
>
> - Show quoted text -