I am working on some T4 code generation, for this I need the CodeClass of the type that is passed inside the constructor of BarAttribute.
class Baz { }
class Bar : Attribute { public Bar (Type type) { } }
[Bar(typeof(Baz))]
public class Foo
{
}
This is what I have so far inside my T4 Template, I just give the CodeAttribute '[Bar(typeof(Baz))]' to the function:
private CodeClass GetType(CodeElement codeElement)
{
CodeAttribute attribute = (CodeAttribute)codeElement;
if (attribute.Name == "Bar")
{
foreach (CodeElement child in attribute.Children)
{
EnvDTE80.CodeAttributeArgument attributeArg = (EnvDTE80.CodeAttributeArgument)child;
WriteLine(attributeArg.Value);
}
}
return null;
}
The function now will just write: typeof(Baz), how can I get the CodeClass of Baz (which can be inside another assembly within the solution) without iterating thru all Projects, ProjectItems, CodeElements, etc?