Skip to content

Commit

Permalink
Fix output extension directive and add test
Browse files Browse the repository at this point in the history
Fixes #142
  • Loading branch information
mhutch committed Oct 28, 2022
1 parent 927d5f1 commit da00afe
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions Mono.TextTemplating.Tests/ProcessingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
using System.CodeDom.Compiler;
using System.IO;
using System.Linq;
using System.Reflection.Emit;
using System.Threading.Tasks;

using Xunit;
Expand Down Expand Up @@ -117,6 +118,22 @@ public async Task SetLangVersionViaAdditionalArgsInProcess ()
}
#endif

[Fact]
public async Task SetOutputExtension ()
{
string inputContent = "<#@ output extension=\".cfg\" #>";
string inputFile = "hello.tt";
string outputName = "hello.txt";

// this reproduces the calls made by dotnet-t4
var gen = new TemplateGenerator ();
var pt = gen.ParseTemplate (inputFile, inputContent);
TemplateSettings settings = TemplatingEngine.GetSettings (gen, pt);
(outputName, _) = await gen.ProcessTemplateAsync (pt, inputFile, inputContent, outputName, settings);

Assert.Equal ("hello.cfg", outputName);
}

[Fact]
public async Task ImportReferencesTest ()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public string PreprocessTemplate (

var outputContent = await Engine.ProcessTemplateAsync (pt, inputContent, settings, this, token).ConfigureAwait (false);

return (outputFileName, outputContent);
return (OutputFile, outputContent);
}

#region Virtual members
Expand Down

0 comments on commit da00afe

Please sign in to comment.