Skip to content

Commit

Permalink
small fixes and Changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
gasparnagy committed Jul 3, 2019
1 parent 447bf54 commit 09aeea2
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 8 deletions.
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
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:

Expand Down
5 changes: 5 additions & 0 deletions Deveroom.VisualStudio/Configuration/SpecFlowConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
using System.Linq;
using System.Text.RegularExpressions;
using Deveroom.VisualStudio.Common;
using Deveroom.VisualStudio.ProjectSystem.Settings;
using Equ;

Expand All @@ -22,6 +24,9 @@ private void FixEmptyContainers()
public void CheckConfiguration()
{
FixEmptyContainers();

if (Version != null && !Regex.IsMatch(Version, @"^(?:\.?[0-9]+){2,}(?:\-[\-a-z0-9]*)?$"))
throw new DeveroomConfigurationException("'specFlow/version' was not in a correct format");
}
}
}
3 changes: 2 additions & 1 deletion Deveroom.VisualStudio/Configuration/deveroom-config-1.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
},
"version": {
"description": "The SpecFlow version used by the project, e.g. '2.3.1'. (Default: [detect version automatically])",
"type": "string"
"type": "string",
"pattern": "^(?:\\.?[0-9]+){2,}(?:\\-[\\-a-z0-9]*)?$"
},
"traits": {
"description": "The list of the SpecFlow-related project traits. The possible traits are: 'MsBuildGeneration', 'XUnitAdapter', 'DesignTimeFeatureFileGeneration', e.g. '[\"XUnitAdapter\"]'. (Default: [detect from the installed NuGet packages])",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ private ConfigCache LoadConfiguration(ConfigSource[] configSources)
LoadFromDeveroomConfig(configSource.FilePath, configuration);
}

configuration.CheckConfiguration();

loadedSources.Add(configSource);
}
catch (Exception ex)
Expand All @@ -159,6 +161,7 @@ private ConfigCache LoadConfiguration(ConfigSource[] configSources)
}
catch (Exception ex)
{
Logger.LogWarning($"Invalid Deveroom configuration: {ex.Message}");
Logger.LogVerboseException(MonitoringService, ex, "Configuration error, using default config");
configuration = new DeveroomConfiguration();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ public ProjectSettings CheckProjectSettings()
{
OnSettingsInitialized(projectSettings, featureFileCount);
}
else
{
Logger.LogInfo($"Project settings updated: {projectSettings.GetShortLabel()}");
}
return _projectSettings;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,15 @@ private SpecFlowSettings UpdateSpecFlowSettingsFromConfig(SpecFlowSettings specF
specFlowSettings.Version = new NuGetVersion(configuration.SpecFlow.Version);

if (configuration.SpecFlow.GeneratorFolder != null)
{
specFlowSettings.GeneratorFolder = configuration.SpecFlow.GeneratorFolder;
specFlowSettings.Traits |= SpecFlowProjectTraits.DesignTimeFeatureFileGeneration;
}

if (configuration.SpecFlow.ConfigFilePath != null)
specFlowSettings.ConfigFilePath = configuration.SpecFlow.ConfigFilePath;
else if (specFlowSettings.ConfigFilePath == null)
specFlowSettings.ConfigFilePath = GetSpecFlowConfigFilePath(_projectScope);

return specFlowSettings;
}
Expand All @@ -62,8 +67,9 @@ private SpecFlowSettings GetSpecFlowSettingsFromPackages(IEnumerable<NuGetPackag
var specFlowGeneratorFolder = specFlowPackage.InstallPath == null
? null
: Path.Combine(specFlowPackage.InstallPath, "tools");
var configFilePath = GetSpecFlowConfigFilePath(_projectScope);

return CreateSpecFlowSettings(specFlowVersion, specFlowProjectTraits, specFlowGeneratorFolder);
return CreateSpecFlowSettings(specFlowVersion, specFlowProjectTraits, specFlowGeneratorFolder, configFilePath);
}

private SpecFlowSettings GetSpecFlowSettingsFromOutputFolder()
Expand All @@ -81,7 +87,9 @@ private SpecFlowSettings GetSpecFlowSettingsFromOutputFolder()

var specFlowNuGetVersion = new NuGetVersion($"{specFlowVersion.FileMajorPart}.{specFlowVersion.FileMinorPart}.{specFlowVersion.FileBuildPart}");

return CreateSpecFlowSettings(specFlowNuGetVersion, SpecFlowProjectTraits.None, null);
var configFilePath = GetSpecFlowConfigFilePath(_projectScope);

return CreateSpecFlowSettings(specFlowNuGetVersion, SpecFlowProjectTraits.None, null, configFilePath);
}

private FileVersionInfo GetSpecFlowVersion(string outputFolder)
Expand All @@ -91,16 +99,17 @@ private FileVersionInfo GetSpecFlowVersion(string outputFolder)
return fileVersionInfo;
}

private SpecFlowSettings CreateSpecFlowSettings(NuGetVersion specFlowVersion, SpecFlowProjectTraits specFlowProjectTraits, string specFlowGeneratorFolder)
private SpecFlowSettings CreateSpecFlowSettings(
NuGetVersion specFlowVersion, SpecFlowProjectTraits specFlowProjectTraits,
string specFlowGeneratorFolder, string specFlowConfigFilePath)
{
var configFilePath = GetSpecFlowConfigFilePath(_projectScope);

if (specFlowVersion.Version < new Version(3, 0) &&
!specFlowProjectTraits.HasFlag(SpecFlowProjectTraits.MsBuildGeneration) &&
!specFlowProjectTraits.HasFlag(SpecFlowProjectTraits.XUnitAdapter))
!specFlowProjectTraits.HasFlag(SpecFlowProjectTraits.XUnitAdapter) &&
specFlowGeneratorFolder != null)
specFlowProjectTraits |= SpecFlowProjectTraits.DesignTimeFeatureFileGeneration;

return new SpecFlowSettings(specFlowVersion, specFlowProjectTraits, specFlowGeneratorFolder, configFilePath);
return new SpecFlowSettings(specFlowVersion, specFlowProjectTraits, specFlowGeneratorFolder, specFlowConfigFilePath);
}

private NuGetPackageReference GetSpecFlowPackage(IProjectScope projectScope, IEnumerable<NuGetPackageReference> packageReferences, out SpecFlowProjectTraits specFlowProjectTraits)
Expand Down

0 comments on commit 09aeea2

Please sign in to comment.