Mutable interfaces?

Topics: Metadata Model
Apr 27, 2010 at 7:01 PM

Hello, I'm using CCI/Metadata to generate a set of new classes from a given set of classes.

To make my code more readable I create specific implementation of IMethodDefinition or IPropertyDefinition to implement specific kind of methods: for example a specific kind of constructor or a read-only abstract property made so and so.

Now I have this data structure where I accumulate type members generated while performing a specific task. I collect several of this kind of "type contribution" and at the end I check them for clashes and add them to the type I'm building.

To add them to the type I set

fieldDefinition.ContainingTypeDefinition = definingTypeDefinition;

and add the item to the specific collection, in this case

definingTypeDefinition.Fields.Add(fieldDefinition);

Now the problem is that if the items are collected into List<ConcreteDefinitionType> (like List<FieldDefinition> FieldDefinitions) I can set ContainingTypeDefinition but i can't host other kind of IFieldDefinition in the same collection; if I use a list of interfaces, I can host any custom member definition but I can't set ContainingTypeDefinition.

How would you work around this problem?

An additional set of mutable interface would be acceptable or would break some design requirement?

Thanks!