提交 432eb620 编写于 作者: C Charles Stoner

Use async read for process output

上级 831d295e
......@@ -82,7 +82,6 @@ internal override ImmutableArray<string> ResolveNuGetPackage(string reference)
internal static bool ParsePackageReference(string reference, out string name, out string version)
{
var parts = reference.Split('/');
int n = reference.Length;
if ((parts.Length == 2) &&
(parts[0].Length > 0) &&
(parts[1].Length > 0))
......@@ -187,17 +186,9 @@ private void NuGetRestore(string projectJsonPath)
private static void NuGetRestore(ProcessStartInfo startInfo)
{
var process = Process.Start(startInfo);
string line;
var reader = process.StandardOutput;
while ((line = reader.ReadLine()) != null)
{
// Should echo output to InteractiveWindow.
}
reader = process.StandardError;
while ((line = reader.ReadLine()) != null)
{
// Should echo errors to InteractiveWindow.
}
// Should echo output and errors to InteractiveWindow.
process.StandardOutput.ReadToEndAsync();
process.StandardError.ReadToEndAsync();
process.WaitForExit();
}
}
......
......@@ -4,7 +4,7 @@
using Microsoft.CodeAnalysis.Test.Utilities;
using Roslyn.Test.Utilities;
using Roslyn.Utilities;
using System.Collections.Immutable;
using System;
using System.IO;
using System.Text;
using Xunit;
......@@ -89,6 +89,27 @@ public void ResolveReference()
}
}
[ConditionalFact(typeof(WindowsOnly))]
public void HandledException()
{
using (var directory = new DisposableDirectory(Temp))
{
var resolver = new NuGetPackageResolverImpl(directory.Path, startInfo => { throw new IOException(); });
var actualPaths = resolver.ResolveNuGetPackage("A.B.C/1.2");
Assert.True(actualPaths.IsDefault);
}
}
[ConditionalFact(typeof(WindowsOnly))]
public void UnhandledException()
{
using (var directory = new DisposableDirectory(Temp))
{
var resolver = new NuGetPackageResolverImpl(directory.Path, startInfo => { throw new InvalidOperationException(); });
Assert.Throws<InvalidOperationException>(() => resolver.ResolveNuGetPackage("A.B.C/1.2"));
}
}
[ConditionalFact(typeof(WindowsOnly))]
public void ParsePackageNameAndVersion()
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册