提交 cfcd8b71 编写于 作者: T Tomas Matousek

Adapt to path normalization changes in 4.6.2

上级 b9d81e43
......@@ -83,9 +83,7 @@ public void CreateFromFile()
Assert.Throws<ArgumentException>(() => ModuleMetadata.CreateFromFile(@"c:\*"));
char systemDrive = Environment.GetFolderPath(Environment.SpecialFolder.Windows)[0];
Assert.Throws<ArgumentException>(() => ModuleMetadata.CreateFromFile(@"http://goo.bar"));
Assert.Throws<ArgumentException>(() => ModuleMetadata.CreateFromFile(@"\\.\COM1"));
Assert.Throws<IOException>(() => ModuleMetadata.CreateFromFile(@"http://goo.bar"));
Assert.Throws<FileNotFoundException>(() => ModuleMetadata.CreateFromFile(systemDrive + @":\file_that_does_not_exists.dll"));
Assert.Throws<FileNotFoundException>(() => ModuleMetadata.CreateFromFile(systemDrive + @":\directory_that_does_not_exists\file_that_does_not_exists.dll"));
Assert.Throws<PathTooLongException>(() => ModuleMetadata.CreateFromFile(systemDrive + @":\" + new string('x', 1000)));
......
......@@ -405,13 +405,12 @@ internal static Stream OpenFileStream(string path)
{
throw;
}
catch (IOException e)
catch (DirectoryNotFoundException e)
{
throw new FileNotFoundException(e.Message, path, e);
}
catch (IOException)
{
if (e.GetType().Name == "DirectoryNotFoundException")
{
throw new FileNotFoundException(e.Message, path, e);
}
throw;
}
catch (Exception e)
......
......@@ -288,27 +288,7 @@ internal bool TrySubmit()
{
this.FullFilePath = Path.GetFullPath(this.FullFilePath);
}
catch (ArgumentNullException e)
{
SendFailureNotification(e.Message);
return false;
}
catch (ArgumentException e)
{
SendFailureNotification(e.Message);
return false;
}
catch (SecurityException e)
{
SendFailureNotification(e.Message);
return false;
}
catch (NotSupportedException e)
{
SendFailureNotification(e.Message);
return false;
}
catch (PathTooLongException e)
catch (Exception e)
{
SendFailureNotification(e.Message);
return false;
......@@ -319,7 +299,11 @@ internal bool TrySubmit()
if (lastIndexOfSeparatorInFullPath != -1)
{
var fileNameInFullPathInContainers = this.FullFilePath.Split(new[] { '\\' }, StringSplitOptions.RemoveEmptyEntries);
this.FullFilePath = string.Join("\\", fileNameInFullPathInContainers.Select(str => str.TrimStart()));
// Trim spaces of each component of the file name.
// Note that path normalization changed between 4.6.1 and 4.6.2 and GetFullPath no longer trims trailing spaces.
// See https://blogs.msdn.microsoft.com/jeremykuhne/2016/06/21/more-on-new-net-path-handling/
this.FullFilePath = string.Join("\\", fileNameInFullPathInContainers.Select(str => str.Trim()));
}
string projectRootPath = null;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册