Skip to content

Commit

Permalink
Use language extension for default filename when preprocessing
Browse files Browse the repository at this point in the history
Fixes #130
  • Loading branch information
mhutch committed Oct 5, 2022
1 parent 917e516 commit 0e13af0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions dotnet-t4/TextTransform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,11 @@ static int MainInternal (string [] args)
}

bool writeToStdout = outputFile == "-" || (inputIsFromStdin && string.IsNullOrEmpty (outputFile));
bool isDefaultOutputFilename = false;

if (!writeToStdout && string.IsNullOrEmpty (outputFile)) {
outputFile = inputFile;
isDefaultOutputFilename = true;
if (Path.HasExtension (outputFile)) {
var dir = Path.GetDirectoryName (outputFile);
var fn = Path.GetFileNameWithoutExtension (outputFile);
Expand Down Expand Up @@ -225,6 +227,9 @@ static int MainInternal (string [] args)
} else {
SplitClassName (preprocessClassName, settings);
outputContent = generator.PreprocessTemplate (pt, inputFile, inputContent, settings, out _);
if (isDefaultOutputFilename) {
outputFile = Path.ChangeExtension (outputFile, settings.Provider.FileExtension);
}
}
}

Expand Down

0 comments on commit 0e13af0

Please sign in to comment.