----- Original Message -----
From: "Ian MacLean" <[EMAIL PROTECTED]>
To: "Gert Driesen" <[EMAIL PROTECTED]>
Cc: "Nant-Developers (E-Mail)" <[EMAIL PROTECTED]>
Sent: Sunday, July 04, 2004 5:10 PM
Subject: Re: [nant-dev] checking task availability


> Gert Driesen wrote:
>
> >After giving it some more thought, it might be best to have a bool
property
> >on Task that is non-virtual, and which never throws an exception.  And
have
> >a protected virtual method (called CheckAvailability or so) that will
throw
> >a (Build)Exception if the task is not available, while specifying the
> >reason.  That way we could call this method as part of Task.Execute, and
> >output the reason why the task is not available in the build log.
> >
> >
> >
> ok - so the bool property just checks the config file or whatever and
> CheckAvailability does the runtime check. The bool property should
> probably be static so that it can be called without having to
> instantiate the Task class.

Well, CheckAvailability would perform the actual runtime check (using the
XML configuration in the NAnt configuration file, or the behaviour specified
by the task), and possibly throw an exception detailing the reason why the
task is not available.  The IsAvailable property would just call the
CheckAvailability method, and return false if the CheckAvailability method
throws an exception.

So, the IsAvailable property would be used to conditionally execute code
based on the availability of a task, while the CheckAvailability method
would be invoked by Task.Execute to ensure a task is available, and report a
build failure otherwise ...

>
> >To be able to use this in our tests to determine whether a given test can
be
> >executed, we'd need to initialize the task that we want to execute
though.
> >
> >
> >
> not if we make it static.

That's not possible, as we always need an instance of the task that you want
to check the availability of ....

We could have a static method on Task that takes a task name as input, and
returns a bool indicating the task availability, but I'm not sure this is
the right approach as we need to allow third party tools to pass in the XML
configuration node, and this can only be done by passing it to the Project
ctor.  So, we can have a static property that takes both a task name, and a
project as input .... But I think it might be best to add this just to
BuildTestBase for now, as I don't think there's much need for this right now
in other places ...

> It would also be worth having a task::is-available(string
> taskName ) function so the check can be done from a build file.

Yes, ofcourse ...

Still not sure about the name of the property/function though, kinda awkward
to have task::exists and task::available.  In order to determine whether a
task can be executed you'd have to check the value of both functions ...

Gert


-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
nant-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers

Reply via email to