Fixing an issue where packages with a filter but no match were not being migrated as is, instead they were being dropped.

This commit is contained in:
Livar Cunha 2017-01-12 18:23:35 -08:00
parent a9c5f4e90a
commit 18a3dd60b5
2 changed files with 23 additions and 13 deletions

View file

@ -291,21 +291,19 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
{
var possibleVersions = possibleMappings.Select(p => VersionRange.Parse(p.Key.Version));
var matchVersion = possibleVersions.FirstOrDefault(p => p.Satisfies(minRange));
if (matchVersion == null)
if (matchVersion != null)
{
return null;
var dependencyInfo = possibleMappings.First(c =>
c.Key.Version.Equals(matchVersion.OriginalString, StringComparison.OrdinalIgnoreCase)).Value;
if (dependencyInfo == null)
{
return null;
}
name = dependencyInfo.Name;
version = dependencyInfo.Version;
}
var dependencyInfo = possibleMappings.First(c =>
c.Key.Version.Equals(matchVersion.OriginalString, StringComparison.OrdinalIgnoreCase)).Value;
if (dependencyInfo == null)
{
return null;
}
name = dependencyInfo.Name;
version = dependencyInfo.Version;
}
return new PackageDependencyInfo

View file

@ -24,6 +24,18 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
ValidatePackageMigration(sourcePackageName, sourceVersion, targetPackageName, targetVersion);
}
[Theory]
[InlineData("NETStandard.Library", "1.6.2-*", "NETStandard.Library", "1.6.2-*")]
[InlineData("System.Text.Encodings.Web", "4.4.0-*", "System.Text.Encodings.Web", "4.4.0-*")]
public void ItDoesNotDropDependenciesThatDoNotHaveAMatchingVersionInTheMapping(
string sourcePackageName,
string sourceVersion,
string targetPackageName,
string targetVersion)
{
ValidatePackageMigration(sourcePackageName, sourceVersion, targetPackageName, targetVersion);
}
[Theory]
[InlineData("Microsoft.AspNetCore.Antiforgery", "1.0.0", "Microsoft.AspNetCore.Antiforgery", ConstantPackageVersions.AspNetLTSPackagesVersion)]
[InlineData("Microsoft.AspNetCore.Mvc", "1.0.0", "Microsoft.AspNetCore.Mvc", ConstantPackageVersions.AspNetLTSPackagesVersion)]