Skip to content

Commit 4c7f5d9

Browse files
committed
Revert MultipleOutputHelper.ttinclude to original from nuget.
* Move back to project root. * Revert modifications (adding the using() pattern) * Update usages
1 parent 77313b5 commit 4c7f5d9

File tree

3 files changed

+8
-36
lines changed

3 files changed

+8
-36
lines changed

Src/UnitsNet/GeneratedCode/UnitClasses.tt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<#@ import namespace="UnitsNet.Units" #>
44
<#@ import namespace="UnitsNet.Attributes" #>
55
<#@ import namespace="UnitsNet.Templating" #>
6-
<#@ include file="Includes\MultipleOutputHelper.ttinclude" once="true"#>
6+
<#@ include file="..\MultipleOutputHelper.ttinclude" once="true"#>
77
<#@ output extension=".g.cs" #>
88
<#
99
var assembly = Assembly.GetAssembly(typeof (LengthUnit));
@@ -12,16 +12,17 @@
1212
var m = Manager.Create(Host, GenerationEnvironment);
1313
foreach (UnitClassInfo info in infos)
1414
{
15+
m.StartNewFile(info.UnitClassName + ".g.cs");
1516
GenerateUnitClass(m, info.UnitClassName, info.UnitClassXmlDoc, info.BaseUnitName, info.BaseUnitPluralName, info.UnitEnumType.Name, info.OrderedUnits);
17+
m.EndBlock();
1618
}
1719

1820
m.Process(split: true);
1921

2022
#><#+
2123
private void GenerateUnitClass(Manager manager, string className, string xmlDocSummary, string baseUnitName, string baseUnitPluralName, string unitEnumName, ICollection<UnitInfo> orderedClassUnits)
2224
{
23-
using (manager.StartNewFile(className + ".g.cs"))
24-
{
25+
2526
List<UnitInfo> orderedClassUnitsExceptBaseUnit =
2627
orderedClassUnits
2728
.Where(val => val.SingularName != baseUnitName)
@@ -371,7 +372,6 @@ namespace UnitsNet
371372
}
372373
}
373374
<#+
374-
} // using
375375
} // GenerateUnitClass()
376376
#>
377377
<#+
Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,10 @@ class Manager {
3636
return (host is IServiceProvider) ? new VSManager(host, template) : new Manager(host, template);
3737
}
3838

39-
40-
public IDisposable StartNewFile(String name) {
39+
public void StartNewFile(String name) {
4140
if (name == null)
4241
throw new ArgumentNullException("name");
4342
CurrentBlock = new Block { Name = name };
44-
return new StartNewFileBlock(this);
4543
}
4644

4745
public void StartFooter() {
@@ -154,7 +152,7 @@ class Manager {
154152
projectSyncAction = (IEnumerable<String> keepFileNames) => ProjectSync(templateProjectItem, keepFileNames);
155153
}
156154

157-
private void ProjectSync(EnvDTE.ProjectItem templateProjectItem, IEnumerable<String> keepFileNames) {
155+
private static void ProjectSync(EnvDTE.ProjectItem templateProjectItem, IEnumerable<String> keepFileNames) {
158156
var keepFileNameSet = new HashSet<String>(keepFileNames);
159157
var projectFiles = new Dictionary<String, EnvDTE.ProjectItem>();
160158
var originalFilePrefix = Path.GetFileNameWithoutExtension(templateProjectItem.get_FileNames(0)) + ".";
@@ -169,18 +167,7 @@ class Manager {
169167
// Add missing files to the project
170168
foreach(String fileName in keepFileNameSet)
171169
if (!projectFiles.ContainsKey(fileName))
172-
{
173-
// Remove any "..\" in path when outputting to parent folder by getting full path.
174-
// Source: http://stackoverflow.com/a/4796339/134761
175-
string fileNameFullPath = Path.GetFullPath(new Uri(fileName).LocalPath);
176-
177-
// Output as item in same folder as template file.
178-
//templateProjectItem.Collection.AddFromFile(fileNameFullPath);
179-
180-
// Output as nested item under template file
181-
templateProjectItem.ProjectItems.AddFromFile(fileNameFullPath);
182-
}
183-
170+
templateProjectItem.ProjectItems.AddFromFile(fileName);
184171
}
185172

186173
private void CheckoutFileIfRequired(String fileName) {
@@ -189,19 +176,4 @@ class Manager {
189176
checkOutAction.EndInvoke(checkOutAction.BeginInvoke(fileName, null, null));
190177
}
191178
}
192-
193-
private class StartNewFileBlock : IDisposable
194-
{
195-
private readonly Manager _manager;
196-
197-
public StartNewFileBlock(Manager manager)
198-
{
199-
_manager = manager;
200-
}
201-
202-
public void Dispose()
203-
{
204-
_manager.EndBlock();
205-
}
206-
}
207179
} #>

Src/UnitsNet/UnitsNet.net35.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
<Compile Include="Vector3.cs" />
124124
</ItemGroup>
125125
<ItemGroup>
126-
<None Include="GeneratedCode\Includes\MultipleOutputHelper.ttinclude" />
126+
<None Include="MultipleOutputHelper.ttinclude" />
127127
<None Include="GeneratedCode\UnitClasses.tt">
128128
<Generator>TextTemplatingFileGenerator</Generator>
129129
<LastGenOutput>UnitClasses.g.cs</LastGenOutput>

0 commit comments

Comments
 (0)