Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.

Commit

Permalink
gherkin: Update .NET
Browse files Browse the repository at this point in the history
  • Loading branch information
aslakhellesoy committed Jun 15, 2018
1 parent 55ab34d commit 879c1ec
Show file tree
Hide file tree
Showing 58 changed files with 537 additions and 1,295 deletions.
2 changes: 1 addition & 1 deletion Gherkin.CLI/Gherkin.CLI.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="../netfx.props" />
<PropertyGroup>
<OutputType>exe</OutputType>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp2.0;net45</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
Expand Down
10 changes: 5 additions & 5 deletions Gherkin.CSharp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26730.12
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Gherkin", "Gherkin\Gherkin.csproj", "{2FF8C8E3-D3D1-452D-8BA7-358035FEC064}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gherkin", "Gherkin\Gherkin.csproj", "{2FF8C8E3-D3D1-452D-8BA7-358035FEC064}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Gherkin.CLI", "Gherkin.CLI\Gherkin.CLI.csproj", "{19BEC00D-448A-44BF-9E9D-4B75849C9A57}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gherkin.CLI", "Gherkin.CLI\Gherkin.CLI.csproj", "{19BEC00D-448A-44BF-9E9D-4B75849C9A57}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Gherkin.Specs", "Gherkin.Specs\Gherkin.Specs.csproj", "{A0DEA4BA-3A79-4C05-87F2-7C7C9DE8B245}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gherkin.Specs", "Gherkin.Specs\Gherkin.Specs.csproj", "{A0DEA4BA-3A79-4C05-87F2-7C7C9DE8B245}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Gherkin.TokensGenerator", "Gherkin.TokensGenerator\Gherkin.TokensGenerator.csproj", "{4725D7DF-7488-41CC-8F30-90C6A5FB463A}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gherkin.TokensGenerator", "Gherkin.TokensGenerator\Gherkin.TokensGenerator.csproj", "{4725D7DF-7488-41CC-8F30-90C6A5FB463A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Gherkin.TokensGeneratorLib", "Gherkin.TokensGeneratorLib\Gherkin.TokensGeneratorLib.csproj", "{77918F35-3CB3-4A62-95F9-438804A2BF02}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gherkin.TokensGeneratorLib", "Gherkin.TokensGeneratorLib\Gherkin.TokensGeneratorLib.csproj", "{77918F35-3CB3-4A62-95F9-438804A2BF02}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
2 changes: 1 addition & 1 deletion Gherkin.TokensGenerator/Gherkin.TokensGenerator.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="../netfx.props" />
<PropertyGroup>
<OutputType>exe</OutputType>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp2.0;net45</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Gherkin/Ast/Background.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace Gherkin.Ast
{
public class Background : ScenarioDefinition
public class Background : StepsContainer
{
public Background(Location location, string keyword, string name, string description, Step[] steps)
: base(location, keyword, name, description, steps)
Expand Down
4 changes: 2 additions & 2 deletions Gherkin/Ast/Feature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ public class Feature : IHasLocation, IHasDescription, IHasTags
public string Keyword { get; private set; }
public string Name { get; private set; }
public string Description { get; private set; }
public IEnumerable<ScenarioDefinition> Children { get; private set; }
public IEnumerable<StepsContainer> Children { get; private set; }

public Feature(Tag[] tags, Location location, string language, string keyword, string name, string description, ScenarioDefinition[] children)
public Feature(Tag[] tags, Location location, string language, string keyword, string name, string description, StepsContainer[] children)
{
Tags = tags;
Location = location;
Expand Down
6 changes: 4 additions & 2 deletions Gherkin/Ast/Scenario.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@

namespace Gherkin.Ast
{
public class Scenario : ScenarioDefinition, IHasTags
public class Scenario : StepsContainer, IHasTags
{
public IEnumerable<Tag> Tags { get; private set; }
public IEnumerable<Examples> Examples { get; private set; }

public Scenario(Tag[] tags, Location location, string keyword, string name, string description, Step[] steps)
public Scenario(Tag[] tags, Location location, string keyword, string name, string description, Step[] steps, Examples[] examples)
: base(location, keyword, name, description, steps)
{
Tags = tags;
Examples = examples;
}
}
}
17 changes: 0 additions & 17 deletions Gherkin/Ast/ScenarioOutline.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

namespace Gherkin.Ast
{
public abstract class ScenarioDefinition : IHasLocation, IHasDescription, IHasSteps
public abstract class StepsContainer : IHasLocation, IHasDescription, IHasSteps
{
public Location Location { get; private set; }
public string Keyword { get; private set; }
public string Name { get; private set; }
public string Description { get; private set; }
public IEnumerable<Step> Steps { get; private set; }

protected ScenarioDefinition(Location location, string keyword, string name, string description, Step[] steps)
protected StepsContainer(Location location, string keyword, string name, string description, Step[] steps)
{
Location = location;
Keyword = keyword;
Expand Down
51 changes: 15 additions & 36 deletions Gherkin/AstBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,47 +85,31 @@ private object GetTransformedNode(AstNode node)
var steps = GetSteps(node);
return CreateBackground(GetLocation(backgroundLine), backgroundLine.MatchedKeyword, backgroundLine.MatchedText, description, steps, node);
}
case RuleType.Scenario_Definition:
case RuleType.ScenarioDefinition:
{
var tags = GetTags(node);

var scenarioNode = node.GetSingle<AstNode>(RuleType.Scenario);
if (scenarioNode != null)
{
var scenarioLine = scenarioNode.GetToken(TokenType.ScenarioLine);

var description = GetDescription(scenarioNode);
var steps = GetSteps(scenarioNode);

return CreateScenario(tags, GetLocation(scenarioLine), scenarioLine.MatchedKeyword, scenarioLine.MatchedText, description, steps, node);
}
else
{
var scenarioOutlineNode = node.GetSingle<AstNode>(RuleType.ScenarioOutline);
if (scenarioOutlineNode == null)
throw new InvalidOperationException("Internal gramar error");
var scenarioOutlineLine = scenarioOutlineNode.GetToken(TokenType.ScenarioOutlineLine);
var scenarioLine = scenarioNode.GetToken(TokenType.ScenarioLine);

var description = GetDescription(scenarioOutlineNode);
var steps = GetSteps(scenarioOutlineNode);
var examples = scenarioOutlineNode.GetItems<Examples>(RuleType.Examples_Definition).ToArray();

return CreateScenarioOutline(tags, GetLocation(scenarioOutlineLine), scenarioOutlineLine.MatchedKeyword, scenarioOutlineLine.MatchedText, description, steps, examples, node);
}
var description = GetDescription(scenarioNode);
var steps = GetSteps(scenarioNode);
var examples = scenarioNode.GetItems<Examples>(RuleType.ExamplesDefinition).ToArray();
return CreateScenario(tags, GetLocation(scenarioLine), scenarioLine.MatchedKeyword, scenarioLine.MatchedText, description, steps, examples, node);
}
case RuleType.Examples_Definition:
case RuleType.ExamplesDefinition:
{
var tags = GetTags(node);
var examplesNode = node.GetSingle<AstNode>(RuleType.Examples);
var examplesLine = examplesNode.GetToken(TokenType.ExamplesLine);
var description = GetDescription(examplesNode);

var allRows = examplesNode.GetSingle<TableRow[]>(RuleType.Examples_Table);
var allRows = examplesNode.GetSingle<TableRow[]>(RuleType.ExamplesTable);
var header = allRows != null ? allRows.First() : null;
var rows = allRows != null ? allRows.Skip(1).ToArray() : null;
return CreateExamples(tags, GetLocation(examplesLine), examplesLine.MatchedKeyword, examplesLine.MatchedText, description, header, rows, node);
}
case RuleType.Examples_Table:
case RuleType.ExamplesTable:
{
return GetTableRows(node);
}
Expand All @@ -140,18 +124,18 @@ private object GetTransformedNode(AstNode node)
}
case RuleType.Feature:
{
var header = node.GetSingle<AstNode>(RuleType.Feature_Header);
var header = node.GetSingle<AstNode>(RuleType.FeatureHeader);
if(header == null) return null;
var tags = GetTags(header);
var featureLine = header.GetToken(TokenType.FeatureLine);
if(featureLine == null) return null;
var children = new List<ScenarioDefinition> ();
var children = new List<StepsContainer> ();
var background = node.GetSingle<Background>(RuleType.Background);
if (background != null)
{
children.Add (background);
}
var childrenEnumerable = children.Concat(node.GetItems<ScenarioDefinition>(RuleType.Scenario_Definition));
var childrenEnumerable = children.Concat(node.GetItems<StepsContainer>(RuleType.ScenarioDefinition));
var description = GetDescription(header);
if(featureLine.MatchedGherkinDialect == null) return null;
var language = featureLine.MatchedGherkinDialect.Language;
Expand Down Expand Up @@ -184,19 +168,14 @@ protected virtual Comment CreateComment(Location location, string text)
return new Comment(location, text);
}

protected virtual ScenarioOutline CreateScenarioOutline(Tag[] tags, Location location, string keyword, string name, string description, Step[] steps, Examples[] examples, AstNode node)
{
return new ScenarioOutline(tags, location, keyword, name, description, steps, examples);
}

protected virtual Examples CreateExamples(Tag[] tags, Location location, string keyword, string name, string description, TableRow header, TableRow[] body, AstNode node)
{
return new Examples(tags, location, keyword, name, description, header, body);
}

protected virtual Scenario CreateScenario(Tag[] tags, Location location, string keyword, string name, string description, Step[] steps, AstNode node)
protected virtual Scenario CreateScenario(Tag[] tags, Location location, string keyword, string name, string description, Step[] steps, Examples[] examples, AstNode node)
{
return new Scenario(tags, location, keyword, name, description, steps);
return new Scenario(tags, location, keyword, name, description, steps, examples);
}

protected virtual DocString CreateDocString(Location location, string contentType, string content, AstNode node)
Expand All @@ -213,7 +192,7 @@ protected virtual GherkinDocument CreateGherkinDocument(Feature feature, Comment
return new GherkinDocument(feature, gherkinDocumentComments);
}

protected virtual Feature CreateFeature(Tag[] tags, Location location, string language, string keyword, string name, string description, ScenarioDefinition[] children, AstNode node)
protected virtual Feature CreateFeature(Tag[] tags, Location location, string language, string keyword, string name, string description, StepsContainer[] children, AstNode node)
{
return new Feature(tags, location, language, keyword, name, description, children);
}
Expand Down
12 changes: 6 additions & 6 deletions Gherkin/Gherkin.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="../netfx.props"/>
<Import Project="../netfx.props" />
<PropertyGroup>
<TargetFrameworks>netstandard1.5;net45</TargetFrameworks>
</PropertyGroup>
Expand All @@ -12,7 +12,7 @@
<Title>Gherkin Parser</Title>
<Description>Cross-platform parser for the Gherkin language, used by Cucumber, SpecFlow and other Cucumber-based tools to parse feature files.</Description>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<Copyright>Copyright &#xA9; Cucumber Ltd, Gaspar Nagy</Copyright>
<Copyright>Copyright © Cucumber Ltd, Gaspar Nagy</Copyright>
<PackageTags>specflow gherkin cucumber</PackageTags>
<PackageProjectUrl>https://github.com/cucumber/cucumber/tree/master/gherkin</PackageProjectUrl>
<PackageIconUrl>https://cucumber.io/images/cucumber-mark-32x32.png</PackageIconUrl>
Expand All @@ -21,12 +21,12 @@
</PropertyGroup>

<ItemGroup>
<None Remove="gherkin-languages.json"/>
<None Remove="gherkin-languages.json" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="gherkin-languages.json"/>
<EmbeddedResource Include="gherkin-languages.json" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="10.0.3"/>
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
</ItemGroup>
</Project>
Loading

0 comments on commit 879c1ec

Please sign in to comment.