Skip to content
This repository was archived by the owner on Nov 7, 2019. It is now read-only.

Commit ad62ce7

Browse files
committed
Version bump and style fixes
1 parent 9c670e8 commit ad62ce7

File tree

7 files changed

+25
-19
lines changed

7 files changed

+25
-19
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Update your project:
5050

5151
```xml
5252
<ItemGroup>
53-
<DotNetCliToolReference Include="SpecFlow.NetCore" Version="1.3.3" />
53+
<DotNetCliToolReference Include="SpecFlow.NetCore" Version="1.3.4" />
5454
</ItemGroup>
5555
```
5656

samples/VS2017/SpecFlow 2.1.0/net461/Sample.Website.Tests.MsTest/Sample.Website.Tests.MSTest.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
</Target>
3737

3838
<ItemGroup>
39-
<DotNetCliToolReference Include="SpecFlow.NetCore" Version="1.3.3" />
39+
<DotNetCliToolReference Include="SpecFlow.NetCore" Version="1.3.4" />
4040
</ItemGroup>
4141

4242
</Project>

samples/VS2017/SpecFlow 2.1.0/net461/Sample.Website.Tests.NUnit/Sample.Website.Tests.NUnit.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
</Target>
3737

3838
<ItemGroup>
39-
<DotNetCliToolReference Include="SpecFlow.NetCore" Version="1.3.3" />
39+
<DotNetCliToolReference Include="SpecFlow.NetCore" Version="1.3.4" />
4040
</ItemGroup>
4141

4242
</Project>

samples/VS2017/SpecFlow 2.1.0/net461/Sample.Website.Tests.XUnit/Sample.Website.Tests.XUnit.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
</Target>
3737

3838
<ItemGroup>
39-
<DotNetCliToolReference Include="SpecFlow.NetCore" Version="1.3.3" />
39+
<DotNetCliToolReference Include="SpecFlow.NetCore" Version="1.3.4" />
4040
</ItemGroup>
4141

4242
</Project>

src/SpecFlow.NetCore/AppConfig.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ public static AppConfig CreateIn(DirectoryInfo directory, FileInfo csproj, strin
5353

5454
Content = string.Format(Content, testFramework);
5555

56-
// fixes SpecFlow Scenario Outline scenarios appearing under the project they belong to.
57-
// see https://github.com/stajs/SpecFlow.NetCore/issues/34 and https://github.com/techtalk/SpecFlow/issues/275
56+
// Fixes SpecFlow Scenario Outline scenarios appearing under the project they belong to.
57+
// See https://github.com/stajs/SpecFlow.NetCore/issues/34 and https://github.com/techtalk/SpecFlow/issues/275.
5858
if (testFramework.ToLower() == "mstest")
5959
Content = Content.Replace("</specFlow>", " <generator allowDebugGeneratedFiles=\"true\" />\r\n </specFlow>");
6060

@@ -143,6 +143,5 @@ private static IEnumerable<string> GetProjectPackageReferences(string csproj)
143143

144144
return packageReferences;
145145
}
146-
147146
}
148147
}

src/SpecFlow.NetCore/Args.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public Args(string[] args)
2727
if (args == null || !args.Any())
2828
return;
2929

30-
// establish a dictionary of all good command line variables
30+
// Establish a dictionary of all good command line variables.
3131
var argDictionary = new Dictionary<string, string>
3232
{
3333
{ SpecFlowPathArgName, null },

src/SpecFlow.NetCore/Fixer.cs

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ private static string FindSpecFlow(string version)
4646
var userProfile = Environment.GetEnvironmentVariable("USERPROFILE");
4747

4848
if (string.IsNullOrWhiteSpace(userProfile))
49-
{
5049
userProfile = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
51-
}
5250

5351
path = Path.Combine(userProfile, ".nuget", "packages", relativePathToSpecFlow);
5452

@@ -64,29 +62,37 @@ private static bool TryGetSpecFlowVersion(FileInfo csproj, out string version)
6462
doc.Load(csproj.FullName);
6563

6664
var root = doc.DocumentElement;
67-
var node = root.SelectSingleNode("//ItemGroup/PackageReference[translate(@Include, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')='specflow']"); // case-insensitive for XPath version 1.0
65+
66+
// Case-insensitive for XPath version 1.0
67+
var node = root.SelectSingleNode("//ItemGroup/PackageReference[translate(@Include, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')='specflow']");
68+
6869
if (node == null)
6970
{
70-
if (TryGetSpecflowVersionFromImports(csproj, root, out version))
71+
if (TryGetSpecFlowVersionFromImports(csproj, root, out version))
7172
return true;
7273

7374
version = default(string);
7475
return false;
7576
}
77+
7678
version = node.Attributes["Version"].Value;
7779
return true;
7880
}
7981

