Properly formed Namespace trees

Mar 26, 2011 at 6:46 PM

I'm just wondering about the proper way to create namespace objects. I can see from the samples that you need to have a RootUnitNamespace but inside of there you can also have nested namespaces. A couple questions about this.

Suppose I want to create a namespace "A.B.C". What are the possible valid ways I can create the tree of namespaces?

  1. RootUnitNamespace { Name = "A.B.C" }
  2. RootUnitNamespace { Members = [ NestedUnitNamespace { Name = "A.B.C" } ] }
  3. RootUnitNamespace { Members = [ NestedUnitNamespace { Name = "A", Members = [ NestedUnitNamespace { Name = "B.C" } ] } ] }
  4. RootUnitNamespace { Members = [ NestedUnitNamespace { Name = "A" }, NestedUnitNamespace { Name = "A.B" } ] }

etc. (I hope the above psuedo-code is understandable)

It appears to be very flexible I just want to make sure that I don't make too many assumptions before going too far in one direction.

Coordinator
Mar 26, 2011 at 6:51 PM

By the time this gets serialized into metadata, all of these variations normalize to option 1. However, the object model makes more sense, and lookup is easier to reason about if you stick to option 5:

  • RootUnitNamespace { Members = [ NestedUnitNamespace { Name = "A" }, NestedUnitNamespace { Name = "B", Members = [ NestedUnitNamespace { Name = "C" }] } ] }
  • Mar 26, 2011 at 7:18 PM

    Excellent, thanks.