Skip to content
This repository has been archived by the owner on Dec 18, 2017. It is now read-only.

Fix regression in ProjectResolver #1505

Merged
merged 1 commit into from
Mar 26, 2015

Conversation

ChengTian
Copy link
Contributor

@ghost ghost added the cla-not-required label Mar 26, 2015
@@ -49,7 +49,7 @@ public bool TryResolveProject(string name, out Project project)

private void Initialize(string projectPath, string rootPath)
{
_searchPaths.Add(Path.GetDirectoryName(projectPath));
_searchPaths.Add(new DirectoryInfo(projectPath).Parent.FullName);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Path.GetFullPath?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am using FullName

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant instead of this entire line

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Path.GetDirectoryName(Path.GetFullPath(projectPath)) should do it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Path.GetFullPath() doesn't help here.

To make it clear, projectPath is a directory, that may have a trailing slash. We want to get the parent dir of projectPath.

The current approach is the most readable one. If you think newing an object here may increase program startup time, I can do a naïve trailing slash removal here (which actually is creating a new string object, so there is no too much difference).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Path.GetDirectoryName("this/is/a/path") returns "this/is/a"
Path.GetDirectoryName("this/is/a/path/") returns "this/is/a/path"
Path.GetFullPath() doesn't remove trailing slash for you

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good catch. I stand (or rather sit) corrected :)

@ChengTian
Copy link
Contributor Author

I should add a test case covering this case. Adding test now.

@ChengTian
Copy link
Contributor Author

Added test

@davidfowl
Copy link
Member

:shipit:

@ChengTian ChengTian force-pushed the wei/fix-regression-in-ProjectResolver branch from 745856d to 7bd3b77 Compare March 26, 2015 21:28
@ChengTian ChengTian merged commit 7bd3b77 into release Mar 26, 2015
@ChengTian ChengTian deleted the wei/fix-regression-in-ProjectResolver branch March 26, 2015 22:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants