protected override bool GenerateInternal(string inputFilePath, string inputFileContent, Project project, string defaultNamespace, Action<SingleFileGeneratorError> onError, out string generatedContent)
        {
            if (IsSharePointFeature(inputFileContent))
            {
                StringBuilder sharePointFeatureComment = new StringBuilder();
                sharePointFeatureComment.AppendFormat("/*SpecFlow tried to generate a test class file, but {0} appears to be a SharePoint feature.", Path.GetFileName(inputFilePath));
                sharePointFeatureComment.AppendLine("  The SpecFlow test class was not be generated in order to avoid errors in the SharePoint proejct*/");
                generatedContent = sharePointFeatureComment.ToString();
                return true;
            }

            var ideSingleFileGenerator = new IdeSingleFileGenerator();

            ideSingleFileGenerator.GenerationError +=
                delegate(TestGenerationError error)
                    {
                        onError(new SingleFileGeneratorError(error.Line, error.LinePosition, error.Message));
                    };
            ideSingleFileGenerator.OtherError +=
                delegate(Exception exception)
                    {
                        onError(new SingleFileGeneratorError(GetMessage(exception)));
                    };

            string outputContent = null;
            string outputFilePath = ideSingleFileGenerator.GenerateFile(inputFilePath, null, GeneratorServicesProvider(project), _ => inputFileContent, (_, oc) => { outputContent = oc; });

            generatedContent = outputContent;

            return outputFilePath != null;
        }
Exemplo n.º 2
0
        public void GenerateCode(FileProjectItem item, CustomToolContext context)
		{
            context.RunAsync(() =>
            {
                var ideSingleFileGenerator = new IdeSingleFileGenerator();

                string outputFilePath = context.GetOutputFileName(item, ".feature");
                ideSingleFileGenerator.GenerateFile(item.FileName, outputFilePath, () => new SharpDevelop4GeneratorServices(item.Project));

                WorkbenchSingleton.SafeThreadCall(
                    () => context.EnsureOutputFileIsInProject(item, outputFilePath));
            });
		}
Exemplo n.º 3
0
		public IAsyncOperation Generate(IProgressMonitor monitor, ProjectFile featureFile, SingleFileCustomToolResult result)
		{
			return new ThreadAsyncOperation(() => {
				
                var ideSingleFileGenerator = new IdeSingleFileGenerator();

                ideSingleFileGenerator.GenerationError += 
                    delegate(TestGenerationError error)
                        {
                            result.Errors.Add(new CompilerError(featureFile.Name, error.Line + 1, error.LinePosition + 1, "0", error.Message));
                        };
                ideSingleFileGenerator.OtherError += 
                    delegate(Exception exception)
                        {
                            result.UnhandledException = exception;
                        };

                string outputFilePath = ideSingleFileGenerator.GenerateFile(featureFile.FilePath, null, () => new MonoDevelopGeneratorServices(featureFile.Project));
				result.GeneratedFilePath = outputFilePath;
				
			}, result);
		}