Using extension methods from EnvDTEExtensions in custom Scaffolders

Oct 21, 2012 at 11:07 PM
Edited Oct 21, 2012 at 11:08 PM

I'm trying to use GetEligibleProperties helper method in my t4 template but I'm always getting this error:

error CS1061: Compiling transformation: 'EnvDTE.CodeProperty' does not contain a definition for 'IsScaffoldable' and no extension method 'IsScaffoldable' accepting a first argument of type 'EnvDTE.CodeProperty' could be found (are you missing a using directive or an assembly reference?)

At the beginning of my template I have the following import statements:

 

<#@ import namespace="T4Scaffolding.Core.EnvDTE" #>
<#@ assembly name="T4Scaffolding" #>

 

I have also included T4Scaffolding.dll in my custom scaffolder project.

Helper method:

// Helper
List<ModelProperty> GetEligibleProperties(EnvDTE.CodeType typeInfo, bool includeUnbindableProperties) {
    List<ModelProperty> results = new List<ModelProperty>();
    if (typeInfo != null) {
        foreach (var prop in typeInfo.VisibleMembers().OfType<EnvDTE.CodeProperty>()) {
            if (prop.IsReadable() && !prop.HasIndexParameters() && prop.IsScaffoldable() && (includeUnbindableProperties || IsBindableType(prop.Type))) {
                results.Add(new ModelProperty {
                    Name = prop.Name,
                    ValueExpression = "Model." + prop.Name,
                    Type = prop.Type,
                    IsPrimaryKey = Model.PrimaryKeyName == prop.Name,
                    IsForeignKey = ParentRelations.Any(x => x.RelationProperty == prop),
                    IsReadOnly = !prop.IsWriteable()
                });
            }
        }
    }

    return results;
}

 

 

 

Nov 2, 2012 at 1:15 AM

Hi jernejg

Did you find a solution to the problem?

Thanks!

 

Nov 3, 2012 at 1:11 PM

No, for now I just deleted the call to prop.IsScaffoldable()