Denis Evseev
Denis Evseev

Reputation: 1710

How get type of property in CodeProperty ? T4

I included VisualStudioHelper. Here I getting all my classes by Attribute

var classesWithMapAttribute = VisualStudioHelper.GetClassesByAttributeName("Map", projectName);

After that I getting all properties in the Class.

    foreach (CodeClass pi in classesWithMapAttribute)
{ 
   var allProperties = VisualStudioHelper.GetAllCodeElementsOfType(pi.Members, vsCMElement.vsCMElementProperty, true);
}

That work perfectly. But I need get Types of properties. If I call

foreach(CodeProperty property in allPropertiesDto)
        {
             <#= property.Type #>
         }

I'll get System.__ComObject as result

Could you tell me, how get nested type of property ?

Upvotes: 4

Views: 811

Answers (2)

Denis Evseev
Denis Evseev

Reputation: 1710

I am ashamed that can't found answer before...

CodeTypeRef codeTypeRef = property.Type;
codeTypeRef.AsString // here we get type of property

Upvotes: 1

VERYNET
VERYNET

Reputation: 541

You can try this :

Type t = property.PropertyType; // That will return a System.string

Upvotes: 2

Related Questions