80-
private static bool TryGetSpecflowVersionFromImports(FileInfo csproj, XmlElement root, out string version)
82+
private static bool TryGetSpecFlowVersionFromImports(FileInfo csproj, XmlElement root, out string version)
8183
{
8284
var importNodes = root.SelectNodes("//Import");
85+
8386
foreach (XmlNode import in importNodes)
8487
{
8588
var relativePath = import.Attributes["Project"].Value;
8689
var fullPath = Path.Combine(csproj.DirectoryName, relativePath);
90+
8791
if (!File.Exists(fullPath))
8892
continue;
93+
8994
var importInfo = new FileInfo(fullPath);
95+
9096
if (TryGetSpecFlowVersion(importInfo, out version))
9197
return true;
9298
}
@@ -107,9 +113,7 @@ public IEnumerable<FileInfo> GetFeatureFromLinks(FileInfo csproj)
107113
var include = node.Attributes["Include"].Value;
108114

109115
if (File.Exists(include) && Path.GetExtension(include).Equals(".feature", StringComparison.OrdinalIgnoreCase))
110-
{
111116
yield return new FileInfo(include);
112-
}
113117
}
114118
}
115119

@@ -128,6 +132,7 @@ public void Fix(DirectoryInfo directory)
128132
EnsureSpecFlow(csproj);
129133

130134
var fakeCsproj = SaveFakeCsProj(directory, csproj);
135+
131136
try
132137
{
133138
GenerateSpecFlowGlue(directory, fakeCsproj, csproj);
@@ -136,6 +141,7 @@ public void Fix(DirectoryInfo directory)
136141
{
137142
DeleteFakeCsProj(fakeCsproj);
138143
}
144+
139145
FixTests(directory);
140146

141147
if (missingGeneratedFiles.Any())
@@ -150,19 +156,17 @@ private void EnsureSpecFlow(FileInfo csproj)
150156
if (string.IsNullOrWhiteSpace(_specFlowExe))
151157
{
152158
if (!TryGetSpecFlowVersion(csproj, out _specFlowVersion))
153-
{
154159
throw new XmlException("Could not get SpecFlow version from: " + csproj.FullName);
155-
}
156160

157161
_specFlowExe = FindSpecFlow(_specFlowVersion);
158162
WriteLine("Found: " + _specFlowExe);
163+
159164
return;
160165
}
161166

162167
if (File.Exists(_specFlowExe))
163-
{
164168
return;
165-
}
169+
166170
throw new FileNotFoundException("Path to SpecFlow was supplied as an argument, but doesn't exist: " + _specFlowExe);
167171
}
168172

@@ -209,6 +213,7 @@ private static string FixXunit(string content)
209213
{
210214
content = content.Replace(" : Xunit.IUseFixture<", " : Xunit.IClassFixture<");
211215
content = content.Replace("[Xunit.Extensions", "[Xunit");
216+
212217
return content;
213218
}
214219

@@ -223,10 +228,12 @@ private void RunSpecFlow(string csproj)
223228
{
224229
// Credit: http://www.marcusoft.net/2010/12/specflowexe-and-mstest.html
225230
var arguments = "generateall ";
231+
226232
// Version 2.4.0 and higher require the -p parameter
227233
// Version 2.3.2 and below cannot work with the -p parameter so we can't add
228234
var projectParameterVersion = Version.Parse("2.4.0");
229235
var localSpecFlowVersion = Version.Parse(_specFlowVersion);
236+
230237
if (localSpecFlowVersion >= projectParameterVersion)
231238
arguments += $@"-p ""{csproj}"" --force --verbose";
232239
else

0 commit comments

Comments
 (0)