Skip to content

Commit

Permalink
Do not warn for missing 'SpecFlow.Tools.MsBuild.Generation' package w…
Browse files Browse the repository at this point in the history
…hen SpecFlow v3.3 or later is used
  • Loading branch information
gasparnagy committed Feb 22, 2021
1 parent 244cc47 commit 6530ad5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Improvements:

* Support for .NET 5 projects (Issue #67, thx for Timothée Lecomte)
* Support for SpecFlow v3.7 projects (Issue #69)
* Do not warn for missing 'SpecFlow.Tools.MsBuild.Generation' package when SpecFlow v3.3 or later is used

# v1.6.1 - 2020-05-13

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ private NuGetPackageReference GetSpecFlowPackage(IProjectScope projectScope, IEn
var specFlowPackage = detector.GetSpecFlowPackage(packageReferencesArray);
if (specFlowPackage != null)
{
if (detector.IsMsBuildGenerationEnabled(packageReferencesArray))
var specFlowVersion = specFlowPackage.Version.Version;
if (detector.IsMsBuildGenerationEnabled(packageReferencesArray) ||
IsImplicitMsBuildGeneration(detector, specFlowVersion, packageReferencesArray))
specFlowProjectTraits |= SpecFlowProjectTraits.MsBuildGeneration;
if (detector.IsXUnitAdapterEnabled(packageReferencesArray))
specFlowProjectTraits |= SpecFlowProjectTraits.XUnitAdapter;
Expand All @@ -133,6 +135,12 @@ private NuGetPackageReference GetSpecFlowPackage(IProjectScope projectScope, IEn
return specFlowPackage;
}

private bool IsImplicitMsBuildGeneration(SpecFlowPackageDetector detector, Version specFlowVersion, NuGetPackageReference[] packageReferencesArray)
{
return specFlowVersion >= new Version(3, 3) &&
detector.IsSpecFlowTestFrameworkPackagesUsed(packageReferencesArray);
}

private string GetSpecFlowConfigFilePath(IProjectScope projectScope)
{
var projectFolder = projectScope.ProjectFolder;
Expand Down
19 changes: 16 additions & 3 deletions Deveroom.VisualStudio/ProjectSystem/SpecFlowPackageDetector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,24 @@ internal class SpecFlowPackageDetector
public const string SpecFlowToolsMsBuildGenerationPackageName = "SpecFlow.Tools.MsBuild.Generation";
public const string SpecFlowXUnitAdapterPackageName = "SpecFlow.xUnitAdapter";
public const string CucumberExpressionPluginPackageNamePrefix = "CucumberExpressions.SpecFlow";
public const string SpecFlowPlusRunnerPluginPackageNamePrefix = "SpecRun.SpecFlow";

private static readonly string[] KnownSpecFlowPackages =
private static readonly string[] SpecFlowTestFrameworkPackages =
{
"SpecFlow.MsTest",
"SpecFlow.xUnit",
"SpecFlow.NUnit",
"SpecFlow.MsTest",
SpecFlowToolsMsBuildGenerationPackageName
"SpecFlow.MsTest"
};

private static readonly string[] KnownSpecFlowPackages =
SpecFlowTestFrameworkPackages
.Concat(new[]
{
SpecFlowToolsMsBuildGenerationPackageName
})
.ToArray();

private const string SpecRunPackageRe = @"^SpecRun.SpecFlow.(?<sfver>[\d-]+)$";
private const string SpecSyncPackageRe = @"^SpecSync.AzureDevOps.SpecFlow.(?<sfver>[\d-]+)$";

Expand Down Expand Up @@ -52,6 +60,11 @@ public bool IsCucumberExpressionPluginEnabled(IEnumerable<NuGetPackageReference>
return packageReferences.Any(pr => pr.PackageName != null && pr.PackageName.StartsWith(CucumberExpressionPluginPackageNamePrefix));
}

public bool IsSpecFlowTestFrameworkPackagesUsed(NuGetPackageReference[] packageReferences)
{
return packageReferences.Any(pr => SpecFlowTestFrameworkPackages.Contains(pr.PackageName) || pr.PackageName.StartsWith(SpecFlowPlusRunnerPluginPackageNamePrefix));
}

public NuGetPackageReference GetSpecFlowPackage(IEnumerable<NuGetPackageReference> packageReferences)
{
NuGetPackageReference knownSpecFlowPackage = null;
Expand Down

0 comments on commit 6530ad5

Please sign in to comment.