I have a class that I created using CodeDOM:
CodeTypeDeclaration some_class = new CodeTypeDeclaration("SomeClass");
// ... properties and methods creation elided
I want to create a List of the "SomeClass" type. However, I can't seem to do so:
var list_type = new CodeTypeReference(typeof (List<>).Name, ??? some_class ???);
var member_field = new CodeMemberField(list_type, field_name)
{
Attributes = MemberAttributes.Private,
};
CodeTypeReference doesn't accept a CodeTypeDeclaration
, which is what I need. What can I do? I don't want to pass the class name as a string, since this could lead to errors.
typeof(list<>)
relies on reflection to retrieve the name; but I see your point... I could use list_type.Name, right? – Baron