in Backend/RiderPlugin/ForTea.RiderPlugin/TemplateProcessing/Managing/Impl/T4TargetFileManager.cs [207:231]
public void SavePreprocessResults(IT4File file, string text)
{
Locks.AssertReadAccessAllowed();
var sourceFile = file.PhysicalPsiSourceFile.NotNull();
var projectFile = sourceFile.ToProjectFile().NotNull();
Locks.AssertWriteAccessAllowed();
VirtualFileSystemPath destinationLocation = null;
IProjectFile destination = null;
Solution.InvokeUnderTransaction(cookie =>
{
string destinationName = GetPreprocessingTargetFileName(file);
destination = GetOrCreateSameDestinationFile(cookie, file, destinationName);
destinationLocation = destination.Location;
RemoveLastGenOutputIfDifferent(file, cookie, destinationLocation);
TemplateMetadataManager.UpdateTemplateMetadata(
cookie,
projectFile,
T4TemplateKind.Preprocessed,
destinationLocation
);
TemplateMetadataManager.UpdateGeneratedFileMetadata(cookie, destination, projectFile);
});
destinationLocation.WriteAllText(text);
OutputFileRefresher.Refresh(destination);
}