Merge pull request #2834 from dotnet/davidfowl/placeholders

Fix placeholder resolution logic
This commit is contained in:
Peter Marcu 2016-05-03 08:15:19 -07:00
commit 05d0dcebc1
2 changed files with 48 additions and 1 deletions

View file

@ -36,7 +36,7 @@ namespace Microsoft.DotNet.ProjectModel
public override IEnumerable<LockFileItem> CompileTimeAssemblies => FilterPlaceholders(base.CompileTimeAssemblies);
public bool HasCompileTimePlaceholder => base.CompileTimeAssemblies.Any(a => PackageDependencyProvider.IsPlaceholderFile(a));
public bool HasCompileTimePlaceholder => base.CompileTimeAssemblies.Any() && base.CompileTimeAssemblies.All(a => PackageDependencyProvider.IsPlaceholderFile(a));
private static IEnumerable<LockFileItem> FilterPlaceholders(IEnumerable<LockFileItem> items)
{

View file

@ -42,6 +42,53 @@ namespace Microsoft.DotNet.ProjectModel.Tests
Assert.Empty(p2.RuntimeAssemblies);
}
[Fact]
public void HasCompileTimePlaceholderChecksAllCompileTimeAssets()
{
var provider = new PackageDependencyProvider("/foo/packages", new FrameworkReferenceResolver("/foo/references"));
var package = new LockFilePackageLibrary();
package.Name = "Something";
package.Version = NuGetVersion.Parse("1.0.0");
package.Files.Add("lib/net46/_._");
package.Files.Add("lib/net46/Something.dll");
var target = new LockFileTargetLibrary();
target.Name = "Something";
target.Version = package.Version;
target.RuntimeAssemblies.Add("lib/net46/_._");
target.RuntimeAssemblies.Add("lib/net46/Something.dll");
target.CompileTimeAssemblies.Add("lib/net46/_._");
target.CompileTimeAssemblies.Add("lib/net46/Something.dll");
var p1 = provider.GetDescription(NuGetFramework.Parse("net46"), package, target);
Assert.False(p1.HasCompileTimePlaceholder);
Assert.Equal(1, p1.CompileTimeAssemblies.Count());
Assert.Equal(1, p1.RuntimeAssemblies.Count());
Assert.Equal("lib/net46/Something.dll", p1.CompileTimeAssemblies.First().Path);
Assert.Equal("lib/net46/Something.dll", p1.RuntimeAssemblies.First().Path);
}
[Fact]
public void HasCompileTimePlaceholderReturnsFalseIfEmpty()
{
var provider = new PackageDependencyProvider("/foo/packages", new FrameworkReferenceResolver("/foo/references"));
var package = new LockFilePackageLibrary();
package.Name = "Something";
package.Version = NuGetVersion.Parse("1.0.0");
var target = new LockFileTargetLibrary();
target.Name = "Something";
target.Version = package.Version;
var p1 = provider.GetDescription(NuGetFramework.Parse("net46"), package, target);
Assert.False(p1.HasCompileTimePlaceholder);
Assert.Equal(0, p1.CompileTimeAssemblies.Count());
Assert.Equal(0, p1.RuntimeAssemblies.Count());
}
[Theory]
[InlineData("TestMscorlibReference", true)]
[InlineData("TestMscorlibReference", false)]