Features > Features
As a developer
I can generate code with the T4.FileManager with each class in its own file
Acceptance criterias 10/10 (100%)
Duration
Background
Given the file manager
00:00.101
Given the script "Test.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ output extension=".txt" #>
<#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #>
<#
var files = new string[] { "PersonDto", "OrderDto" };
var fileManager = T4FileManager.Create(this);
foreach(var itm in files)
{
fileManager.CreateNewFile(itm + ".g.cs", "","");
#>
namespace Test
{
public class <#= itm #>
{
}
}
<#
}
fileManager.Generate();
#>
00:00.587
When I run the script
00:02.183
Then the following files are generated:
File |
PersonDto.g.cs |
OrderDto.g.cs |
00:00.000
Background
Given the file manager
00:00.007
Given the script "TestTFM.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ output extension=".txt" #>
<#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #>
<#
var files = new string[] { "TFMPersonDto", "TFMOrderDto" };
var fileManager = T4FileManager.Create(this);
foreach(var itm in files)
{
fileManager.StartNewFile(itm + ".g.cs", "","");
#>
namespace Test
{
public class <#= itm #>
{
}
}
<#
}
fileManager.Process();
#>
00:00.600
When I run the script
00:02.186
Then the following files are generated:
File |
TFMPersonDto.g.cs |
TFMOrderDto.g.cs |
00:00.000
Background
Given the file manager
00:00.231
Given the script "TestMissingFileExtension.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #>
<#
var files = new string[] { "PersonTxtDto", "OrderTxtDto" };
var fileManager = T4FileManager.Create(this);
foreach(var itm in files)
{
fileManager.CreateNewFile(itm + ".g.cs", "","");
#>
namespace Test
{
public class <#= itm #>
{
}
}
<#
}
fileManager.Generate();
#>
00:00.809
When I run the script
00:00.268
Then the following files are generated:
File |
PersonTxtDto.g.cs |
OrderTxtDto.g.cs |
TestMissingFileExtension.txt |
00:00.000
Background
Given the file manager
00:01.000
Given the script "TestCsExtension.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ output extension=".cs" #> <# /* **** <====== is ignored **** */ #>
<#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #>
<#
var files = new string[] { "PersonCsDto", "OrderCsDto" };
var fileManager = T4FileManager.Create(this);
foreach(var itm in files)
{
fileManager.CreateNewFile(itm + ".g.cs", "","");
#>
namespace Test
{
public class <#= itm #>
{
}
}
<#
}
fileManager.Generate();
#>
00:00.887
When I run the script
00:00.246
Then the following files are generated:
File |
PersonCsDto.g.cs |
OrderCsDto.g.cs |
TestCsExtension.txt |
00:00.002
Background
Given the file manager
00:00.312
Given the script "TestInvalidFileExtension.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ output extension=".txt" #>
<#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #>
<#
var files = new string[] { "PersonIvDto", "OrderIvDto" };
var fileManager = T4FileManager.Create(this).DisableTemplateMainOutputFile(); // <=== prevent main output file
foreach(var itm in files)
{
fileManager.CreateNewFile(itm + ".g.cs", "","");
#>
namespace Test
{
public partial class <#= itm #>
{
}
}
<#
}
fileManager.Generate();
#>
00:00.618
When I run the script
00:00.203
Then the following files are generated:
File |
PersonIvDto.g.cs |
OrderIvDto.g.cs |
00:00.000
But the following files are not generated:
File |
TestInvalidFileExtension.txt |
00:00.001
Background
Given the file manager
00:27.017
Given the script "TestAutoIndent.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ output extension=".txt" #>
<#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #>
<#
var files = new string[] { "FileFormat" };
var fileManager = T4FileManager.Create(this).EnableAutoIndent(); // <=== Enable Format Document
foreach(var itm in files)
{
fileManager.CreateNewFile(itm + ".g.cs", "","");
#>
namespace Test
{
public partial class <#= itm #>
{
public int Id {get; set;}
public string Name {get; set;}
}
}
<#
}
fileManager.Generate();
#>
00:11.542
When I run the script
00:03.346
Then the file "FileFormat.g.cs" has following format:
namespace Test
{
public partial class FileFormat
{
public int Id { get; set; }
public string Name { get; set; }
}
}
00:00.225
Background
Given the file manager
00:00.250
Given the script "TestDefaultEncoding.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ output extension=".txt" #>
<#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #>
<#
var files = new string[] { "FileDefaultEncoding" };
var fileManager = T4FileManager.Create(this);
foreach(var itm in files)
{
fileManager.StartNewFile(itm + ".g.cs", "","");
#>
namespace Test
{
public partial class <#= itm #>
{
public int Id {get; set;}
}
}
<#
}
fileManager.Process();
#>
00:00.777
When I run the script
00:00.179
Then the file "FileDefaultEncoding.g.cs" is encoded in "UTF-8"
00:00.015
Background
Given the file manager
00:00.099
Given the script "TestUTF16Encoding.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ output extension=".txt" #>
<#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #>
<#
var files = new string[] { "TestUTF16Encoding" };
var fileManager = T4FileManager.Create(this).EnableLog().SetOutputFileEncoding(Encoding.Unicode); // <=== Set encoding for output file
foreach(var itm in files)
{
fileManager.StartNewFile(itm + ".g.cs", "","");
#>
namespace Test
{
public partial class <#= itm #>
{
public int Id {get; set;}
}
}
<#
}
fileManager.Process();
#>
00:00.643
When I run the script
00:00.179
Then the file "TestUTF16Encoding.g.cs" is encoded in "UTF-16"
00:00.012
Background
Given the file manager
00:00.334
Given the script "TestBigEndianEncoding.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ output extension=".txt" #>
<#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #>
<#
var files = new string[] { "TesBigEndianEncoding" };
var fileManager = T4FileManager.Create(this).EnableLog().SetOutputFileEncoding(Encoding.BigEndianUnicode);
foreach(var itm in files)
{
fileManager.StartNewFile(itm + ".g.sql", "","");
#>
SELECT 'öäüé' <#=itm#>
<#
}
fileManager.Process();
#>
00:00.834
When I run the script
00:02.298
Then the file "TesBigEndianEncoding.g.sql" is encoded in "UTF-16BE"
00:00.016
Background
Given the file manager
00:00.008
Given the script "TestSystemXml.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ assembly name="System.Xml" #>
<#@ assembly name="System.Xml.Linq" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Xml" #>
<#@ import namespace="System.Xml.Linq" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ output extension=".txt" #>
<#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #>
<# var fileManager = T4FileManager.Create(this).EnableAutoIndent(); #>
<#
fileManager.StartNewFile("text.xml", "","");
var doc = new XmlDocument();
doc.LoadXml("<book>Reading</book>");
#>
<#=doc.InnerXml#>
<#
fileManager.Process();
#>
00:07.314
When I run the script
00:09.060
Then the following files are generated:
00:00.000
Features > Features
As a developer
I can generate code with the T4.FileManager with each class in its own file in a subfolder
Acceptance criterias 2/2 (100%)
Duration
Background
Given the file manager
00:00.006
Given the script "TestSubfolder.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ output extension=".txt" #>
<#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #>
<#
var files = new string[] { "PersonDto", "OrderDto" };
var fileManager = new T4FileManager(this);
foreach(var itm in files)
{
fileManager.StartNewFile(itm + ".g.cs","","TestSubfolder");
#>
namespace Test.TestSubFolder
{
public class <#= itm #>
{
}
}
<#
}
fileManager.Process();
#>
00:00.550
When I run the script
00:02.214
Then the following files are generated:
File |
Folder |
PersonDto.g.cs |
TestSubfolder |
OrderDto.g.cs |
TestSubfolder |
00:00.000
Background
Given the file manager
00:00.022
Given the script "TestSubfolderMoving.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ output extension=".txt" #>
<#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #>
<#
var files = new string[] { "PersonMDto", "OrderMDto" };
var fileManager = new T4FileManager(this);
foreach(var itm in files)
{
fileManager.StartNewFile(itm + ".g.cs","","TestSubfolder");
#>
namespace Test.TestSubFolder
{
public class <#= itm #>
{
}
}
<#
}
fileManager.Process();
#>
00:00.550
When I run the script
00:02.176
And I change the line
From |
To |
fileManager.StartNewFile(itm + ".g.cs","","TestSubfolder"); |
fileManager.StartNewFile(itm + ".g.cs","","TestSubfolderNew"); |
00:00.920
And I run the script again
00:00.074
Then the following files are generated:
File |
Folder |
PersonMDto.g.cs |
TestSubfolderNew |
OrderMDto.g.cs |
TestSubfolderNew |
00:00.000
And the following files no longer exist:
File |
Folder |
PersonMDto.g.cs |
TestSubfolder |
OrderMDto.g.cs |
TestSubfolder |
00:00.000
Features > Features
As a developer
I can generate code with the T4.FileManager with each class in its own file or in different projects
Acceptance criterias 1/1 (100%)
Duration
Given the file manager
00:00.025
And the script "TestInOtherProject.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ output extension=".txt" #>
<#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #>
<#
var files = new string[] { "PersonDto", "OrderDto" };
var fileManager = new T4FileManager(this);
foreach(var itm in files)
{
fileManager.CreateNewFile(itm + ".g.cs","T4.FileManager.VisualStudio.AcceptanceCriteria.ExampleTestProject","");
#>
namespace Test
{
public class <#= itm #>
{
}
}
<#
}
fileManager.Generate();
#>
00:00.639
And I select the target project "T4.FileManager.VisualStudio.AcceptanceCriteria.ExampleTestProject"
00:00.000
When I run the script
00:00.176
Then the following files are generated:
File |
PersonDto.g.cs |
OrderDto.g.cs |
00:00.000
Features > Features
As a developer
I can generate code with the T4.FileManager and definied custom tool properties
Acceptance criterias 4/4 (100%)
Duration
Background
Given the file manager
00:00.087
Background
Given the file manager
00:00.006
Given the script "ProjectTestFP.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ output extension=".txt" #>
<#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #>
<#
var document = new List<string[]>();
document.Add(new string[] { "FirstName", "Vorname", "Angaben zum Vornamen"});
document.Add(new string[] { "LastName", "Nachname", "Angaben zum Nachnamen"});
document.Add(new string[] { "Street", "Strasse", "Angaben zur Strasse"});
var fileManager = TemplateFileManager.Create(this);
var fp = new FileProperties();
fp.CustomTool = "ResXFileCodeGenerator";
fileManager.CreateNewFile("ProjectTestFP.resx", "", "", fp); // <-- use method of FileProperties only (since Version 2.0.0)
#>
<?xml version="1.0" encoding="utf-8"?>
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<#
for (int idx = 0; idx < document.Count; idx++)
{
var item = document[idx];
#>
<data name="<#= item[0] #>" xml:space="preserve">
<value><#= item[1] #></value>
<comment><#= item[2] #></comment>
</data>
<#} #>
</root>
<#
fileManager.Generate();
#>
00:01.043
When I run the script
00:02.180
Then the following files are generated:
File |
ProjectTestFP.resx |
ProjectTestFP.Designer.cs |
00:00.000
And the custom tool is set to "ResXFileCodeGenerator" for the following files:
00:00.209
Background
Given the file manager
00:00.017
Given the script "TestTFMCustomTool.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ output extension=".txt" #>
<#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #>
<#
var document = new List<string[]>();
document.Add(new string[] { "FirstName", "Vorname", "Angaben zum Vornamen"});
document.Add(new string[] { "LastName", "Nachname", "Angaben zum Nachnamen"});
document.Add(new string[] { "Street", "Strasse", "Angaben zur Strasse"});
var fileManager = TemplateFileManager.Create(this);
var fp = new FileProperties();
fp.CustomTool = "ResXFileCodeGenerator";
fileManager.StartNewFile("ProjectTestTFM.resx", "", "", fp); //<-- Backward compatibility for TemplateFileManager
#>
<?xml version="1.0" encoding="utf-8"?>
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<#
for (int idx = 0; idx < document.Count; idx++)
{
var item = document[idx];
#>
<data name="<#= item[0] #>" xml:space="preserve">
<value><#= item[1] #></value>
<comment><#= item[2] #></comment>
</data>
<#} #>
</root>
<#
fileManager.Process();
#>
00:00.717
When I run the script
00:02.210
Then the following files are generated:
File |
ProjectTestTFM.resx |
ProjectTestTFM.Designer.cs |
00:00.000
And the custom tool is set to "ResXFileCodeGenerator" for the following files:
00:00.194
Background
Given the file manager
00:00.018
Given the script "GenerateEmbeddedResource.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #>
<#@ output extension=".txt" #>
<#
var outputContent = @"[""generated1"",""generated2""]";
var fileName = "data.json";
var project = "T4.FileManager.VisualStudio.AcceptanceCriteria.ExampleTestProject";
var projectPath = "Data";
var manager = T4FileManager.Create(this);
manager.EnableLog();
var embeddedProperties = new FileProperties(){BuildAction = BuildAction.EmbeddedResource};
manager.CreateNewFile(fileName, project, projectPath, embeddedProperties);
#>
<#= outputContent #>
<#
manager.FinishFile();
manager.Process();
#>
00:00.717
Then the following files with BuildAction exists:
File |
Project |
BuildAction |
data.json |
T4.FileManager.VisualStudio.AcceptanceCriteria.ExampleTestProject |
EmbeddedResource |
data.json |
T4.FileManager.VisualStudio.AcceptanceCriteria |
None |
00:00.084
Features > Features
As a developer
I can generate code with the T4.FileManager using a standard header
Acceptance criterias 3/3 (100%)
Duration
Background
Given the file manager
00:00.007
Given the script "TestGlobalHeader.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ output extension=".txt" #>
<#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #>
<#
var fileManager = T4FileManager.Create(this);
fileManager.StartHeader();
#>
// -------------------------
// databinding - T4
// -------------------------
<#
fileManager.FinishHeader();
fileManager.CreateNewFile("PersonDtoWithGlobal.g.cs","","");
#>
namespace Test
{
public class PersonDtoWithGlobal
{
}
}
<#
fileManager.CreateNewFile("OrderDtoWithGlobal.g.cs","","");
#>
namespace Test
{
public class OrderDtoWithGlobal
{
}
}
<#
fileManager.Generate();
#>
00:00.548
When I run the script
00:02.190
Then the file "PersonDtoWithGlobal.g.cs" starts with header:
// -------------------------
// databinding - T4
// -------------------------
00:00.012
And the file "PersonDtoWithGlobal.g.cs" starts with header:
// -------------------------
// databinding - T4
// -------------------------
00:00.000
Background
Given the file manager
00:00.019
Given the script "TestSA1633Header.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ output extension=".txt" #>
<#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #>
<#
var fileManager = T4FileManager.Create(this);
fileManager.StartHeader();
#>
// <copyright file="$filename$" company="databinding.gmbh">
// databinding.gmbh - All rights reserved.
// </copyright>
// <author>Mr. T4</author>
<#
fileManager.FinishHeader();
fileManager.CreateNewFile("PersonDtoWithSA1633.g.cs","","");
#>
namespace Test
{
public class PersonDtoWithHeader
{
}
}
<#
fileManager.CreateNewFile("OrderDtoWithSA1633.g.cs","","");
#>
namespace Test
{
public class OrderDtoWithHeader
{
}
}
<#
fileManager.Generate();
#>
00:00.556
When I run the script
00:02.205
Then the file "PersonDtoWithSA1633.g.cs" starts with header:
// <copyright file="PersonDtoWithSA1633.g.cs" company="databinding.gmbh">
// databinding.gmbh - All rights reserved.
// </copyright>
// <author>Mr. T4</author>
00:00.013
And the file "OrderDtoWithSA1633.g.cs" starts with header:
// <copyright file="OrderDtoWithSA1633.g.cs" company="databinding.gmbh">
// databinding.gmbh - All rights reserved.
// </copyright>
// <author>Mr. T4</author>
00:00.011
Background
Given the file manager
00:00.006
Given the script "TestSA1633HeaderTFM.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ output extension=".txt" #>
<#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #>
<#
var fileManager = T4FileManager.Create(this);
fileManager.StartHeader();
#>
// <copyright file="$filename$" company="databinding.gmbh">
// databinding.gmbh - All rights reserved.
// </copyright>
// <author>Mr. T4</author>
<#
fileManager.EndBlock();
fileManager.CreateNewFile("PersonDtoWithSA1633TFM.g.cs","","");
#>
namespace Test
{
public class PersonDtoWithHeader
{
}
}
<#
fileManager.CreateNewFile("OrderDtoWithSA1633TFM.g.cs","","");
#>
namespace Test
{
public class OrderDtoWithHeader
{
}
}
<#
fileManager.Process();
#>
00:00.639
When I run the script
00:02.198
Then the file "PersonDtoWithSA1633TFM.g.cs" starts with header:
// <copyright file="PersonDtoWithSA1633TFM.g.cs" company="databinding.gmbh">
// databinding.gmbh - All rights reserved.
// </copyright>
// <author>Mr. T4</author>
00:00.013
And the file "OrderDtoWithSA1633TFM.g.cs" starts with header:
// <copyright file="OrderDtoWithSA1633TFM.g.cs" company="databinding.gmbh">
// databinding.gmbh - All rights reserved.
// </copyright>
// <author>Mr. T4</author>
00:00.012
Features > Features
As a developer
I can generate code with the T4.FileManager without taking care of old generated files
Acceptance criterias 1/1 (100%)
Duration
Background
Given the file manager
00:00.012
And the script "TestOldFilesCleanUp.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ output extension=".txt" #>
<#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #>
<#
var fileManager = T4FileManager.Create(this);
fileManager.CreateNewFile("TestOldFilesCleanUp.g.cs","","");
#>
namespace Test
{
public class TestOldFilesCleanUp
{
}
}
<#
fileManager.Generate();
#>
00:00.593
When I run the script
00:02.197
Then the following files are generated:
File |
TestOldFilesCleanUp.g.cs |
00:00.000
Given I change the line
From |
To |
fileManager.CreateNewFile("TestOldFilesCleanUp.g.cs","","") |
fileManager.CreateNewFile("TestOldFilesCleanUpRenamed.g.cs","","") |
00:00.545
When I run the script
00:00.066
Then the following files are cleaned up:
File |
TestOldFilesCleanUp.g.cs |
00:00.000
And the following files are generated:
File |
TestOldFilesCleanUpRenamed.g.cs |
00:00.000
Features > Features
As a developer
I can generate code with the T4.FileManager and supress changes if the file exist
Acceptance criterias 2/2 (100%)
Duration
Background
Given the file manager
00:00.012
And the script "TestNoDelete.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ output extension=".txt" #>
<#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #>
<#
var fileManager = T4FileManager.Create(this).DisableOverwriteExistingFile();
fileManager.CreateNewFile("TestNoDelete.g.cs","","TestOverwrite");
#>
namespace Test
{
public class TestNoDelete
{
// first run template
}
}
<#
fileManager.Generate();
#>
00:00.012
Given I run the script
00:00.060
And the following files are generated:
File |
Folder |
TestNoDelete.g.cs |
TestOverwrite |
00:00.000
And I change the line
From |
To |
fileManager.CreateNewFile("TestNoDelete.g.cs","","TestOverwrite"); |
fileManager.CreateNewFile("TestNoDelete2.g.cs","","TestOverwrite"); |
public class TestNoDelete |
public class TestNoDelete2 |
00:00.601
When I run the script
00:00.062
Then the following files are generated:
File |
Folder |
TestNoDelete.g.cs |
TestOverwrite |
TestNoDelete2.g.cs |
TestOverwrite |
00:00.000
Background
Given the file manager
00:00.006
And the script "TestNoDelete.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ output extension=".txt" #>
<#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #>
<#
var fileManager = T4FileManager.Create(this).DisableOverwriteExistingFile();
fileManager.CreateNewFile("TestNoDelete.g.cs","","TestOverwrite");
#>
namespace Test
{
public class TestNoDelete
{
// first run template
}
}
<#
fileManager.Generate();
#>
00:00.622
Given I run the script
00:02.192
And the following files are generated:
File |
Folder |
TestNoDelete.g.cs |
TestOverwrite |
00:00.000
And I change the line
From |
To |
// first run template |
// second run template |
00:00.233
When I run the script
00:00.060
Then the following files are generated:
File |
Contains |
Folder |
TestNoDelete.g.cs |
// first run template |
TestOverwrite |
00:00.013
Features > Features
As a developer
I can change the behaviour of supress changes to overwrite existing files
Acceptance criterias 1/1 (100%)
Duration
Background
Given the file manager
00:00.006
And the script "TestDelete.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ output extension=".txt" #>
<#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #>
<#
var fileManager = T4FileManager.Create(this).DisableOverwriteExistingFile();
fileManager.CreateNewFile("TestDelete.g.cs","","TestOverwrite");
#>
namespace Test
{
public class TestDelete
{
// first run template
}
}
<#
fileManager.Generate();
#>
00:00.534
Given I run the script
00:02.260
And the following files are generated:
File |
Folder |
TestDelete.g.cs |
TestOverwrite |
00:00.000
And I change the line
From |
To |
T4FileManager.Create(this).DisableOverwriteExistingFile(); |
T4FileManager.Create(this); |
fileManager.CreateNewFile("TestDelete.g.cs","","TestOverwrite"); |
fileManager.CreateNewFile("TestNoDelete3.g.cs","","TestOverwrite"); |
public class TestDelete |
public class NewTestDeleteModel |
00:01.008
When I run the script
00:00.074
Then the following files are generated:
File |
Folder |
TestNoDelete3.g.cs |
TestOverwrite |
00:00.000
And the following files are cleaned up:
File |
Folder |
TestDelete.g.cs |
TestOverwrite |
00:00.000
Features > Features
As a developer
I can log to the main output file
so that I can analyze the generation process
Acceptance criterias 2/2 (100%)
Duration
Background
Given the file manager
00:00.009
Given the script "TestWithLogEnabled.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ output extension=".txt" #>
<#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #>
<#
var files = new string[] { "PersonDto", "OrderDto" };
var fileManager = new T4FileManager(this).EnableLog(); // <-- log output to main file TestWithLogEnabled.txt
foreach(var itm in files)
{
fileManager.CreateNewFile(itm + ".g.cs", "", "TestSubfolder");
#>
namespace Test
{
public class <#= itm #>
{
}
}
<#
}
fileManager.Generate();
#>
00:00.603
When I run the script
00:00.191
Then the file "TestWithLogEnabled.txt" contains following log fragments
Textfragment |
Log to main output file enabled |
Begin CreateNewFile PersonDto.g.cs |
Start DeleteExistingFiles |
2 files generated |
00:00.011
Background
Given the file manager
00:00.009
Given the script "TestWithCustomLog.tt" with the following content
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ output extension=".txt" #>
<#@ include file="$(ProjectDir)\T4.FileManager.VisualStudio.ttinclude" #>
<#
var files = new string[] { "PersonDto", "OrderDto" };
var fileManager = new T4FileManager(this).EnableLog(); // <-- log output to main file TestWithLogEnabled.txt
foreach(var itm in files)
{
fileManager.CreateNewFile(itm + ".g.cs", "", "TestSubfolder");
#>
namespace Test
{
public class <#= itm #>
{
<# fileManager.Log("My custom log info for {0}", itm); #>
}
}
<#
}
fileManager.Generate();
#>
00:00.559
When I run the script
00:02.201
Then the file "TestWithCustomLog.txt" contains following log fragments
Textfragment |
My custom log info for OrderDto |
My custom log info for PersonDto |
00:00.011