提交 400dd2c6 编写于 作者: H Heejae Chang

renamed Combine to TryCombine to show the intent more clear.

TryCombine should never throw exception.
上级 65c3f26a
......@@ -182,7 +182,18 @@ protected bool TryNavigateTo(Workspace workspace, DocumentId documentId, int lin
protected string GetFileName(string original, string mapped)
{
return mapped == null ? original : original == null ? mapped : FilePathUtilities.Combine(original, mapped);
return mapped == null ? original : original == null ? mapped : Combine(original, mapped);
}
private string Combine(string path1, string path2)
{
string result;
if (FilePathUtilities.TryCombine(path1, path2, out result))
{
return result;
}
return string.Empty;
}
protected string GetProjectName(Workspace workspace, ProjectId projectId)
......
......@@ -104,16 +104,18 @@ public static bool PathsEqual(string path1, string path2)
return string.Compare(path1, path2, StringComparison.OrdinalIgnoreCase) == 0;
}
public static string Combine(string path1, string path2)
public static bool TryCombine(string path1, string path2, out string result)
{
try
{
// don't throw exception when either path1 or path2 contains illegal path char
return Path.Combine(path1, path2);
result = Path.Combine(path1, path2);
return true;
}
catch
{
return string.Empty;
result = null;
return false;
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册