Я не нашел, как его включить, но нашел другой способ получить все запросы JSON от визуальной студии. На клиентском языке я перехватил все запросы Visual Studio, создав InterceptionStream
как здесь , и обернул PipeStream.
Использование:
var readerPipe = new NamedPipeClientStream(readerPipeName);
var writerPipe = new NamedPipeClientStream(writerPipeName);
var fileStream = File.OpenWrite(logFilePath);
var interceptionStream = new InterceptionStream(writerPipe, fileStream);
if (process.Start())
{
await Task.WhenAll(readerPipe.ConnectAsync(token), writerPipe.ConnectAsync(token));
return new Connection(readerPipe, interceptionStream);
}
InterceptionStream
:
public class InterceptionStream : Stream
{
public InterceptionStream(Stream innerStream, Stream copyStream)
{
InnerStream = innerStream ?? throw new ArgumentNullException(nameof(innerStream));
CopyStream = copyStream ?? throw new ArgumentNullException(nameof(copyStream));
if (!CopyStream.CanWrite)
{
throw new ArgumentException("copyStream is not writable");
}
}
public Stream InnerStream { get; }
public Stream CopyStream { get; }
public override bool CanRead => InnerStream.CanRead;
public override bool CanSeek => InnerStream.CanSeek;
public override bool CanWrite => InnerStream.CanWrite;
public override long Length => InnerStream.Length;
public override long Position
{
get => InnerStream.Position;
set => InnerStream.Position = value;
}
public override void Flush()
{
InnerStream.Flush();
}
public override long Seek(long offset, SeekOrigin origin)
{
return InnerStream.Seek(offset, origin);
}
public override void SetLength(long value)
{
InnerStream.SetLength(value);
}
public override int Read(byte[] buffer, int offset, int count)
{
var bytesRead = InnerStream.Read(buffer, offset, count);
if (bytesRead != 0)
{
CopyStream.Write(buffer, offset, bytesRead);
}
return bytesRead;
}
public override void Write(byte[] buffer, int offset, int count)
{
InnerStream.Write(buffer, offset, count);
CopyStream.Write(buffer, offset, count);
}
protected override void Dispose(bool disposing)
{
CopyStream.Dispose();
InnerStream.Dispose();
}
}