From 8a3ddc9c8a8c5b2308496176f7a23ebfec61d1b7 Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Wed, 30 Mar 2016 15:54:40 -0700 Subject: [PATCH] Remove MSBuildProjectPath property --- .../Models/DependencyDescription.cs | 8 ++---- .../Models/ProjectReferenceDescription.cs | 7 ++--- .../DthTests.cs | 28 +++++-------------- 3 files changed, 12 insertions(+), 31 deletions(-) diff --git a/src/dotnet/commands/dotnet-projectmodel-server/Models/DependencyDescription.cs b/src/dotnet/commands/dotnet-projectmodel-server/Models/DependencyDescription.cs index 6d60288a8..07aa58a64 100644 --- a/src/dotnet/commands/dotnet-projectmodel-server/Models/DependencyDescription.cs +++ b/src/dotnet/commands/dotnet-projectmodel-server/Models/DependencyDescription.cs @@ -24,8 +24,6 @@ namespace Microsoft.DotNet.ProjectModel.Server.Models public bool Resolved { get; private set; } - public string MSBuildProjectPath { get; private set; } - public IEnumerable Dependencies { get; private set; } public IEnumerable Errors { get; private set; } @@ -72,13 +70,13 @@ namespace Microsoft.DotNet.ProjectModel.Server.Models Warnings = diagnostics.Where(d => d.Severity == DiagnosticMessageSeverity.Warning) .Select(d => new DiagnosticMessageView(d)) }; - + var msbuildLibrary = library as MSBuildProjectDescription; if (msbuildLibrary != null) { - result.MSBuildProjectPath = msbuildLibrary.ProjectLibrary.MSBuildProject; + result.Path = msbuildLibrary.MSBuildProjectPath; } - + return result; } diff --git a/src/dotnet/commands/dotnet-projectmodel-server/Models/ProjectReferenceDescription.cs b/src/dotnet/commands/dotnet-projectmodel-server/Models/ProjectReferenceDescription.cs index 24bc4e263..224837488 100644 --- a/src/dotnet/commands/dotnet-projectmodel-server/Models/ProjectReferenceDescription.cs +++ b/src/dotnet/commands/dotnet-projectmodel-server/Models/ProjectReferenceDescription.cs @@ -10,15 +10,13 @@ namespace Microsoft.DotNet.ProjectModel.Server.Models public FrameworkData Framework { get; set; } public string Name { get; set; } public string Path { get; set; } - public string MSBuildProjectPath { get; set; } public override bool Equals(object obj) { var other = obj as ProjectReferenceDescription; return other != null && string.Equals(Name, other.Name) && - string.Equals(Path, other.Path) && - string.Equals(MSBuildProjectPath, other.MSBuildProjectPath); + string.Equals(Path, other.Path); } public override int GetHashCode() @@ -47,8 +45,7 @@ namespace Microsoft.DotNet.ProjectModel.Server.Models { Framework = library.Framework.ToPayload(), Name = library.Identity.Name, - Path = library.Path, - MSBuildProjectPath = ((MSBuildProjectDescription)library).ProjectLibrary.MSBuildProject + Path = ((MSBuildProjectDescription)library).MSBuildProjectPath, }; } else diff --git a/test/dotnet-projectmodel-server.Tests/DthTests.cs b/test/dotnet-projectmodel-server.Tests/DthTests.cs index c8424a23c..92df20c70 100644 --- a/test/dotnet-projectmodel-server.Tests/DthTests.cs +++ b/test/dotnet-projectmodel-server.Tests/DthTests.cs @@ -149,8 +149,7 @@ namespace Microsoft.DotNet.ProjectModel.Server.Tests .AssertJArrayCount(1) .RetrieveArraryElementAs(0) .AssertProperty("Name", expectedUnresolvedDependency) - .AssertProperty("Path", expectedUnresolvedProjectPath) - .AssertProperty("MSBuildProjectPath", prop => !prop.HasValues); + .AssertProperty("Path", expectedUnresolvedProjectPath); } else if (referenceType == "Package") { @@ -432,11 +431,12 @@ namespace Microsoft.DotNet.ProjectModel.Server.Tests var classLibraries = new HashSet(new string[] { "ClassLibrary1", "ClassLibrary2", "ClassLibrary3" }); var dependencies = messages.RetrieveSingleMessage(MessageTypes.Dependencies); + var testProjectRoot = Path.Combine(RepoRoot, "TestAssets", "ProjectModelServer", "MSBuildReferencesProjects", "ValidCase01"); foreach (var classLibrary in classLibraries) - { + { dependencies.RetrieveDependency(classLibrary) .AssertProperty("Type", LibraryType.MSBuildProject.ToString()) - .AssertProperty("MSBuildProjectPath", AssertPathsEqual(Path.Combine("..", "..", classLibrary, $"{classLibrary}.csproj"))) + .AssertProperty("Path", NormalizePathString(Path.Combine(testProjectRoot, classLibrary, $"{classLibrary}.csproj"))) .AssertProperty("Resolved", true) .AssertProperty("Name", classLibrary) .AssertProperty("Errors", array => array.Count == 0) @@ -454,8 +454,7 @@ namespace Microsoft.DotNet.ProjectModel.Server.Tests var name = projectRef["Name"].Value(); Assert.True(classLibraries.Contains(name)); - projectRef.AssertProperty("Path", path => path.Contains(Path.Combine("ValidCase01", name))) - .AssertProperty("MSBuildProjectPath", AssertPathsEqual(Path.Combine("..", "..", name, $"{name}.csproj"))); + projectRef.AssertProperty("Path", NormalizePathString(Path.Combine(testProjectRoot, name, $"{name}.csproj"))); } var fileReferences = references.RetrievePropertyAs("FileReferences") @@ -468,22 +467,9 @@ namespace Microsoft.DotNet.ProjectModel.Server.Tests } } - private static Func AssertPathsEqual(string expectedString) + private static string NormalizePathString(string original) { - return - (string t) => - { - if (t.Contains('/')) - { - t = t.Replace('/', Path.DirectorySeparatorChar); - } - else if (t.Contains('\\')) - { - t = t.Replace('\\', Path.DirectorySeparatorChar); - } - - return string.Equals(t, expectedString); - }; + return original.Replace('/', Path.DirectorySeparatorChar).Replace('\\', Path.DirectorySeparatorChar); } } }