private void GenerateCode(FilePath classFullPath, string eventName) { _taskFactory.StartNew(() => { pMixinsOnSolutionOpenCodeGenerator.OnSolutionOpeningTask.Wait(); using (new LoggingActivity("GenerateCode - " + eventName + " -- " + classFullPath)) try { //Generate code for the file saved var currentFileContext = _codeGeneratorContextFactory.GenerateContext( s => s.GetValidPMixinFiles() .Where(f => f.FileName.Equals(classFullPath))) .ToArray(); if (currentFileContext.Length == 0) { _log.InfoFormat("No code will be genereated for [{0}]", classFullPath); _responseFileWriter.ClearCodeBehindForSourceFile(classFullPath); } else { _visualStudioCodeGenerator .GenerateCode(currentFileContext) .Map(_responseFileWriter.WriteCodeGeneratorResponse); } //Generate code for dependencies var filesToUpdate = _codeGeneratorDependencyManager.GetFilesThatDependOn(classFullPath); if (_log.IsDebugEnabled) { _log.DebugFormat("Will update [{0}]", string.Join(Environment.NewLine, filesToUpdate.Select(x => x.FileName))); } _visualStudioCodeGenerator .GenerateCode( _codeGeneratorContextFactory.GenerateContext(filesToUpdate)) .MapParallel(_responseFileWriter.WriteCodeGeneratorResponse); } catch (Exception exc) { _log.Error("Exception in HandleProjectItemSaved", exc); } }); }