Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
765 changes: 437 additions & 328 deletions src/Authentication/Authentication/Cmdlets/InvokeGraphRequest.cs

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions src/Authentication/Authentication/Helpers/AttachDebugger.cs
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
// ------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
// ------------------------------------------------------------------------------

using System;
using System.Diagnostics;
using System.Management.Automation;

using Microsoft.Graph.PowerShell.Authentication.Cmdlets;
using System.Threading;
using Debugger = System.Diagnostics.Debugger;

namespace Microsoft.Graph.PowerShell.Authentication.Helpers
{
internal static class AttachDebugger
{
internal static void Break(PSCmdlet invokedCmdLet)
internal static void Break(this PSCmdlet invokedCmdLet)
{
while (!System.Diagnostics.Debugger.IsAttached)
while (!Debugger.IsAttached)
{
Console.Error.WriteLine($"Waiting for debugger to attach to process {System.Diagnostics.Process.GetCurrentProcess().Id}");
//invokedCmdLet.WriteDebug($"Waiting for debugger to attach to process {System.Diagnostics.Process.GetCurrentProcess().Id}");
Console.Error.WriteLine($"Waiting for debugger to attach to process {Process.GetCurrentProcess().Id}");
for (var i = 0; i < 50; i++)
{
if (System.Diagnostics.Debugger.IsAttached)
if (Debugger.IsAttached)
{
break;
}
System.Threading.Thread.Sleep(100);
//invokedCmdLet.WriteDebug(".");

Thread.Sleep(100);
Console.Error.Write(".");
}
//invokedCmdLet.WriteDebug(Environment.NewLine);

Console.Error.WriteLine();
}
System.Diagnostics.Debugger.Break();

Debugger.Break();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// ------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
// ------------------------------------------------------------------------------

using System;
using System.IO;

Expand Down Expand Up @@ -41,16 +45,16 @@ public override long Position

public override int Read(byte[] buffer, int offset, int count)
{
long previousPosition = Position;
bool consumedStream = false;
int totalCount = count;
var previousPosition = Position;
var consumedStream = false;
var totalCount = count;
while ((!consumedStream) &&
((Position + totalCount) > _streamBuffer.Length))
{
// If we don't have enough data to fill this from memory, cache more.
// We try to read 4096 bytes from base stream every time, so at most we
// may cache 4095 bytes more than what is required by the Read operation.
int bytesRead = _baseStream.Read(_copyBuffer, 0, _copyBuffer.Length);
var bytesRead = _baseStream.Read(_copyBuffer, 0, _copyBuffer.Length);

if (_streamBuffer.Position < _streamBuffer.Length)
{
Expand All @@ -73,7 +77,7 @@ public override int Read(byte[] buffer, int offset, int count)
_streamBuffer.Seek(previousPosition, SeekOrigin.Begin);

// Read from the backing store into the requested buffer.
int read = _streamBuffer.Read(buffer, offset, count);
var read = _streamBuffer.Read(buffer, offset, count);

if (read < count)
{
Expand Down
Loading