Here are my findings after studying the source code in NAntSchemaTask.cs
and TypeFactory.cs and writing some code to support named assemblies:

  * The current semantics of <nantschema/> is to generate a XSD for all
    loaded assemblies or for a single class in one of those loaded
    assemblies. Requiring that a named assembly be loaded doesn't seem
    unreasonable.

  * NAntSchemaTask looks for types to process in TypeFactory. It is
possible
    to reuse the functionality in TypeFactory to process a named
assembly
    but the result is equivalent to a <loadtasks/>.

  * If one could create an instance of TypeFactory, then one could use
an
    AppDomain to load a named assembly, use the instance of TypeFactory
to
    scan for NAnt extensions, and use NAntSchemaTask with very little
    modification to generate a schema. The second AppDomain could then
be
    unloaded and the TypeFactory instance garbage collected, providing
    schema generation without the <loadtasks/> side effect. Allowing
    instances of TypeFactory might be a big refactoring job which might
not
    be worth the effort.

  * NAntSchemaTask uses NAntSchemaGenerator to generate the XSD file.
    NAntSchemaGenerator automatically adds a top project element and a
    target element. To use any task in a named assembly would require,
at
    the very least, a <project/> element. Example:

<project
  name="example"
  default="build"
  xmlns="http://tempuri.org/nant-donotuse.xsd";
  xmlns:custom="http://tempuri.org/custom-donotuse.xsd";
>

  <target name="build">
    <echo message="normal task" />
  </target>

  <custom:project>
    <custom:mytask />
  </custom:project>

</project>

    In the example above, I could place the <custom:project/> element
    anywhere I can place a regular task. I can't access <custom:mytask/>
    until I have a <custom:project/> somewhere... I was hoping that I
could
    simply use <custom:mytask/> anywhere I could use a regular task.

Given the above points, I'm not sure whether having the ability to
create a schema for named assemblies would be useful to anyone. If the
functionality I'm looking for can be implemented, then perhaps it could
be useful. At that point I could present the possible refactoring
required to allow TypeFactory instances (I think it can be done without
changing the current interface!) and the implementation for named
assemblies. I'm thinking the implementation for named assemblies should
be its own task if the TypeFactory instance refactoring is used because
the semantics would be different depending on how <nantschema/> was
used.

I'm really looking forward to hearing comments from the developers list
so that I can determine how much effort (if any) I should put into this.

--Edwin

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Castro, Edwin Gabriel (Firing Systems Engr.)
Sent: Wednesday, September 29, 2004 5:16 PM
To: Scott Hernandez; [EMAIL PROTECTED]
Subject: [nant-dev] RE: [Nant-users] NantContrib [loadtasks]

Bringing this over to the developers list:

I see what you mean about appdomain issues. I'll look into the code as I
expect the implementation might be somewhat easy. I'll also try to write
some good tests!

Would it be feasible to create a second appdomain, load the assembly
into that appdomain, generate the schema, and finally unload the
appdomain? Actually, this could be a cool way for <loadtasks/> to work
since that would allow users to <unloadtasks/> later... Assuming that's
something people would want to do... I don't know...

My appdomain knowledge is almost non-existent (I know appdomains exist
and I sort of know what they're about, but that's pretty much it). If
there are some reasons as to why using a second appdomain would be bad
please let me know. Thanks!

--Edwin

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Scott
Hernandez
Sent: Wednesday, September 29, 2004 2:47 PM
To: [EMAIL PROTECTED]
Cc: Castro, Edwin Gabriel (Firing Systems Engr.)
Subject: Re: [Nant-users] NantContrib [loadtasks]

No idea when this would get worked on, but the implementation should be 
pretty simple.

Most of the code is written to support creating a schema of arbitrary
Type 
objects. But be careful as loading types means loading assemblies, and 
loading the assembly in the appdomain may cause the task, types and 
functions to be loaded... (which I believe it will). This would have the

side effect of basically doing a <loadtasks/> on the assemblies you want
to 
create a schema for. Another approach may be to require that the
assemblies 
you want to create a schema for are already loaded, and just filter the
rest 
of the loaded assemblies out. Either way, documenting the behavior is 
probably all that is needed. :)

If you want to discuss any more of the internal code I would suggest
moving 
this thread over to the dev list.

If you put together a patch you can post it to the nant-dev list for
review. 
If you include an updated unit test you are even more likely to get
someone 
to test it and commit it.

----- Original Message ----- 
From: "Castro, Edwin Gabriel (Firing Systems Engr.)" <[EMAIL PROTECTED]>
> That's good to know! I would like to have the ability to generate a
task
> schema for individual assemblies. :-) Will this ever be implemented?
And
> if yes, any idea when this might happen? If I look at the
<nantschema/>
> task and try to implement this functionality can I pass implementation
> to someone to review and add to the distribution?
> -----Original Message-----
> From: [EMAIL PROTECTED]
> Actually, the <nantschema/> task will output a schema for any, and
all,
> tasks that are loaded. This includes any custom tasks that are loaded
> with
> <loadtasks/>. It was on the <nantschema/> todo list to allow creating
> schemas for only a given assembly, but that was not been coded yet.
> ----- Original Message ----- 
> From: "Castro, Edwin Gabriel (Firing Systems Engr.)" <[EMAIL PROTECTED]>
>> While this method is not the recommended procedure, it does have the
>> nice property that you can use the <nantschema> task to produce a
> schema
>> that will contain all the NAnt, NAntContrib, and Custom tasks
> specified
>> in the nant.exe.config. This is very useful since there is no other
> way
>> to create a schema for NAntContrib or Custom tasks. 



-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give
us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out
more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
Nant-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-users


-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give
us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out
more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
nant-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers


-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
nant-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers

Reply via email to