dotnet-installer/src/Microsoft.DotNet.ProjectModel/PackageDescription.cs

47 lines
1.8 KiB
C#
Raw Normal View History

// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System.Collections.Generic;
using System.Linq;
using Microsoft.DotNet.ProjectModel.Graph;
using Microsoft.DotNet.ProjectModel.Resolution;
namespace Microsoft.DotNet.ProjectModel
{
2016-03-23 15:26:36 -07:00
public class PackageDescription : TargetLibraryWithAssets
{
public PackageDescription(
string path,
LockFilePackageLibrary package,
LockFileTargetLibrary lockFileLibrary,
IEnumerable<LibraryRange> dependencies,
bool compatible,
bool resolved)
: base(
new LibraryIdentity(package.Name, package.Version, LibraryType.Package),
"sha512-" + package.Sha512,
path,
2016-03-23 15:26:36 -07:00
lockFileLibrary,
dependencies,
resolved: resolved,
2016-03-23 15:26:36 -07:00
compatible: compatible,
framework: null)
{
2016-03-23 15:26:36 -07:00
PackageLibrary = package;
}
2016-03-23 15:26:36 -07:00
public LockFilePackageLibrary PackageLibrary { get; }
2016-03-23 15:26:36 -07:00
public override IEnumerable<LockFileItem> RuntimeAssemblies => FilterPlaceholders(base.RuntimeAssemblies);
2016-03-23 15:26:36 -07:00
public override IEnumerable<LockFileItem> CompileTimeAssemblies => FilterPlaceholders(base.CompileTimeAssemblies);
2016-05-03 02:00:12 -07:00
public bool HasCompileTimePlaceholder => base.CompileTimeAssemblies.Any() && base.CompileTimeAssemblies.All(a => PackageDependencyProvider.IsPlaceholderFile(a));
2016-03-23 15:26:36 -07:00
private static IEnumerable<LockFileItem> FilterPlaceholders(IEnumerable<LockFileItem> items)
{
return items.Where(a => !PackageDependencyProvider.IsPlaceholderFile(a));
}
}
}