コード例 #1
0
        private void HandleException(Exception ex, ProjectFile file, SingleFileCustomToolResult result)
        {
            if (ex is SpecFlowParserException)
            {
                SpecFlowParserException sfpex = (SpecFlowParserException)ex;

                if (sfpex.ErrorDetails == null || sfpex.ErrorDetails.Count == 0)
                {
                    result.UnhandledException = ex;
                }
                else
                {
                    var compilerErrors = new CompilerErrorCollection();

                    foreach (var errorDetail in sfpex.ErrorDetails)
                    {
                        var compilerError = new CompilerError(file.Name, errorDetail.ForcedLine, errorDetail.ForcedColumn, "0", errorDetail.Message);
                        compilerErrors.Add(compilerError);
                    }

                    result.Errors.AddRange(compilerErrors);
                }
            }
            else
            {
                result.UnhandledException = ex;
            }
        }
コード例 #2
0
        public void WhenIParseTheFile()
        {
            var contentReader = new StringReader(gherkinContent);

            try
            {
                feature = parser.Parse(contentReader, "sample.feature");
            }
            catch (SpecFlowParserException ex)
            {
                parsingErrors = ex;
                Console.WriteLine("-> parsing errors");
                foreach (ErrorDetail errorDetail in parsingErrors.ErrorDetails)
                {
                    Console.WriteLine("-> {0}:{1} {2}", errorDetail.Line, errorDetail.Column, errorDetail.Message);
                }
            }
        }
コード例 #3
0
        protected override string GenerateError(Microsoft.VisualStudio.Shell.Interop.IVsGeneratorProgress pGenerateProgress, Exception ex)
        {
            if (ex is SpecFlowParserException)
            {
                SpecFlowParserException sfpex = (SpecFlowParserException)ex;
                if (sfpex.ErrorDetails == null || sfpex.ErrorDetails.Count == 0)
                {
                    return(base.GenerateError(pGenerateProgress, ex));
                }

                foreach (var errorDetail in sfpex.ErrorDetails)
                {
                    pGenerateProgress.GeneratorError(0, 4, errorDetail.Message,
                                                     (uint)errorDetail.ForcedLine - 1,
                                                     (uint)errorDetail.ForcedColumn - 1);
                }

                return(GetMessage(ex));
            }

            return(base.GenerateError(pGenerateProgress, ex));
        }
コード例 #4
0
        public void ParseFile()
        {
            var contentReader = new StringReader(FileContent);

            ParsedFeature = null;
            ParsingErrors = null;

            try
            {
                ParsedFeature = parser.Parse(contentReader, "sample.feature");
                Assert.IsNotNull(ParsedFeature);
                ParsedFeature.SourceFile = null;
            }
            catch (SpecFlowParserException ex)
            {
                ParsingErrors = ex;
                Console.WriteLine("-> parsing errors");
                foreach (ErrorDetail errorDetail in ParsingErrors.ErrorDetails)
                {
                    Console.WriteLine("-> {0}:{1} {2}", errorDetail.Line, errorDetail.Column, errorDetail.Message);
                }
            }
        }