Merge pull request #3204 from dotnet/pakrym/dc-fixes

Fix dependency context merge and msbuildproject resolution
This commit is contained in:
Pavel Krymets 2016-05-23 16:29:58 -07:00
commit 40a2b495ba
5 changed files with 73 additions and 3 deletions

View file

@ -88,12 +88,12 @@ namespace Microsoft.Extensions.DependencyModel
{
public bool Equals(T x, T y)
{
return string.Equals(x.Name, y.Name, StringComparison.Ordinal);
return StringComparer.OrdinalIgnoreCase.Equals(x.Name, y.Name);
}
public int GetHashCode(T obj)
{
return obj.Name.GetHashCode();
return StringComparer.OrdinalIgnoreCase.GetHashCode(obj.Name);
}
}
}

View file

@ -40,7 +40,9 @@ namespace Microsoft.Extensions.DependencyModel.Resolution
public bool TryResolveAssemblyPaths(CompilationLibrary library, List<string> assemblies)
{
var isProject = string.Equals(library.Type, "project", StringComparison.OrdinalIgnoreCase);
var isProject = string.Equals(library.Type, "project", StringComparison.OrdinalIgnoreCase) ||
string.Equals(library.Type, "msbuildproject", StringComparison.OrdinalIgnoreCase);
var isPackage = string.Equals(library.Type, "package", StringComparison.OrdinalIgnoreCase);
if (!isProject &&
!isPackage &&

View file

@ -39,6 +39,23 @@ namespace Microsoft.Extensions.DependencyModel.Tests
Assert.True(result);
}
[Fact]
public void ResolvesMsBuildProjectType()
{
var fileSystem = FileSystemMockBuilder
.Create()
.AddFiles(BasePathRefs, TestLibraryFactory.DefaultAssembly)
.Build();
var resolver = CreateResolver(fileSystem);
var library = TestLibraryFactory.Create(
TestLibraryFactory.MsBuildProjectType,
assemblies: TestLibraryFactory.EmptyAssemblies);
var result = resolver.TryResolveAssemblyPaths(library, null);
Assert.True(result);
}
[Fact]
public void ResolvesPackageType()
{

View file

@ -69,6 +69,56 @@ namespace Microsoft.Extensions.DependencyModel.Tests
});
}
[Fact]
public void MergeMergesLibrariesWithDifferentCasing()
{
var compilationLibraries = new[]
{
CreateCompilation("PaCkAgEA"),
};
var runtimeLibraries = new[]
{
CreateRuntime("PaCkAgEA"),
};
var compilationLibrariesRedist = new[]
{
CreateCompilation("PackageA"),
};
var runtimeLibrariesRedist = new[]
{
CreateRuntime("PackageA"),
};
var context = new DependencyContext(
CreateTargetInfo(),
CompilationOptions.Default,
compilationLibraries,
runtimeLibraries,
new RuntimeFallbacks[] { });
var contextRedist = new DependencyContext(
CreateTargetInfo(),
CompilationOptions.Default,
compilationLibrariesRedist,
runtimeLibrariesRedist,
new RuntimeFallbacks[] { });
var result = context.Merge(contextRedist);
result.CompileLibraries.Should().BeEquivalentTo(new[]
{
compilationLibraries[0]
});
result.RuntimeLibraries.Should().BeEquivalentTo(new[]
{
runtimeLibraries[0]
});
}
public void MergeMergesRuntimeGraph()
{
var context = new DependencyContext(

View file

@ -26,6 +26,7 @@ namespace Microsoft.Extensions.DependencyModel.Tests
public static readonly string DefaultHash = DefaultHashAlgoritm + "-" + DefaultHashValue;
public static readonly string ProjectType = "project";
public static readonly string MsBuildProjectType = "msbuildproject";
public static readonly string ReferenceAssemblyType = "referenceassembly";
public static readonly string PackageType = "package";