public T4PreprocessingResult Preprocess(IT4File file) { Logger.Verbose("Preprocessing a file"); var psiSourceFile = file.PhysicalPsiSourceFile.NotNull(); var projectFile = psiSourceFile.ToProjectFile().NotNull(); var solution = file.GetSolution(); var contextFreeTree = psiSourceFile.BuildT4Tree(); var location = new T4FileLocation(solution.GetComponent <ProjectModelViewHost>().GetIdByItem(projectFile)); try { string message = new T4CSharpPreprocessedCodeGenerator(contextFreeTree, solution).Generate().RawText; solution.Locks.ExecuteOrQueueEx(solution.GetLifetime(), "T4 template preprocessing", () => { using (WriteLockCookie.Create()) { TargetFileManager.SavePreprocessResults(file, message); } }); return(new T4PreprocessingResult(location, true, new List <T4BuildMessage>())); } catch (T4OutputGenerationException e) { var message = BuildMessageConverter.ToT4BuildMessages(e.FailureDatum.AsEnumerable()); return(new T4PreprocessingResult(location, false, message)); } }
// When execution is said to succeed, we still cannot be sure whether temporary file exists or not. // If the process being executed was the debugger process, // it would exit normally even if the process it was debugging // (i.e. the generated transformation process) crashed private void ExecutionSucceeded([NotNull] IT4File file) { Logger.Verbose("Execution of a file succeeded"); Logger.Catch(() => { // This call is not expected to fail, but just in case using (WriteLockCookie.Create()) { TargetFileManager.TryProcessExecutionResults(file); } }); ExecutionManager.OnExecutionFinished(file); }
private T4ConfigurationModel CalculateConfiguration([NotNull] IT4File file) => new T4ConfigurationModel( TargetFileManager.GetTemporaryExecutableLocation(file).FullPath.Replace("\\", "/"), TargetFileManager.GetExpectedTemporaryTargetFileLocation(file).FullPath.Replace("\\", "/"), ExecutionManager.GetEnvDTEPort(file) );