Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tags not accessible for Children of Feature #507

Closed
manasacharyya25 opened this issue Oct 21, 2018 · 7 comments
Closed

Tags not accessible for Children of Feature #507

manasacharyya25 opened this issue Oct 21, 2018 · 7 comments

Comments

@manasacharyya25
Copy link

manasacharyya25 commented Oct 21, 2018

Tags which is a field for each Child of a Feature, is not accessible from code for C# code.

Problem with : Gherkin parser/compiler for .NET.

@xtrasimplicity
Copy link
Member

Hi @manasacharyya25,

Thanks for reporting this. Could you please post a Minimal, Complete, Verifiable example demonstrating this issue?

Thanks!

@manasacharyya25
Copy link
Author

Parser p = new Parser();
string fileName="GherkinFeatureFile.feature";
TextReader gherkinReader = File.OpenText(fileName);
var feature = p.Parse(gherkinReader);               
var child0 = feature.Children.ElementAt(0);        //Returns a ScenarioDefinition

child0.Tags;                                                        //Generates Error

child0.Name;                                                   //Other Fields are Accessible

This workaround however lets me get the task done :

Parser p = new Parser();
string fileName="GherkinFeatureFile.feature";
TextReader gherkinReader = File.OpenText(fileName);
var feature = p.Parse(gherkinReader);               
var child0 = feature.Children.ElementAt(0);               //Returns a ScenarioDefinition
scenario0 = (scenario)child0;                                    //Type Casting to Scenario Type

scenario0.Tags;                                                        //Generates No Error

scenario0.Name;                                                   //Other Fields are Accessible

@SabotageAndi
Copy link
Contributor

@manasacharyya25 You had always to cast the children items to Scenario or ScenarioOutline to get access to the tags.

@manasacharyya25
Copy link
Author

manasacharyya25 commented Nov 5, 2018

@SabotageAndi But why is it implemented this way? Any specific reason.

Btw, Thanks for the comment

@SabotageAndi
Copy link
Contributor

The Gherkin AST is generated from this file: https://github.com/cucumber/cucumber/blob/master/gherkin/gherkin.berp

A feature has different children (FeatureHeader, Background, ScenarioDefinitions and Rules) and not everything has tags. Background as an example.
So you have to do some casting.

@manasacharyya25
Copy link
Author

@SabotageAndi Ok. That makes sense. Thanks :)

@lock
Copy link

lock bot commented Nov 16, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Nov 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants