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

Configuration API & detect SpecFlow version from output folder, fixes #14 #43

Merged
merged 22 commits into from
Jul 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
94d47a1
Add DeveroomConfigurationLoader
gasparnagy Jun 27, 2019
5b48519
remove deps to ProjectSettings.SpecFlowPackage
gasparnagy Jun 27, 2019
d597ccd
remove ProjectSettings.SpecFlowPackage
gasparnagy Jun 27, 2019
5416263
refactor SpecFlow settings detection
gasparnagy Jun 27, 2019
bd09d26
Add ConfigFilePath to SpecFlowSettings
gasparnagy Jun 27, 2019
d278f8d
extract ProjectSettingsProvider
gasparnagy Jun 27, 2019
6d85381
Use VS assemblies for stubbing from the internal folder by default
gasparnagy Jun 28, 2019
7abf99a
Load SpecFlow settings from config
gasparnagy Jun 28, 2019
d84d0f0
Use https://www.nuget.org/packages/Equ for generating equals
gasparnagy Jul 1, 2019
c720050
Make Equ strong named
gasparnagy Jul 2, 2019
8c5226e
Add Equ to vsix
gasparnagy Jul 2, 2019
a28a07b
better connector version selector
gasparnagy Jul 2, 2019
0292b6c
rename connector classes and namespaces
gasparnagy Jul 2, 2019
15ad66c
Detect SpecFlow from output folder
gasparnagy Jul 2, 2019
8d77627
Display warning on config load error
gasparnagy Jul 2, 2019
d043139
Default language is not detected for SpecFlow v3 from specflow.json c…
gasparnagy Jul 2, 2019
029204e
Improved error handling for code-behind generation
gasparnagy Jul 2, 2019
8f89a9d
Add deveroom.json config file template
gasparnagy Jul 2, 2019
c1e5e45
Add JSON schema and sample for deveroom.json
gasparnagy Jul 2, 2019
17a31bb
Use myget for custom dependencies
gasparnagy Jul 3, 2019
b98cfbb
Update config and schema
gasparnagy Jul 3, 2019
653a57e
small fixes and Changelog
gasparnagy Jul 3, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,21 @@
New features:

* Provide documentation in autocompletion of keywords (Issue #3)
* Support projects with SpecFlow assembly references (non-NuGet) (Issue #14)
* see http://speclink.me/deveroomsfassref for details
* Deveroom configuration file support
* see http://speclink.me/deveroomconfig for details

Improvements:

* Step completion should use word containment for filtering the list (Issue #28)
* Display warning on config load error
* Improved error handling for code-behind generation

Bug fixes:

* Editor: No syntax coloring when the file ends with doc-string open (Issue #6)
* Default language is not detected for SpecFlow v3 from specflow.json config file

# v1.3.0 - 2019-06-20

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
</PropertyGroup>

<ItemGroup>
<VSTemplate Include="DeveroomConfig_CSharp\DeveroomConfig_CSharp.vstemplate">
<OutputSubPath>Deveroom</OutputSubPath>
</VSTemplate>
<VSTemplate Include="FeatureFile_CSharp\FeatureFile_CSharp.vstemplate">
<OutputSubPath>Deveroom</OutputSubPath>
</VSTemplate>
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<VSTemplate Version="3.0.0" Type="Item" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
<TemplateData>
<DefaultName>deveroom.json</DefaultName>
<Name>Deveroom configuration file</Name>
<Description>A json file containing Deveroom configuration settings. Place it in the project or solution root.</Description>
<ProjectType>CSharp</ProjectType>
<Icon>Deveroom-Icon.ico</Icon>
</TemplateData>
<TemplateContent>
<ProjectItem>deveroom.json</ProjectItem>
</TemplateContent>
</VSTemplate>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$schema": "http://schemas.specsolutions.eu/deveroom-config-latest.json"

// See configuration options and samples at http://speclink.me/deveroomconfig
// or use the auto-complete feature of your IDE to discover configuration options.

// The deveroom configuration file (deveroom.json) can be placed in
// * the project folder -- project-level settings
// * the solution folder -- solution-level settings
// * the %LOCALAPPDATA%\Deveroom\ folder -- user-level settings for this machine


}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
<AdditionalDeveroomDependencies Include="Utf8Json.dll" />
<AdditionalDeveroomDependencies Include="System.Threading.Tasks.Extensions.dll" />
<AdditionalDeveroomDependencies Include="System.IO.Abstractions.dll" />
<AdditionalDeveroomDependencies Include="Equ.dll" />
</ItemGroup>

<Import Project="..\Deveroom.VisualStudio.SpecFlowConnector.V1\DeploymentAssets.props" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Deveroom.VisualStudio.Common;
using Deveroom.VisualStudio.Diagonostics;
using Deveroom.VisualStudio.Editor.Commands;
using Deveroom.VisualStudio.Generation;
using Deveroom.VisualStudio.ProjectSystem;
using Deveroom.VisualStudio.ProjectSystem.Settings;
using EnvDTE;
Expand Down Expand Up @@ -86,6 +87,13 @@ private void InvokeHandler(object sender, EventArgs e)
if (project == null)
return;

var projectScope = _vsIdeScope.GetProjectScope(project);
if (projectScope == null)
return;

if (!GenerationService.CheckSpecFlowToolsFolder(projectScope))
return;

foreach (var featureFileItem in GetFeatureFileItems(project))
{
var vsProjectItem = featureFileItem.Object as VSProjectItem;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System.Diagnostics;
using System.IO;
using Deveroom.VisualStudio.SpecFlowConnector.AppDomainHelper;
using Deveroom.VisualStudio.SpecFlowConnector.Discovery.V1090;
using Deveroom.VisualStudio.SpecFlowConnector.Discovery.V2000;
using Deveroom.VisualStudio.SpecFlowConnector.Discovery.V2010;
using Deveroom.VisualStudio.SpecFlowConnector.Discovery.V2020;
using Deveroom.VisualStudio.SpecFlowConnector.Discovery.V3000;
using Deveroom.VisualStudio.SpecFlowConnector.Discovery.V19;
using Deveroom.VisualStudio.SpecFlowConnector.Discovery.V20;
using Deveroom.VisualStudio.SpecFlowConnector.Discovery.V21;
using Deveroom.VisualStudio.SpecFlowConnector.Discovery.V22;
using Deveroom.VisualStudio.SpecFlowConnector.Discovery.V30;

namespace Deveroom.VisualStudio.SpecFlowConnector.Discovery
{
Expand All @@ -25,25 +25,25 @@ public string Process()
var appDomain = new AppDomainManager(_options.AssemblyFilePath, _options.ConfigFilePath, false, null);

var specFlowVersion = GetSpecFlowVersion();
var discovererType = typeof(SpecFlowV2020Discoverer);
var discovererType = typeof(SpecFlowV30P220Discoverer); // assume recent version
if (specFlowVersion != null)
switch (specFlowVersion.FileMajorPart * 1000 + specFlowVersion.FileMinorPart * 10)
{
case 1090:
discovererType = typeof(SpecFlowV1090Discoverer);
break;
case 2000:
discovererType = typeof(SpecFlowV2000Discoverer);
break;
case 2010:
discovererType = typeof(SpecFlowV2010Discoverer);
break;
case 3000:
discovererType = specFlowVersion.FileBuildPart >= 220 ?
typeof(SpecFlowV3000P220Discoverer) :
typeof(SpecFlowV3000Discoverer);
break;
}
{
var versionNumber =
((specFlowVersion.FileMajorPart * 100) + specFlowVersion.FileMinorPart) * 1000 + specFlowVersion.FileBuildPart;

if (versionNumber >= 3_00_220)
discovererType = typeof(SpecFlowV30P220Discoverer);
else if (versionNumber >= 3_00_000)
discovererType = typeof(SpecFlowV30Discoverer);
else if (versionNumber >= 2_02_000)
discovererType = typeof(SpecFlowV22Discoverer);
else if (versionNumber >= 2_01_000)
discovererType = typeof(SpecFlowV21Discoverer);
else if (versionNumber >= 2_00_000)
discovererType = typeof(SpecFlowV20Discoverer);
else if (versionNumber >= 1_09_000)
discovererType = typeof(SpecFlowV19Discoverer);
}

appDomain.CreateObjectFrom<AssemblyHelper>(typeof(AssemblyHelper).Assembly.Location, typeof(AssemblyHelper).FullName, _options.TargetFolder);
appDomain.CreateObjectFrom<AssemblyHelper>(typeof(AssemblyHelper).Assembly.Location, typeof(AssemblyHelper).FullName, _options.ConnectorFolder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
using TechTalk.SpecFlow.Configuration;
using TechTalk.SpecFlow.Infrastructure;

namespace Deveroom.VisualStudio.SpecFlowConnector.Discovery.V1090
namespace Deveroom.VisualStudio.SpecFlowConnector.Discovery.V19
{
public class SpecFlowV1090Discoverer : RemotingBaseDiscoverer
public class SpecFlowV19Discoverer : RemotingBaseDiscoverer
{
protected override IBindingRegistry GetBindingRegistry(Assembly testAssembly, string configFilePath)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
using TechTalk.SpecFlow.Configuration;
using TechTalk.SpecFlow.Infrastructure;

namespace Deveroom.VisualStudio.SpecFlowConnector.Discovery.V2000
namespace Deveroom.VisualStudio.SpecFlowConnector.Discovery.V20
{
public class SpecFlowV2000Discoverer : RemotingBaseDiscoverer
public class SpecFlowV20Discoverer : RemotingBaseDiscoverer
{
protected override IBindingRegistry GetBindingRegistry(Assembly testAssembly, string configFilePath)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
using TechTalk.SpecFlow.Configuration;
using TechTalk.SpecFlow.Infrastructure;

namespace Deveroom.VisualStudio.SpecFlowConnector.Discovery.V2010
namespace Deveroom.VisualStudio.SpecFlowConnector.Discovery.V21
{
public class SpecFlowV2010Discoverer : RemotingBaseDiscoverer
public class SpecFlowV21Discoverer : RemotingBaseDiscoverer
{
protected override IBindingRegistry GetBindingRegistry(Assembly testAssembly, string configFilePath)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
using TechTalk.SpecFlow.Configuration;
using TechTalk.SpecFlow.Infrastructure;

namespace Deveroom.VisualStudio.SpecFlowConnector.Discovery.V2020
namespace Deveroom.VisualStudio.SpecFlowConnector.Discovery.V22
{
public class SpecFlowV2020Discoverer : RemotingBaseDiscoverer
public class SpecFlowV22Discoverer : RemotingBaseDiscoverer
{
protected override IBindingRegistry GetBindingRegistry(Assembly testAssembly, string configFilePath)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
using TechTalk.SpecFlow.Configuration;
using TechTalk.SpecFlow.Infrastructure;

namespace Deveroom.VisualStudio.SpecFlowConnector.Discovery.V3000
namespace Deveroom.VisualStudio.SpecFlowConnector.Discovery.V30
{
public class SpecFlowV3000Discoverer : SpecFlowV3000P220Discoverer
public class SpecFlowV30Discoverer : SpecFlowV30P220Discoverer
{
protected override object CreateGlobalContainer(IConfigurationLoader configurationLoader, Assembly testAssembly)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
using TechTalk.SpecFlow.Configuration;
using TechTalk.SpecFlow.Infrastructure;

namespace Deveroom.VisualStudio.SpecFlowConnector.Discovery.V3000
namespace Deveroom.VisualStudio.SpecFlowConnector.Discovery.V30
{
public class SpecFlowV3000P220Discoverer : RemotingBaseDiscoverer
public class SpecFlowV30P220Discoverer : RemotingBaseDiscoverer
{
protected override IBindingRegistry GetBindingRegistry(Assembly testAssembly, string configFilePath)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
using System.Diagnostics;
using System.IO;
using Deveroom.VisualStudio.SpecFlowConnector.AppDomainHelper;
using Deveroom.VisualStudio.SpecFlowConnector.Generation.V1090;
using Deveroom.VisualStudio.SpecFlowConnector.Generation.V2020;
using Deveroom.VisualStudio.SpecFlowConnector.Generation.V19;
using Deveroom.VisualStudio.SpecFlowConnector.Generation.V22;

namespace Deveroom.VisualStudio.SpecFlowConnector.Generation
{
Expand All @@ -22,18 +22,19 @@ public string Process()
using (AssemblyHelper.SubscribeResolveForAssembly(generatorAssemblyPath))
{
var specFlowAssemblyPath = Path.Combine(_options.SpecFlowToolsFolder, "TechTalk.SpecFlow.dll");
var fileVersionInfo = File.Exists(specFlowAssemblyPath) ? FileVersionInfo.GetVersionInfo(specFlowAssemblyPath) : null;
var specFlowVersion = File.Exists(specFlowAssemblyPath) ? FileVersionInfo.GetVersionInfo(specFlowAssemblyPath) : null;

var generatorType = typeof(SpecFlowV2020Generator);
if (fileVersionInfo != null)
switch (fileVersionInfo.FileMajorPart * 1000 + fileVersionInfo.FileMinorPart * 10)
{
case 1090:
case 2000:
case 2010:
generatorType = typeof(SpecFlowV1090Generator);
break;
}
var generatorType = typeof(SpecFlowV22Generator);
if (specFlowVersion != null)
{
var versionNumber =
((specFlowVersion.FileMajorPart * 100) + specFlowVersion.FileMinorPart) * 1000 + specFlowVersion.FileBuildPart;

if (versionNumber >= 2_02_000)
generatorType = typeof(SpecFlowV22Generator);
else if (versionNumber >= 1_09_000)
generatorType = typeof(SpecFlowV19Generator);
}

var generator = (ISpecFlowGenerator)Activator.CreateInstance(generatorType);
return generator.Generate(_options.ProjectFolder, _options.ConfigFilePath, _options.TargetExtension, _options.FeatureFilePath, _options.TargetNamespace, _options.ProjectDefaultNamespace, _options.SaveResultToFile);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System.IO;
using TechTalk.SpecFlow.Generator.Interfaces;

namespace Deveroom.VisualStudio.SpecFlowConnector.Generation.V1090
namespace Deveroom.VisualStudio.SpecFlowConnector.Generation.V19
{
public class SpecFlowV1090Generator : BaseGenerator
public class SpecFlowV19Generator : BaseGenerator
{
protected override SpecFlowConfigurationHolder CreateConfigHolder(string configFilePath)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
using TechTalk.SpecFlow.Configuration;
using TechTalk.SpecFlow.Generator.Interfaces;

namespace Deveroom.VisualStudio.SpecFlowConnector.Generation.V2020
namespace Deveroom.VisualStudio.SpecFlowConnector.Generation.V22
{
public class SpecFlowV2020Generator : BaseGenerator
public class SpecFlowV22Generator : BaseGenerator
{
protected override SpecFlowConfigurationHolder CreateConfigHolder(string configFilePath)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
using TechTalk.SpecFlow.Configuration;
using TechTalk.SpecFlow.Infrastructure;

namespace Deveroom.VisualStudio.SpecFlowConnector.Discovery.V3000
namespace Deveroom.VisualStudio.SpecFlowConnector.Discovery.V30
{
public class SpecFlowV3000Discoverer : SpecFlowV3000P220Discoverer
public class SpecFlowV30Discoverer : SpecFlowV30P220Discoverer
{
protected override IObjectContainer CreateGlobalContainer(IConfigurationLoader configurationLoader, Assembly testAssembly)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
using TechTalk.SpecFlow.Configuration;
using TechTalk.SpecFlow.Infrastructure;

namespace Deveroom.VisualStudio.SpecFlowConnector.Discovery.V3000
namespace Deveroom.VisualStudio.SpecFlowConnector.Discovery.V30
{
public class SpecFlowV3000P220Discoverer : BaseDiscoverer
public class SpecFlowV30P220Discoverer : BaseDiscoverer
{
protected override IBindingRegistry GetBindingRegistry(Assembly testAssembly, string configFilePath)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Diagnostics;
using System.IO;
using System.Reflection;
using Deveroom.VisualStudio.SpecFlowConnector.Discovery.V3000;
using Deveroom.VisualStudio.SpecFlowConnector.Discovery.V30;
using TechTalk.SpecFlow;

namespace Deveroom.VisualStudio.SpecFlowConnector.Discovery
Expand All @@ -29,16 +29,17 @@ private ISpecFlowDiscoverer CreateDiscoverer()
{
var specFlowVersion = GetSpecFlowVersion();

var discovererType = typeof(SpecFlowV3000Discoverer);
var discovererType = typeof(SpecFlowV30P220Discoverer); // assume recent version
if (specFlowVersion != null)
switch (specFlowVersion.FileMajorPart * 1000 + specFlowVersion.FileMinorPart * 10)
{
case 3000:
discovererType = specFlowVersion.FileBuildPart >= 220 ?
typeof(SpecFlowV3000P220Discoverer) :
typeof(SpecFlowV3000Discoverer);
break;
}
{
var versionNumber =
((specFlowVersion.FileMajorPart * 100) + specFlowVersion.FileMinorPart) * 1000 + specFlowVersion.FileBuildPart;

if (versionNumber >= 3_00_220)
discovererType = typeof(SpecFlowV30P220Discoverer);
else if (versionNumber >= 3_00_000)
discovererType = typeof(SpecFlowV30Discoverer);
}

return (ISpecFlowDiscoverer)Activator.CreateInstance(discovererType);
}
Expand Down
Loading