Extension Methods in T4

I try to use PGK.Extensions in the T4 template in VS2008 for VB.NET, and I get:

RemoveAllSpecialCharacters is not a member of the string ..

My T4 headers:

<#@ template language="VB" hostspecific="false" debug="true" inherits="Microsoft.VisualStudio.TextTemplating.VSHost.ModelingTextTransformation" #>
<#@ output extension="vb" #>

<#@ assembly name="PGK.Extensions.dll" #> // the dll is found
<#@ import namespace="StringExtensions" #> //Try with and without namespace

Using the extension in block code:

<#
   Me.WriteLine(item.Name.RemoveAllSpecialCharacters.ToUpper)
#>

RemoveAllSpecialCharacters is a line extension method from PGK.Extensions.dll.

Can someone help me?

Edition:

OK It:

<#@ template language="VBv3.5" ...

But this breaks down the DevArt T4 Editor intellisense and syntax underscore in the VS2008 plugin. Use the Tangible T4 Editor instead.

+5
source share
2 answers

, , . Microsoft .

item.Name.RemoveAllSpecialCharacters() StringExtensions.RemoveAllSpecialCharacters(item.Name)

( , ):

<#
    StringExtensions.RemoveAllSpecialCharacters(item.Name).ToUpper()
#>

, .

+1

, ( @jlvaquero ).

, vars,

 <#@ assembly name="$(ProjectDir)$(OutDir)\AssemblyName.dll" #>
+2

All Articles