Support type hierarchies across multiple files and projects.
Having type hierarchies across multiple files and projects will allow for extensible designs when the base class is in a consumed library. This would allow for something such as the following:
Project A
[GenerateImmutable(GenerateBuilder = true)]
public partial class NodeA
{
readonly string name;
readonly ImmutableHashSet<string> tags;
}
[GenerateImmutable(GenerateBuilder = true, DefineRootedStruct = true)]
public partial class Tree
{
readonly ImmutableSortedSet<Tree> children;
readonly NodeA node;
}
Project B
[GenerateImmutable(GenerateBuilder = true)]
public partial class NodeB : NodeA
{
readonly string mySpecializedProperty;
}
This will not work with the current way <Immutable>.To<InheritedType>() works. Perhaps those methods should be moved to extension methods, but then CreateWithIdentity(...) would have to become public and always generated.
@jviau: with regard to your design that NodeA might be extended by a 3rd party, is that really a scenario? Your design seems to be each tree has exactly one NodeA, so with your proposed design, only one person can determine what NodeA-derived type to instantiate. That doesn't sound like it's consistent with the idea of many CPS extensions setting arbitrary values on these. Or is it just the tree provider (or subtree provider) that gets to determine what extra data to store?
@AArnott this scenario is mostly for subtree providers, where a customer can have the subtree provide an extended implementation of NodeA if they deem it necessary.
OK, that makes sense then.