Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support type hierarchies across multiple files and projects. #70

Open
jviau opened this issue Dec 22, 2015 · 3 comments
Open

Support type hierarchies across multiple files and projects. #70

jviau opened this issue Dec 22, 2015 · 3 comments

Comments

@jviau
Copy link

jviau commented Dec 22, 2015

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.

@AArnott
Copy link
Owner

AArnott commented Dec 23, 2015

@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?

@jviau
Copy link
Author

jviau commented Jan 4, 2016

@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.

@AArnott
Copy link
Owner

AArnott commented Jan 5, 2016

OK, that makes sense then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants