public string FormatAst(Feature feature)
        {
            var result = new StringBuilder();

            FormatFeature(feature, result);
            return(LineEndingHelper.NormalizeLineEndings(result.ToString()));
        }
Beispiel #2
0
        public static string GenerateAst(string featureFilePath)
        {
            var parser        = new Parser();
            var parsingResult = parser.Parse(featureFilePath);

            if (parsingResult == null)
            {
                throw new InvalidOperationException("parser returned null");
            }

            var jsonSerializerSettings = new JsonSerializerSettings();

            jsonSerializerSettings.Formatting        = Formatting.Indented;
            jsonSerializerSettings.NullValueHandling = NullValueHandling.Ignore;
            jsonSerializerSettings.ContractResolver  = new FeatureAstJSonContractResolver();
            var astText = JsonConvert.SerializeObject(parsingResult, jsonSerializerSettings);

            return(LineEndingHelper.NormalizeJSonLineEndings(astText));
        }