[Mono-dev] [Patch] Extern assembly alias

Raja R Harinath rharinath at novell.com
Mon Sep 26 01:20:56 EDT 2005


Carlos Alberto Cortez <calberto.cortez at gmail.com> writes:

> Hey, 
> I've been thinking about your ideas, but haven't understood yet the some
> of the reasons behind your suggestions. Maybe to have a cleaner code? or
> am I losing anything?

Definitely cleaner code, yes.  Also, I was trying to remove redundant
implementation of what was already there.

> El vie, 23-09-2005 a las 18:34 +0530, Raja R Harinath escribió:
>> Hi,
>> Carlos Alberto Cortez <calberto.cortez at gmail.com> writes:
>> > The attached patch implements extern assembly alias support for mcs.
>> > I've also added tests and errors for it, and all the tests are running
>> > fine. Could anybody of the mcs guys take a look at it?
>> I'm not particularly thrilled by the approach.
>> I'd prefer introducing classes RootNamespace (deriving from Namespace)
> Would we have to change Namespace to be abstract?

No.  RootNamespace is used to represent a root namespace.  Till now,
there was just one root namespace (called "global", now).  With external
aliases, there can be multiple root namespaces, one or each external

A root namespace RootNamespace would now have:

  * a reference to the assembly owning the namespace (-r:foo=a.dll)

  * a type lookup function that looks up types in that assembly

The default root namespace GlobalRootNamespace would derive from
RootNamespace, but would in addition/instead have:

  * a list of assemblies (every -r:foo.dll)

  * a type lookup function that looks up types in all the assemblies
    (the current TypeManager.LookupType)

>> We just create
>> an Using alias that points to a RootNamespace, and the current
>> QualifiedAliasEntry code should handle it.
> Could you be more specific?

Hmm...  An 'external alias' is just like an 'using alias', except that
it points to a root namespace.

All the rest of the name and type lookup code should remain unchanged.
We already have enough machinery to handle everything necessary.

> PD - Note that looks like csc created a 'normal' namespace per extern
> alias. 

I don't think it does :-)

> For example, if you have an alias 'Hey', and then write something
> like 'Hey.MyNamespace.MyClass ...", it won't complain. I just mentioned
> this, because could have something to see with some observations in the
> future ;-)

No, 'Hey' is probably being used exactly like how an 'using' alias
would.  It doesn't complain for

  using Hey = System.Collections;

  ... Hey.ArrayList foo ...

That doesn't mean 'Hey' is an normal namespace.

- Hari

More information about the Mono-devel-list mailing list