Addressing code review comments.

This commit is contained in:
Livar Cunha 2017-01-04 12:25:48 -08:00
parent 47eafb9ef4
commit a4dcff9ea8
5 changed files with 19 additions and 17 deletions

View file

@ -28,6 +28,8 @@ namespace Microsoft.DotNet.ProjectJsonMigration
} }
} }
public bool IsMultiTFM => ProjectContexts.Count() > 1;
public MigrationRuleInputs( public MigrationRuleInputs(
IEnumerable<ProjectContext> projectContexts, IEnumerable<ProjectContext> projectContexts,
ProjectRootElement outputMSBuildProject, ProjectRootElement outputMSBuildProject,

View file

@ -63,7 +63,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
MigrateImports( MigrateImports(
migrationRuleInputs.CommonPropertyGroup, migrationRuleInputs.CommonPropertyGroup,
targetFramework, targetFramework,
migrationRuleInputs.ProjectContexts.Count() > 1); migrationRuleInputs.IsMultiTFM);
MigrateDependencies( MigrateDependencies(
project, project,

View file

@ -32,7 +32,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
csproj, csproj,
scriptSet.Value, scriptSet.Value,
scriptSet.Key, scriptSet.Key,
migrationRuleInputs.ProjectContexts.Count() > 1); migrationRuleInputs.IsMultiTFM);
} }
} }

View file

@ -34,20 +34,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
CleanExistingProperties(csproj); CleanExistingProperties(csproj);
CleanExistingPackageReferences(csproj); CleanExistingPackageReferences(csproj);
if(migrationRuleInputs.ProjectContexts.Count() == 1) if(migrationRuleInputs.IsMultiTFM)
{
_transformApplicator.Execute(
FrameworkTransform.Transform(
migrationRuleInputs.ProjectContexts.Single().TargetFramework),
propertyGroup,
mergeExisting: true);
_transformApplicator.Execute(
FrameworkRuntimeIdentifiersTransform.Transform(
migrationRuleInputs.ProjectContexts.Single()),
propertyGroup,
mergeExisting: true);
}
else
{ {
_transformApplicator.Execute( _transformApplicator.Execute(
FrameworksTransform.Transform( FrameworksTransform.Transform(
@ -65,6 +52,19 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Rules
propertyGroup, propertyGroup,
mergeExisting: true); mergeExisting: true);
} }
else
{
_transformApplicator.Execute(
FrameworkTransform.Transform(
migrationRuleInputs.ProjectContexts.Single().TargetFramework),
propertyGroup,
mergeExisting: true);
_transformApplicator.Execute(
FrameworkRuntimeIdentifiersTransform.Transform(
migrationRuleInputs.ProjectContexts.Single()),
propertyGroup,
mergeExisting: true);
}
} }
private void CleanExistingProperties(ProjectRootElement csproj) private void CleanExistingProperties(ProjectRootElement csproj)

View file

@ -201,7 +201,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
} }
[Fact] [Fact]
public void ItDoesNotConditionToPackageTargetFallBackWhenMigratingASingleTFM() public void ItDoesNotAddConditionToPackageTargetFallBackWhenMigratingASingleTFM()
{ {
var importPropertyName = "PackageTargetFallback"; var importPropertyName = "PackageTargetFallback";