I'm implementing some fairly straight forward code generation using T4, but I'm stuck on a basic problem when it comes to the details of Property generation. When I access the Type property on the CodeProperty objects I want to generate, they are returning 'System.__ComObject' instead of the actual type of the property.
I'm using EnvDTE to find all classes in the project that include my custom attribute. I'm using this to mark certain classes for code generation. So far so good. I'm then stepping over all the CodeElement objects that are the Children of my class. I can find all the properties, it's just I can't get the 'Type' of them.
Here's a snippet of my T4:
public class <#= cls.Name #>_DTO
{
<#
foreach (CodeElement child in cls.Children)
{
if (child.Kind == vsCMElement.vsCMElementProperty)
{
var prop = child as CodeProperty;
#>
public <#= prop.Type.ToString() + " " + child.Name #> { get; set; }
<#
}
}
}
#>
And a sample of the output is:
public class TestResult_DTO
{
public System.__ComObject TestType { get; set; }
}
As you can see, I'm close to valid output, it's just the Type of the property that I'm struggling to access.