public DiscoveryResult RunDiscovery(string testAssemblyPath, string configFilePath) { var workingDirectory = Path.GetDirectoryName(testAssemblyPath); var arguments = new List <string>(); var connectorPath = GetConnectorPath(arguments); arguments.Add("discovery"); arguments.Add(testAssemblyPath); arguments.Add(configFilePath); if (DebugConnector) { arguments.Add("--debug"); } if (!File.Exists(connectorPath)) { return new DiscoveryResult { ErrorMessage = $"Error during binding discovery. Unable to find connector: {connectorPath}" } } ; var result = ProcessHelper.RunProcess(workingDirectory, connectorPath, arguments, encoding: Encoding.UTF8); if (result.ExitCode != 0) { var errorMessage = result.HasErrors ? result.StandardError : "Unknown error."; return(new DiscoveryResult { ErrorMessage = GetDetailedErrorMessage(result, errorMessage, BindingDiscoveryCommandName) }); } _logger.LogVerbose(connectorPath); #if DEBUG _logger.LogVerbose(result.StandardOut); #endif var discoveryResult = JsonSerialization.DeserializeObjectWithMarker <DiscoveryResult>(result.StandardOut); if (discoveryResult.IsFailed) { discoveryResult.ErrorMessage = GetDetailedErrorMessage(result, discoveryResult.ErrorMessage, BindingDiscoveryCommandName); } return(discoveryResult); }
public GenerationResult GenerateFeatureFile(string featureFilePath, string targetExtension, string targetNamespace) { var projectSettings = _projectScope.GetProjectSettings(); var specFlowToolsFolder = GetSpecFlowToolsFolderSafe(_projectScope, projectSettings, out var toolsFolderErrorMessage); if (specFlowToolsFolder == null) { return(CreateErrorResult(featureFilePath, $"Unable to use SpecFlow tools folder '{projectSettings.SpecFlowGeneratorFolder}': {toolsFolderErrorMessage}")); } var stopwatch = new Stopwatch(); stopwatch.Start(); try { var connector = OutProcSpecFlowConnectorFactory.Create(_projectScope); var result = connector.RunGenerator(featureFilePath, projectSettings.SpecFlowConfigFilePath, targetExtension, targetNamespace, _projectScope.ProjectFolder, specFlowToolsFolder); _projectScope.IdeScope.MonitoringService.MonitorSpecFlowGeneration(result.IsFailed, projectSettings); if (result.IsFailed) { _logger.LogWarning(result.ErrorMessage); SetErrorContent(featureFilePath, result); _logger.LogVerbose(() => result.FeatureFileCodeBehind.Content); } else { _logger.LogInfo($"code-behind file generated for file {featureFilePath} in project {_projectScope.ProjectName}"); _logger.LogVerbose(() => result.FeatureFileCodeBehind.Content.Substring(0, Math.Min(450, result.FeatureFileCodeBehind.Content.Length))); } return(result); } catch (Exception ex) { _logger.LogException(MonitoringService, ex); return(CreateErrorResult(featureFilePath, ex.Message)); } finally { stopwatch.Stop(); _logger.LogVerbose($"Generation: {stopwatch.ElapsedMilliseconds} ms"); } }
private IMonitoringService GetSafeMonitoringService(IServiceProvider serviceProvider) { try { var safeMonitoringService = VsUtils.ResolveMefDependency <IMonitoringService>(serviceProvider); if (safeMonitoringService != null) { _safeLogger.LogVerbose("Monitoring service loaded"); } return(safeMonitoringService ?? NullVsIdeScope.GetNullMonitoringService()); } catch { return(NullVsIdeScope.GetNullMonitoringService()); } }
public bool ParseAndCollectErrors(string featureFileContent, IDeveroomLogger logger, out DeveroomGherkinDocument gherkinDocument, out List <ParserException> parserErrors) { var reader = new StringReader(featureFileContent); gherkinDocument = null; parserErrors = new List <ParserException>(); try { gherkinDocument = Parse(reader, "foo.feature"); //TODO: remove unused path return(true); } catch (ParserException parserException) { logger.LogVerbose($"ParserErrors: {parserException.Message}"); gherkinDocument = GetResultOfInvalid(); if (parserException is CompositeParserException compositeParserException) { parserErrors.AddRange(compositeParserException.Errors); } else { parserErrors.Add(parserException); } } catch (Exception e) { logger.LogException(_monitoringService, e, "Exception during Gherkin parsing"); gherkinDocument = GetResult(); } return(false); }
public GenerationResult GenerateFeatureFile(string featureFilePath, string targetExtension, string targetNamespace) { var projectSettings = _projectScope.GetProjectSettings(); var specFlowToolsFolder = GetSpecFlowToolsFolderSafe(projectSettings); var stopwatch = new Stopwatch(); stopwatch.Start(); try { var connector = new OutProcSpecFlowConnector(_projectScope.GetDeveroomConfiguration(), _logger, projectSettings.TargetFrameworkMoniker, _projectScope.IdeScope.GetExtensionFolder()); var result = connector.RunGenerator(featureFilePath, projectSettings.SpecFlowConfigFilePath, targetExtension, targetNamespace, _projectScope.ProjectFolder, specFlowToolsFolder); _projectScope.IdeScope.MonitoringService.MonitorSpecFlowGeneration(result.IsFailed, projectSettings); if (result.IsFailed) { _logger.LogWarning(result.ErrorMessage); result.FeatureFileCodeBehind = new FeatureFileCodeBehind() { FeatureFilePath = featureFilePath, Content = GetErrorContent(result.ErrorMessage) }; _logger.LogVerbose(() => result.FeatureFileCodeBehind.Content); } else { _logger.LogInfo($"code-behind file generated for file {featureFilePath} in project {_projectScope.ProjectName}"); _logger.LogVerbose(() => result.FeatureFileCodeBehind.Content.Substring(0, Math.Min(450, result.FeatureFileCodeBehind.Content.Length))); } return(result); } catch (Exception ex) { _logger.LogException(MonitoringService, ex); return(null); } finally { stopwatch.Stop(); _logger.LogVerbose($"Generation: {stopwatch.ElapsedMilliseconds} ms"); } }
// this method needs to be static as it is called from the timer, when the core wizard has been disposed already. private static void OpenFile(string targetFile, Project project, IDeveroomLogger logger) { try { var projectItem = VsUtils.FindProjectItemByFilePath(project, targetFile); if (projectItem != null) { //projectItem.Open(); project.DTE.ExecuteCommand("File.OpenFile", targetFile); logger.LogVerbose($"File opened: {targetFile}"); } } catch (Exception ex) { logger.LogDebugException(ex); } }
public ICollection <DeveroomTag> Parse(ITextSnapshot fileSnapshot, ProjectBindingRegistry bindingRegistry, DeveroomConfiguration configuration) { var stopwatch = new Stopwatch(); stopwatch.Start(); try { return(ParseInternal(fileSnapshot, bindingRegistry, configuration)); } catch (Exception ex) { _logger.LogException(_monitoringService, ex, "Unhandled parsing error"); return(new List <DeveroomTag>()); } finally { stopwatch.Stop(); _logger.LogVerbose($"Parsed buffer v{fileSnapshot.Version.VersionNumber} in {stopwatch.ElapsedMilliseconds}ms on thread {Thread.CurrentThread.ManagedThreadId}"); } }
private void DocumentEventsOnDocumentOpened(Document document) { _logger.LogVerbose($"{document.FullName}, {document.Type}"); DocumentOpened?.Invoke(document); }