From 9e8b68479161a91daae917d35900e1dff16080c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Sim=C3=B5es?= Date: Mon, 23 Oct 2017 19:20:44 +0100 Subject: [PATCH] Add ConfigAwait to async calls (#61) --- .../PortSerial/EventHandlerForSerialDevice.cs | 4 +- .../PortUsb/EventHandlerForUsbDevice.cs | 8 +- ...anoFramework.Tools.DebugLibrary.Net.csproj | 1 + .../packages.config | 1 + .../Extensions/DebuggerExtensions.cs | 2 +- .../MFDeployTool/NanoFrameworkDeviceInfo.cs | 10 +- .../NFDevice/NanoDevice.cs | 4 +- .../NFDevice/NanoDeviceBase.cs | 144 +++++++---- .../PortSerial/SerialPort.cs | 18 +- .../PortUSB/UsbPort.cs | 16 +- .../Runtime/RunTimeValue.cs | 10 +- .../Runtime/RuntimeValue_Array.cs | 2 +- .../Runtime/RuntimeValue_Class.cs | 2 +- .../Runtime/RuntimeValue_Indirect.cs | 6 +- .../Runtime/RuntimeValue_String.cs | 2 +- .../SRecordFile.cs | 4 +- .../WireProtocol/ConnectionSource.cs | 4 +- .../WireProtocol/Controller.cs | 8 +- .../WireProtocol/Engine.cs | 234 +++++++++--------- .../WireProtocol/IncomingMessage.cs | 4 +- .../WireProtocol/MessageReassembler.cs | 12 +- .../WireProtocol/OutgoingMessage.cs | 2 +- .../WireProtocol/Request.cs | 4 +- 23 files changed, 276 insertions(+), 226 deletions(-) diff --git a/source/nanoFramework.Tools.DebugLibrary.Net/PortSerial/EventHandlerForSerialDevice.cs b/source/nanoFramework.Tools.DebugLibrary.Net/PortSerial/EventHandlerForSerialDevice.cs index 46e24ca0..684a3ad6 100644 --- a/source/nanoFramework.Tools.DebugLibrary.Net/PortSerial/EventHandlerForSerialDevice.cs +++ b/source/nanoFramework.Tools.DebugLibrary.Net/PortSerial/EventHandlerForSerialDevice.cs @@ -110,9 +110,9 @@ private void OnAppDeactivated(object sender, EventArgs args) /// An exception may be thrown if the device could not be opened for extraordinary reasons. public async Task OpenDeviceAsync(DeviceInformation deviceInfo, string deviceSelector) { - await Task.Delay(250); - +#pragma warning disable ConfigureAwaitChecker // CAC001 device = await SerialDevice.FromIdAsync(deviceInfo.Id); +#pragma warning restore ConfigureAwaitChecker // CAC001 bool successfullyOpenedDevice = false; diff --git a/source/nanoFramework.Tools.DebugLibrary.Net/PortUsb/EventHandlerForUsbDevice.cs b/source/nanoFramework.Tools.DebugLibrary.Net/PortUsb/EventHandlerForUsbDevice.cs index 600966e6..84d411e4 100644 --- a/source/nanoFramework.Tools.DebugLibrary.Net/PortUsb/EventHandlerForUsbDevice.cs +++ b/source/nanoFramework.Tools.DebugLibrary.Net/PortUsb/EventHandlerForUsbDevice.cs @@ -27,10 +27,10 @@ public partial class EventHandlerForUsbDevice /// private void RegisterForDeviceAccessStatusChange() { - deviceAccessInformation = DeviceAccessInformation.CreateFromId(deviceInformation.Id); + //deviceAccessInformation = DeviceAccessInformation.CreateFromId(deviceInformation.Id); - deviceAccessEventHandler = new TypedEventHandler(OnDeviceAccessChanged); - deviceAccessInformation.AccessChanged += deviceAccessEventHandler; + //deviceAccessEventHandler = new TypedEventHandler(OnDeviceAccessChanged); + //deviceAccessInformation.AccessChanged += deviceAccessEventHandler; } /// @@ -48,7 +48,9 @@ private void RegisterForDeviceAccessStatusChange() /// An exception may be thrown if the device could not be opened for extraordinary reasons. public async Task OpenDeviceAsync(DeviceInformation deviceInfo, String deviceSelector) { +#pragma warning disable ConfigureAwaitChecker // CAC001 device = await Windows.Devices.Usb.UsbDevice.FromIdAsync(deviceInfo.Id); +#pragma warning restore ConfigureAwaitChecker // CAC001 bool successfullyOpenedDevice = false; diff --git a/source/nanoFramework.Tools.DebugLibrary.Net/nanoFramework.Tools.DebugLibrary.Net.csproj b/source/nanoFramework.Tools.DebugLibrary.Net/nanoFramework.Tools.DebugLibrary.Net.csproj index 712a5cab..d544e12c 100644 --- a/source/nanoFramework.Tools.DebugLibrary.Net/nanoFramework.Tools.DebugLibrary.Net.csproj +++ b/source/nanoFramework.Tools.DebugLibrary.Net/nanoFramework.Tools.DebugLibrary.Net.csproj @@ -84,6 +84,7 @@ For UWP look for the respective Nuget package. + diff --git a/source/nanoFramework.Tools.DebugLibrary.Net/packages.config b/source/nanoFramework.Tools.DebugLibrary.Net/packages.config index 8396f7e5..29a8c4cc 100644 --- a/source/nanoFramework.Tools.DebugLibrary.Net/packages.config +++ b/source/nanoFramework.Tools.DebugLibrary.Net/packages.config @@ -1,5 +1,6 @@  + diff --git a/source/nanoFramework.Tools.DebugLibrary.Shared/Extensions/DebuggerExtensions.cs b/source/nanoFramework.Tools.DebugLibrary.Shared/Extensions/DebuggerExtensions.cs index 59d4ffb9..3eeeb0a5 100644 --- a/source/nanoFramework.Tools.DebugLibrary.Shared/Extensions/DebuggerExtensions.cs +++ b/source/nanoFramework.Tools.DebugLibrary.Shared/Extensions/DebuggerExtensions.cs @@ -16,7 +16,7 @@ public static class DebuggerExtensions /// public static async Task IsDeviceInInitializeStateAsync(this Engine debugEngine) { - var result = await debugEngine.SetExecutionModeAsync(0, 0); + var result = await debugEngine.SetExecutionModeAsync(0, 0).ConfigureAwait(false); if (result.success) { diff --git a/source/nanoFramework.Tools.DebugLibrary.Shared/MFDeployTool/NanoFrameworkDeviceInfo.cs b/source/nanoFramework.Tools.DebugLibrary.Shared/MFDeployTool/NanoFrameworkDeviceInfo.cs index f5d7e2c7..b0b5fc56 100644 --- a/source/nanoFramework.Tools.DebugLibrary.Shared/MFDeployTool/NanoFrameworkDeviceInfo.cs +++ b/source/nanoFramework.Tools.DebugLibrary.Shared/MFDeployTool/NanoFrameworkDeviceInfo.cs @@ -36,10 +36,10 @@ public async Task GetDeviceInfo() if (!Dbg.IsConnectedTonanoCLR) return false; // get app domains from device - await GetAppDomainsAsync(cancelTSource.Token); + await GetAppDomainsAsync(cancelTSource.Token).ConfigureAwait(false); // get assemblies from device - await GetAssembliesAsync(cancelTSource.Token); + await GetAssembliesAsync(cancelTSource.Token).ConfigureAwait(false); Valid = true; @@ -50,14 +50,14 @@ private async Task GetAppDomainsAsync(CancellationToken cancellationToken) { if (Dbg.Capabilities.AppDomains) { - Commands.Debugging_TypeSys_AppDomains.Reply domainsReply = await Dbg.GetAppDomainsAsync(); + Commands.Debugging_TypeSys_AppDomains.Reply domainsReply = await Dbg.GetAppDomainsAsync().ConfigureAwait(false); // TODO add cancellation token code if (domainsReply != null) { foreach (uint id in domainsReply.Data) { - Commands.Debugging_Resolve_AppDomain.Reply reply = await Dbg.ResolveAppDomainAsync(id); + Commands.Debugging_Resolve_AppDomain.Reply reply = await Dbg.ResolveAppDomainAsync(id).ConfigureAwait(false); // TODO add cancellation token code if (reply != null) { @@ -70,7 +70,7 @@ private async Task GetAppDomainsAsync(CancellationToken cancellationToken) private async Task GetAssembliesAsync(CancellationToken cancellationToken) { - List reply = await Dbg.ResolveAllAssembliesAsync(cancellationToken); + List reply = await Dbg.ResolveAllAssembliesAsync(cancellationToken).ConfigureAwait(false); if (reply != null) foreach (Commands.DebuggingResolveAssembly resolvedAssm in reply) diff --git a/source/nanoFramework.Tools.DebugLibrary.Shared/NFDevice/NanoDevice.cs b/source/nanoFramework.Tools.DebugLibrary.Shared/NFDevice/NanoDevice.cs index bfa7a5a1..d91aecf3 100644 --- a/source/nanoFramework.Tools.DebugLibrary.Shared/NFDevice/NanoDevice.cs +++ b/source/nanoFramework.Tools.DebugLibrary.Shared/NFDevice/NanoDevice.cs @@ -74,11 +74,11 @@ public async Task ConnectAsync() { if (Device is NanoUsbDevice) { - return await Parent.ConnectDeviceAsync(this as NanoDeviceBase); + return await Parent.ConnectDeviceAsync(this as NanoDeviceBase).ConfigureAwait(false); } else if (Device is NanoSerialDevice) { - return await Parent.ConnectDeviceAsync(this as NanoDeviceBase); + return await Parent.ConnectDeviceAsync(this as NanoDeviceBase).ConfigureAwait(false); } return false; diff --git a/source/nanoFramework.Tools.DebugLibrary.Shared/NFDevice/NanoDeviceBase.cs b/source/nanoFramework.Tools.DebugLibrary.Shared/NFDevice/NanoDeviceBase.cs index 3357447b..2bdbdcfa 100644 --- a/source/nanoFramework.Tools.DebugLibrary.Shared/NFDevice/NanoDeviceBase.cs +++ b/source/nanoFramework.Tools.DebugLibrary.Shared/NFDevice/NanoDeviceBase.cs @@ -91,7 +91,7 @@ public async Task GetDeviceInfoAsync(bool force = true { // seems to be invalid so get it from device var mfDeviceInfo = new NanoFrameworkDeviceInfo(this); - await mfDeviceInfo.GetDeviceInfo(); + await mfDeviceInfo.GetDeviceInfo().ConfigureAwait(false); DeviceInfo = mfDeviceInfo; } @@ -105,7 +105,7 @@ public async Task GetDeviceInfoAsync(bool force = true /// public async Task PingAsync() { - var reply = await DebugEngine.GetConnectionSourceAsync(); + var reply = await DebugEngine.GetConnectionSourceAsync().ConfigureAwait(false); if (reply != null) { @@ -130,13 +130,13 @@ public async Task ConnectToNanoBooterAsync(CancellationToken cancellationT { bool ret = false; - if (!await DebugEngine.ConnectAsync(2, 500, true)) return false; + if (!await DebugEngine.ConnectAsync(2, 500, true).ConfigureAwait(false)) return false; if (DebugEngine != null) { - if (DebugEngine.ConnectionSource == ConnectionSource.NanoBooter) return true; + if (DebugEngine.ConnectionSource == ConnectionSource.nanoBooter) return true; - await DebugEngine.RebootDeviceAsync(RebootOption.EnterBootloader); + await DebugEngine.RebootDeviceAsync(RebootOption.EnterBootloader).ConfigureAwait(false); ///////////////////////////////////////// // FIXME @@ -172,9 +172,9 @@ public async Task ConnectToNanoBooterAsync(CancellationToken cancellationT // check if cancellation was requested if (cancellationToken.IsCancellationRequested) return false; - if (fConnected = await DebugEngine.ConnectAsync(1, 1000, true, ConnectionSource.Unknown)) + if (fConnected = await DebugEngine.ConnectAsync(1, 1000, true, ConnectionSource.Unknown).ConfigureAwait(false)) { - Commands.Monitor_Ping.Reply reply = await DebugEngine.GetConnectionSourceAsync(); + Commands.Monitor_Ping.Reply reply = await DebugEngine.GetConnectionSourceAsync().ConfigureAwait(false); ret = (reply.m_source == Commands.Monitor_Ping.c_Ping_Source_NanoBooter); @@ -206,26 +206,26 @@ public async Task EraseAsync(EraseOptions options, CancellationToken cance if (DebugEngine == null) throw new NanoFrameworkDeviceNoResponseException(); - if (!await DebugEngine.ConnectAsync(2, 500, true)) + if (!await DebugEngine.ConnectAsync(2, 500, true).ConfigureAwait(false)) { throw new NanoFrameworkDeviceNoResponseException(); } if (!IsClrDebuggerEnabled || 0 != (options & EraseOptions.Firmware)) { - fReset = (await PingAsync() == PingConnectionType.NanoCLR); + fReset = (await PingAsync().ConfigureAwait(false) == PingConnectionType.NanoCLR); - if (!await ConnectToNanoBooterAsync(cancellationToken)) + if (!await ConnectToNanoBooterAsync(cancellationToken).ConfigureAwait(false)) { throw new NanoBooterConnectionFailureException(); } } - var reply = await DebugEngine.GetFlashSectorMapAsync(); + var reply = await DebugEngine.GetFlashSectorMapAsync().ConfigureAwait(false); if (reply == null) throw new NanoFrameworkDeviceNoResponseException(); - Commands.Monitor_Ping.Reply ping = await DebugEngine.GetConnectionSourceAsync(); + Commands.Monitor_Ping.Reply ping = await DebugEngine.GetConnectionSourceAsync().ConfigureAwait(false); ret = true; @@ -237,7 +237,7 @@ public async Task EraseAsync(EraseOptions options, CancellationToken cance if (isConnectedToCLR) { - await DebugEngine.PauseExecutionAsync(); + await DebugEngine.PauseExecutionAsync().ConfigureAwait(false); } List eraseSectors = new List(); @@ -306,7 +306,7 @@ public async Task EraseAsync(EraseOptions options, CancellationToken cance { progress?.Report(new ProgressReport(value, total, string.Format("Erasing sector 0x{0:x08}", flashSectorData.m_StartAddress))); - var eraseResult = await DebugEngine.EraseMemoryAsync(flashSectorData.m_StartAddress, (flashSectorData.m_NumBlocks * flashSectorData.m_BytesPerBlock)); + var eraseResult = await DebugEngine.EraseMemoryAsync(flashSectorData.m_StartAddress, (flashSectorData.m_NumBlocks * flashSectorData.m_BytesPerBlock)).ConfigureAwait(false); ret &= eraseResult.success; @@ -316,7 +316,7 @@ public async Task EraseAsync(EraseOptions options, CancellationToken cance // reset if we specifically entered tinybooter for the erase if (fReset) { - await DebugEngine.ExecuteMemoryAsync(0); + await DebugEngine.ExecuteMemoryAsync(0).ConfigureAwait(false); } // reboot if we are talking to the clr @@ -324,7 +324,7 @@ public async Task EraseAsync(EraseOptions options, CancellationToken cance { progress?.Report(new ProgressReport(0, 0, "Rebooting...")); - await DebugEngine.RebootDeviceAsync(RebootOption.RebootClrOnly); + await DebugEngine.RebootDeviceAsync(RebootOption.RebootClrOnly).ConfigureAwait(false); } return ret; @@ -332,9 +332,9 @@ public async Task EraseAsync(EraseOptions options, CancellationToken cance public async Task DeployUpdateAsync(StorageFile comprFilePath, CancellationToken cancellationToken, IProgress progress = null) { - if (DebugEngine.ConnectionSource == ConnectionSource.NanoCLR) + if (DebugEngine.ConnectionSource == ConnectionSource.nanoCLR) { - if (await DeployMFUpdateAsync(comprFilePath, cancellationToken, progress)) return true; + if (await DeployMFUpdateAsync(comprFilePath, cancellationToken, progress).ConfigureAwait(false)) return true; } return false; @@ -358,9 +358,9 @@ public async Task> DeployAsync(StorageFile srecFile, Cancellat if (DebugEngine == null) throw new NanoFrameworkDeviceNoResponseException(); // make sure we know who we are talking to - if (await CheckForMicroBooterAsync(cancellationToken)) + if (await CheckForMicroBooterAsync(cancellationToken).ConfigureAwait(false)) { - var reply = await DeploySRECAsync(srecFile, cancellationToken); + var reply = await DeploySRECAsync(srecFile, cancellationToken).ConfigureAwait(false); // check if request was successful if (reply.Item2) @@ -375,9 +375,9 @@ public async Task> DeployAsync(StorageFile srecFile, Cancellat } } - await DebugEngine.ConnectAsync(1, 1000, false, ConnectionSource.Unknown); + await DebugEngine.ConnectAsync(1, 1000, false, ConnectionSource.Unknown).ConfigureAwait(false); - var parseResult = await SRecordFile.ParseAsync(srecFile); + var parseResult = await SRecordFile.ParseAsync(srecFile).ConfigureAwait(false); entryPoint = parseResult.Item1; blocks = parseResult.Item2; @@ -391,7 +391,7 @@ public async Task> DeployAsync(StorageFile srecFile, Cancellat total += (blocks[i] as SRecordFile.Block).data.Length; } - await PrepareForDeployAsync(blocks, cancellationToken, progress); + await PrepareForDeployAsync(blocks, cancellationToken, progress).ConfigureAwait(false); @@ -408,7 +408,7 @@ public async Task> DeployAsync(StorageFile srecFile, Cancellat progress?.Report(new ProgressReport(0, total, string.Format("Erasing sector 0x{0:x08}", block.address))); // the clr requires erase before writing - var eraseResult = await DebugEngine.EraseMemoryAsync(block.address, (uint)len); + var eraseResult = await DebugEngine.EraseMemoryAsync(block.address, (uint)len).ConfigureAwait(false); if (!eraseResult.success) { @@ -428,7 +428,7 @@ public async Task> DeployAsync(StorageFile srecFile, Cancellat return new Tuple(0, false); } - var writeResult = await DebugEngine.WriteMemoryAsync(addr, data); + var writeResult = await DebugEngine.WriteMemoryAsync(addr, data).ConfigureAwait(false); if (writeResult.success == false) { return new Tuple(0, false); @@ -459,7 +459,7 @@ public async Task ExecuteAync(uint entryPoint, CancellationToken cancellat { if (DebugEngine == null) throw new NanoFrameworkDeviceNoResponseException(); - if (await CheckForMicroBooterAsync(cancellationToken)) + if (await CheckForMicroBooterAsync(cancellationToken).ConfigureAwait(false)) { // check if cancellation was requested if (cancellationToken.IsCancellationRequested) throw new NanoUserExitException(); @@ -474,12 +474,12 @@ public async Task ExecuteAync(uint entryPoint, CancellationToken cancellat // check if cancellation was requested if (cancellationToken.IsCancellationRequested) throw new NanoUserExitException(); - await DebugEngine.SendBufferAsync(UTF8Encoding.UTF8.GetBytes(execRec), TimeSpan.FromMilliseconds(1000), cancellationToken); + await DebugEngine.SendBufferAsync(UTF8Encoding.UTF8.GetBytes(execRec), TimeSpan.FromMilliseconds(1000), cancellationToken).ConfigureAwait(false); // check if cancellation was requested if (cancellationToken.IsCancellationRequested) throw new NanoUserExitException(); - await DebugEngine.SendBufferAsync(UTF8Encoding.UTF8.GetBytes("\n"), TimeSpan.FromMilliseconds(1000), cancellationToken); + await DebugEngine.SendBufferAsync(UTF8Encoding.UTF8.GetBytes("\n"), TimeSpan.FromMilliseconds(1000), cancellationToken).ConfigureAwait(false); // check if cancellation was requested if (cancellationToken.IsCancellationRequested) throw new NanoUserExitException(); @@ -497,18 +497,18 @@ public async Task ExecuteAync(uint entryPoint, CancellationToken cancellat return false; } - Commands.Monitor_Ping.Reply reply = await DebugEngine.GetConnectionSourceAsync(); + Commands.Monitor_Ping.Reply reply = await DebugEngine.GetConnectionSourceAsync().ConfigureAwait(false); if (reply == null) throw new NanoFrameworkDeviceNoResponseException(); // only execute if we are talking to the nanoBooter, otherwise reboot if (reply.m_source == Commands.Monitor_Ping.c_Ping_Source_NanoBooter) { - return await DebugEngine.ExecuteMemoryAsync(entryPoint); + return await DebugEngine.ExecuteMemoryAsync(entryPoint).ConfigureAwait(false); } else // if we are talking to the CLR then we simply did a deployment update, so reboot { - await DebugEngine.RebootDeviceAsync(RebootOption.RebootClrOnly); + await DebugEngine.RebootDeviceAsync(RebootOption.RebootClrOnly).ConfigureAwait(false); } return true; @@ -528,7 +528,7 @@ internal async Task CheckForMicroBooterAsync(CancellationToken cancellatio { if (cancellationToken.IsCancellationRequested) return false; - await DebugEngine.SendBufferAsync(UTF8Encoding.UTF8.GetBytes("xx\n"), TimeSpan.FromMilliseconds(5000), cancellationToken); + await DebugEngine.SendBufferAsync(UTF8Encoding.UTF8.GetBytes("xx\n"), TimeSpan.FromMilliseconds(5000), cancellationToken).ConfigureAwait(false); if (m_evtMicroBooterError.WaitOne(100)) { @@ -556,7 +556,9 @@ private async Task DeployMFUpdateAsync(StorageFile zipFile, CancellationTo int handle = -1; int idx = 0; +#pragma warning disable ConfigureAwaitChecker // CAC001 var fileInfo = await zipFile.GetBasicPropertiesAsync(); +#pragma warning restore ConfigureAwaitChecker // CAC001 int numPkts = ((int)fileInfo.Size + c_PacketSize - 1) / c_PacketSize; @@ -569,14 +571,14 @@ private async Task DeployMFUpdateAsync(StorageFile zipFile, CancellationTo //Debug.WriteLine(updateId); - handle = await DebugEngine.StartUpdateAsync("NetMF", 4, 4, updateId, 0, 0, (uint)fileInfo.Size, (uint)c_PacketSize, 0); + handle = await DebugEngine.StartUpdateAsync("NetMF", 4, 4, updateId, 0, 0, (uint)fileInfo.Size, (uint)c_PacketSize, 0).ConfigureAwait(false); if (handle > -1) { uint authType; IAsyncResult iar = null; // perform request - var resp = await DebugEngine.UpdateAuthCommandAsync(handle, 1, null); + var resp = await DebugEngine.UpdateAuthCommandAsync(handle, 1, null).ConfigureAwait(false); // check result if (!resp.Item2 || resp.Item1.Length < 4) return false; @@ -603,7 +605,7 @@ private async Task DeployMFUpdateAsync(StorageFile zipFile, CancellationTo // } //} - if (!await DebugEngine.UpdateAuthenticateAsync(handle, pubKey)) + if (!await DebugEngine.UpdateAuthenticateAsync(handle, pubKey).ConfigureAwait(false)) { return false; } @@ -657,14 +659,16 @@ private async Task DeployMFUpdateAsync(StorageFile zipFile, CancellationTo { } +#pragma warning disable ConfigureAwaitChecker // CAC001 IBuffer buffer = await FileIO.ReadBufferAsync(zipFile); +#pragma warning restore ConfigureAwaitChecker // CAC001 using (DataReader dataReader = DataReader.FromBuffer(buffer)) { dataReader.ReadBytes(packet); uint crc = CRC.ComputeCRC(packet, 0, packet.Length, 0); - if (!await DebugEngine.AddPacketAsync(handle, (uint)idx++, packet, CRC.ComputeCRC(packet, 0, packet.Length, 0))) return false; + if (!await DebugEngine.AddPacketAsync(handle, (uint)idx++, packet, CRC.ComputeCRC(packet, 0, packet.Length, 0)).ConfigureAwait(false)) return false; imageCRC = CRC.ComputeCRC(packet, 0, packet.Length, imageCRC); @@ -673,8 +677,10 @@ private async Task DeployMFUpdateAsync(StorageFile zipFile, CancellationTo if (hash != null) { +#pragma warning disable ConfigureAwaitChecker // CAC001 buffer = await FileIO.ReadBufferAsync(zipFile); - // hash it +#pragma warning restore ConfigureAwaitChecker // CAC001 + // hash it IBuffer hashed = hash.HashData(buffer); CryptographicBuffer.CopyToByteArray(hashed, out sig); } @@ -694,7 +700,7 @@ private async Task DeployMFUpdateAsync(StorageFile zipFile, CancellationTo } } - if (await DebugEngine.InstallUpdateAsync(handle, sig)) + if (await DebugEngine.InstallUpdateAsync(handle, sig).ConfigureAwait(false)) { return true; } @@ -714,7 +720,9 @@ private async Task> DeploySRECAsync(StorageFile srecFile, Canc m_execSrecHash.Clear(); // create .EXT file for SREC file +#pragma warning disable ConfigureAwaitChecker // CAC001 var folder = await srecFile.GetParentAsync(); +#pragma warning restore ConfigureAwaitChecker // CAC001 int m_totalSrecs = 0; uint m_minSrecAddr = uint.MaxValue; @@ -723,21 +731,27 @@ private async Task> DeploySRECAsync(StorageFile srecFile, Canc if (srecFile.IsAvailable) { // check is EXT file exists, if yes delete it +#pragma warning disable ConfigureAwaitChecker // CAC001 var srecExtFile = await folder.TryGetItemAsync(Path.GetFileNameWithoutExtension(srecFile.Name) + ".ext") as StorageFile; +#pragma warning restore ConfigureAwaitChecker // CAC001 if (srecExtFile != null) { +#pragma warning disable ConfigureAwaitChecker // CAC001 await srecExtFile.DeleteAsync(); +#pragma warning restore ConfigureAwaitChecker // CAC001 } - if (await PreProcesSrecAsync(srecFile)) + if (await PreProcesSrecAsync(srecFile).ConfigureAwait(false)) { +#pragma warning disable ConfigureAwaitChecker // CAC001 srecExtFile = await folder.TryGetItemAsync(srecFile.Name.Replace(srecFile.FileType, "") + ".ext") as StorageFile; +#pragma warning restore ConfigureAwaitChecker // CAC001 } // check if cancellation was requested if (cancellationToken.IsCancellationRequested) throw new NanoUserExitException(); - var parsedFile = await ParseSrecFileAsync(srecExtFile); + var parsedFile = await ParseSrecFileAsync(srecExtFile).ConfigureAwait(false); try { @@ -781,11 +795,11 @@ private async Task> DeploySRECAsync(StorageFile srecFile, Canc continue; } - await DebugEngine.SendBufferAsync(UTF8Encoding.UTF8.GetBytes("\n"), TimeSpan.FromMilliseconds(1000), cancellationToken); + await DebugEngine.SendBufferAsync(UTF8Encoding.UTF8.GetBytes("\n"), TimeSpan.FromMilliseconds(1000), cancellationToken).ConfigureAwait(false); - await DebugEngine.SendBufferAsync(UTF8Encoding.UTF8.GetBytes(parsedFile.Records[key]), TimeSpan.FromMilliseconds(20000), cancellationToken); + await DebugEngine.SendBufferAsync(UTF8Encoding.UTF8.GetBytes(parsedFile.Records[key]), TimeSpan.FromMilliseconds(20000), cancellationToken).ConfigureAwait(false); - await DebugEngine.SendBufferAsync(UTF8Encoding.UTF8.GetBytes("\n"), TimeSpan.FromMilliseconds(1000), cancellationToken); + await DebugEngine.SendBufferAsync(UTF8Encoding.UTF8.GetBytes("\n"), TimeSpan.FromMilliseconds(1000), cancellationToken).ConfigureAwait(false); if (pipe-- <= 0) { @@ -830,8 +844,13 @@ private async Task> DeploySRECAsync(StorageFile srecFile, Canc symdefFilePath = Path.GetDirectoryName(srecFile.Path) + "\\" + basefile + ".symdefs"; } +#pragma warning disable ConfigureAwaitChecker // CAC001 var binFile = await folder.TryGetItemAsync(binFilePath) as StorageFile; +#pragma warning restore ConfigureAwaitChecker // CAC001 + +#pragma warning disable ConfigureAwaitChecker // CAC001 var symdefFile = await folder.TryGetItemAsync(symdefFilePath) as StorageFile; +#pragma warning restore ConfigureAwaitChecker // CAC001 // check if cancellation was requested if (cancellationToken.IsCancellationRequested) throw new NanoUserExitException(); @@ -839,12 +858,17 @@ private async Task> DeploySRECAsync(StorageFile srecFile, Canc // send image crc if (binFile != null && symdefFile != null) { +#pragma warning disable ConfigureAwaitChecker // CAC001 var fileInfo = await binFile.GetBasicPropertiesAsync(); +#pragma warning restore ConfigureAwaitChecker // CAC001 UInt32 imageCRC = 0; // read lines from SREC file +#pragma warning disable ConfigureAwaitChecker // CAC001 var textLines = await FileIO.ReadLinesAsync(symdefFile); +#pragma warning restore ConfigureAwaitChecker // CAC001 + foreach (string line in textLines) { // check if cancellation was requested @@ -915,14 +939,20 @@ private async Task PreProcesSrecAsync(StorageFile srecFile) if (!srecFile.IsAvailable) return false; // create .EXT file for SREC file +#pragma warning disable ConfigureAwaitChecker // CAC001 var folder = await srecFile.GetParentAsync(); +#pragma warning restore ConfigureAwaitChecker // CAC001 try { // read lines from SREC file +#pragma warning disable ConfigureAwaitChecker // CAC001 var textLines = await FileIO.ReadLinesAsync(srecFile); +#pragma warning restore ConfigureAwaitChecker // CAC001 +#pragma warning disable ConfigureAwaitChecker // CAC001 StorageFile srecExtFile = await folder.CreateFileAsync(Path.GetFileNameWithoutExtension(srecFile.Name) + ".ext", CreationCollisionOption.ReplaceExisting); +#pragma warning restore ConfigureAwaitChecker // CAC001 const int c_MaxRecords = 8; int iRecord = 0; @@ -979,7 +1009,9 @@ private async Task PreProcesSrecAsync(StorageFile srecFile) // write crc sb.Append(string.Format("{0:X02}", (0xFF - (0xFF & currentCRC)))); +#pragma warning disable ConfigureAwaitChecker // CAC001 await FileIO.WriteTextAsync(srecExtFile, sb.ToString()); +#pragma warning restore ConfigureAwaitChecker // CAC001 currentCRC = 0; iRecord = 0; @@ -999,21 +1031,29 @@ private async Task PreProcesSrecAsync(StorageFile srecFile) // write crc sb.Append(string.Format("{0:X02}", (0xFF - (0xFF & currentCRC)))); +#pragma warning disable ConfigureAwaitChecker // CAC001 await FileIO.WriteTextAsync(srecExtFile, sb.ToString()); +#pragma warning restore ConfigureAwaitChecker // CAC001 } if (s7rec != "") { +#pragma warning disable ConfigureAwaitChecker // CAC001 await FileIO.WriteTextAsync(srecExtFile, s7rec); +#pragma warning restore ConfigureAwaitChecker // CAC001 } } catch { +#pragma warning disable ConfigureAwaitChecker // CAC001 var thisFile = await folder.TryGetItemAsync(Path.GetFileNameWithoutExtension(srecFile.Name) + ".ext") as StorageFile; +#pragma warning restore ConfigureAwaitChecker // CAC001 if (thisFile != null) { +#pragma warning disable ConfigureAwaitChecker // CAC001 await thisFile.DeleteAsync(); +#pragma warning restore ConfigureAwaitChecker // CAC001 } return false; @@ -1035,10 +1075,10 @@ private async Task PrepareForDeployAsync(List blocks, Cancell progress?.Report(new ProgressReport(0, 1, "Connecting to TinyBooter...")); // only check for signature file if we are uploading firmware - if (!await ConnectToNanoBooterAsync(cancellationToken)) throw new NanoFrameworkDeviceNoResponseException(); + if (!await ConnectToNanoBooterAsync(cancellationToken).ConfigureAwait(false)) throw new NanoFrameworkDeviceNoResponseException(); } - var flasSectorsMap = await DebugEngine.GetFlashSectorMapAsync(); + var flasSectorsMap = await DebugEngine.GetFlashSectorMapAsync().ConfigureAwait(false); if (flasSectorsMap == null || flasSectorsMap.Count == 0) throw new NanoFrameworkDeviceNoResponseException(); @@ -1055,12 +1095,12 @@ private async Task PrepareForDeployAsync(List blocks, Cancell } else { - if (DebugEngine.ConnectionSource != ConnectionSource.NanoBooter) + if (DebugEngine.ConnectionSource != ConnectionSource.nanoBooter) { progress?.Report(new ProgressReport(0, 1, "Connecting to nanoBooter...")); // only check for signature file if we are uploading firmware - if (!await ConnectToNanoBooterAsync(cancellationToken)) throw new NanoFrameworkDeviceNoResponseException(); + if (!await ConnectToNanoBooterAsync(cancellationToken).ConfigureAwait(false)) throw new NanoFrameworkDeviceNoResponseException(); } } break; @@ -1069,16 +1109,16 @@ private async Task PrepareForDeployAsync(List blocks, Cancell } if (fEraseDeployment) { - await EraseAsync(EraseOptions.Deployment, cancellationToken, progress); + await EraseAsync(EraseOptions.Deployment, cancellationToken, progress).ConfigureAwait(false); } - else if (DebugEngine.ConnectionSource != ConnectionSource.NanoBooter) + else if (DebugEngine.ConnectionSource != ConnectionSource.nanoBooter) { //if we are not writing to the deployment sector then assure that we are talking with nanoBooter - await ConnectToNanoBooterAsync(cancellationToken); + await ConnectToNanoBooterAsync(cancellationToken).ConfigureAwait(false); } - if (DebugEngine.ConnectionSource == ConnectionSource.NanoCLR) + if (DebugEngine.ConnectionSource == ConnectionSource.nanoCLR) { - await DebugEngine.PauseExecutionAsync(); + await DebugEngine.PauseExecutionAsync().ConfigureAwait(false); } } } diff --git a/source/nanoFramework.Tools.DebugLibrary.Shared/PortSerial/SerialPort.cs b/source/nanoFramework.Tools.DebugLibrary.Shared/PortSerial/SerialPort.cs index 1dc97a90..219b5b3d 100644 --- a/source/nanoFramework.Tools.DebugLibrary.Shared/PortSerial/SerialPort.cs +++ b/source/nanoFramework.Tools.DebugLibrary.Shared/PortSerial/SerialPort.cs @@ -248,11 +248,11 @@ private async void AddDeviceToList(DeviceInformation deviceInformation, String d if (isAllDevicesEnumerated) { // try opening the device to check for a valid nanoFramework device - if (await ConnectSerialDeviceAsync(newNanoFrameworkDevice.Device.DeviceInformation)) + if (await ConnectSerialDeviceAsync(newNanoFrameworkDevice.Device.DeviceInformation).ConfigureAwait(false)) { Debug.WriteLine("New Serial device: " + deviceInformation.Id); - if(await CheckValidNanoFrameworkSerialDeviceAsync()) + if(await CheckValidNanoFrameworkSerialDeviceAsync().ConfigureAwait(false)) { // done here, close the device EventHandlerForSerialDevice.Current.CloseDevice(); @@ -473,7 +473,7 @@ private async Task CheckValidNanoFrameworkSerialDeviceAsync() var device = FindNanoFrameworkDevice(EventHandlerForSerialDevice.Current.DeviceInformation.Id); // need an extra check on this because this can be 'just' a regular COM port without any nanoFramework device behind - var connectionResult = await device.DebugEngine.ConnectAsync(1, 500, false); + var connectionResult = await device.DebugEngine.ConnectAsync(1, 500, false).ConfigureAwait(false); if (connectionResult) { @@ -527,7 +527,7 @@ public async Task ConnectDeviceAsync(NanoDeviceBase device) inputStreamReader = null; outputStreamWriter = null; - return await ConnectSerialDeviceAsync((device as NanoDevice).Device.DeviceInformation as SerialDeviceInformation); + return await ConnectSerialDeviceAsync((device as NanoDevice).Device.DeviceInformation as SerialDeviceInformation).ConfigureAwait(false); } private async Task ConnectSerialDeviceAsync(SerialDeviceInformation serialDeviceInfo) @@ -548,7 +548,7 @@ private async Task ConnectSerialDeviceAsync(SerialDeviceInformation serial // access the Current in EventHandlerForDevice to create a watcher for the device we are connecting to var isConnected = EventHandlerForSerialDevice.Current.IsDeviceConnected; - return await EventHandlerForSerialDevice.Current.OpenDeviceAsync(serialDeviceInfo.DeviceInformation, serialDeviceInfo.DeviceSelector); + return await EventHandlerForSerialDevice.Current.OpenDeviceAsync(serialDeviceInfo.DeviceInformation, serialDeviceInfo.DeviceSelector).ConfigureAwait(false); } public void DisconnectDevice(NanoDeviceBase device) @@ -591,7 +591,7 @@ public async Task SendBufferAsync(byte[] buffer, TimeSpan waiTimeout, Canc // serial works as a "single channel" so we can only TX or RX, // meaning that access to the resource has to be protected with a semephore - await semaphore.WaitAsync(); + await semaphore.WaitAsync().ConfigureAwait(false); try { @@ -602,7 +602,7 @@ public async Task SendBufferAsync(byte[] buffer, TimeSpan waiTimeout, Canc // because we have an external cancellation token and the above timeout cancellation token, need to combine both Task storeAsyncTask = outputStreamWriter.StoreAsync().AsTask(cancellationToken.AddTimeout(waiTimeout)); - bytesWritten = await storeAsyncTask; + bytesWritten = await storeAsyncTask.ConfigureAwait(false); if (bytesWritten > 0) { @@ -639,7 +639,7 @@ public async Task ReadBufferAsync(uint bytesToRead, TimeSpan waiTimeout, { // serial works as a "single channel" so we can only TX or RX, // meaning that access to the resource has to be protected with a semephore - await semaphore.WaitAsync(); + await semaphore.WaitAsync().ConfigureAwait(false); // create a stream reader with serial device InputStream, if there isn't one already if (inputStreamReader == null) @@ -654,7 +654,7 @@ public async Task ReadBufferAsync(uint bytesToRead, TimeSpan waiTimeout, Task loadAsyncTask = inputStreamReader.LoadAsync(bytesToRead).AsTask(cancellationToken.AddTimeout(waiTimeout)); // get how many bytes are available to read - uint bytesRead = await loadAsyncTask; + uint bytesRead = await loadAsyncTask.ConfigureAwait(false); byte[] readBuffer = new byte[bytesToRead]; inputStreamReader.ReadBytes(readBuffer); diff --git a/source/nanoFramework.Tools.DebugLibrary.Shared/PortUSB/UsbPort.cs b/source/nanoFramework.Tools.DebugLibrary.Shared/PortUSB/UsbPort.cs index b660f8e6..31ba5df6 100644 --- a/source/nanoFramework.Tools.DebugLibrary.Shared/PortUSB/UsbPort.cs +++ b/source/nanoFramework.Tools.DebugLibrary.Shared/PortUSB/UsbPort.cs @@ -233,10 +233,10 @@ private async void AddDeviceToList(DeviceInformation deviceInformation, String d // now fill in the description // try opening the device to read the descriptor - if (await ConnectUsbDeviceAsync(newNanoFrameworkDevice.Device.DeviceInformation)) + if (await ConnectUsbDeviceAsync(newNanoFrameworkDevice.Device.DeviceInformation).ConfigureAwait(false)) { // the device description format is kept to maintain backwards compatibility - newNanoFrameworkDevice.Description = EventHandlerForUsbDevice.Current.DeviceInformation.Name + "_" + await GetDeviceDescriptor(5); + newNanoFrameworkDevice.Description = EventHandlerForUsbDevice.Current.DeviceInformation.Name + "_" + await GetDeviceDescriptor(5).ConfigureAwait(false); Debug.WriteLine("Add new nanoFramework device to list: " + newNanoFrameworkDevice.Description + " @ " + newNanoFrameworkDevice.Device.DeviceInformation.DeviceSelector); @@ -387,7 +387,9 @@ private async Task GetDeviceDescriptor(int index) }; // send control to device +#pragma warning disable ConfigureAwaitChecker // CAC001 IBuffer responseBuffer = await EventHandlerForUsbDevice.Current.Device.SendControlInTransferAsync(setupPacket, buffer); +#pragma warning restore ConfigureAwaitChecker // CAC001 // read from a buffer with a data reader DataReader reader = DataReader.FromBuffer(responseBuffer); @@ -435,7 +437,7 @@ protected virtual void OnDeviceEnumerationCompleted() public async Task ConnectDeviceAsync(NanoDeviceBase device) { - return await ConnectUsbDeviceAsync((device as NanoDevice).Device.DeviceInformation as UsbDeviceInformation); + return await ConnectUsbDeviceAsync((device as NanoDevice).Device.DeviceInformation as UsbDeviceInformation).ConfigureAwait(false); } private async Task ConnectUsbDeviceAsync(UsbDeviceInformation usbDeviceInfo) @@ -453,7 +455,7 @@ private async Task ConnectUsbDeviceAsync(UsbDeviceInformation usbDeviceInf // Create an EventHandlerForDevice to watch for the device we are connecting to EventHandlerForUsbDevice.CreateNewEventHandlerForDevice(); - return await EventHandlerForUsbDevice.Current.OpenDeviceAsync(usbDeviceInfo.DeviceInformation, usbDeviceInfo.DeviceSelector); + return await EventHandlerForUsbDevice.Current.OpenDeviceAsync(usbDeviceInfo.DeviceInformation, usbDeviceInfo.DeviceSelector).ConfigureAwait(false); } public void DisconnectDevice(NanoDeviceBase device) @@ -519,7 +521,7 @@ public async Task SendBufferAsync(byte[] buffer, TimeSpan waiTimeout, Canc storeAsyncTask = writer.StoreAsync().AsTask(linkedCancelationToken); } - bytesWritten = await storeAsyncTask; + bytesWritten = await storeAsyncTask.ConfigureAwait(false); if (bytesWritten > 0) { @@ -567,7 +569,7 @@ public async Task ReadBufferAsync(uint bytesToRead, TimeSpan waiTimeout, Task loadAsyncTask; //Debug.WriteLine("### waiting"); - await semaphore.WaitAsync(); + await semaphore.WaitAsync().ConfigureAwait(false); //Debug.WriteLine("### got it"); try @@ -596,7 +598,9 @@ public async Task ReadBufferAsync(uint bytesToRead, TimeSpan waiTimeout, if (readCount > 0 && bytesToRead > 0) { +#pragma warning disable ConfigureAwaitChecker // CAC001 await reader.LoadAsync(readCount); +#pragma warning restore ConfigureAwaitChecker // CAC001 byte[] readBuffer = new byte[bytesToRead]; reader.ReadBytes(readBuffer); diff --git a/source/nanoFramework.Tools.DebugLibrary.Shared/Runtime/RunTimeValue.cs b/source/nanoFramework.Tools.DebugLibrary.Shared/Runtime/RunTimeValue.cs index 9faef1a1..baa52620 100644 --- a/source/nanoFramework.Tools.DebugLibrary.Shared/Runtime/RunTimeValue.cs +++ b/source/nanoFramework.Tools.DebugLibrary.Shared/Runtime/RunTimeValue.cs @@ -354,11 +354,11 @@ protected async Task SetBlockAsync(uint dt, byte[] data) if (IsArrayReference) { - fRes = await m_eng.SetArrayElementAsync(m_handle.m_arrayref_referenceID, m_handle.m_arrayref_index, data); + fRes = await m_eng.SetArrayElementAsync(m_handle.m_arrayref_referenceID, m_handle.m_arrayref_index, data).ConfigureAwait(false); } else { - fRes = await m_eng.SetBlockAsync(m_handle.m_referenceID, dt, data); + fRes = await m_eng.SetBlockAsync(m_handle.m_referenceID, dt, data).ConfigureAwait(false); } return fRes; @@ -375,7 +375,7 @@ public async Task AssignAsync(uint referenceIdDirect) // referenceIdDirect is the data pointer for the CLR_RT_HeapBlock. We subtract 4 to point to the id // portion of the heapblock. For the second parameter we need to use the direct reference because // ReferenceId will return null in this case since the value has not been assigned yet. - return await m_eng.AssignRuntimeValueAsync(referenceIdDirect - 4, ReferenceIdDirect - 4); + return await m_eng.AssignRuntimeValueAsync(referenceIdDirect - 4, ReferenceIdDirect - 4).ConfigureAwait(false); } public async Task AssignAsync(RuntimeValue val) @@ -393,7 +393,7 @@ public async Task AssignAsync(RuntimeValue val) Array.Copy(val.m_handle.m_builtinValue, data, data.Length); } - if (await SetBlockAsync(dt, data)) + if (await SetBlockAsync(dt, data).ConfigureAwait(false)) { retval = this; } @@ -416,7 +416,7 @@ public async Task AssignAsync(RuntimeValue val) throw new InvalidCastException("The two runtime values are incompatible"); } - retval = await AssignAsync(val != null ? val.ReferenceIdDirect : 0); + retval = await AssignAsync(val != null ? val.ReferenceIdDirect : 0).ConfigureAwait(false); } return retval; diff --git a/source/nanoFramework.Tools.DebugLibrary.Shared/Runtime/RuntimeValue_Array.cs b/source/nanoFramework.Tools.DebugLibrary.Shared/Runtime/RuntimeValue_Array.cs index 8d9597ef..796ddc75 100644 --- a/source/nanoFramework.Tools.DebugLibrary.Shared/Runtime/RuntimeValue_Array.cs +++ b/source/nanoFramework.Tools.DebugLibrary.Shared/Runtime/RuntimeValue_Array.cs @@ -24,7 +24,7 @@ protected internal RuntimeValue_Array(Engine eng, WireProtocol.Commands.Debuggin public override async Task GetElementAsync(uint index) { - return await m_eng.GetArrayElementAsync(m_handle.m_referenceID, index); + return await m_eng.GetArrayElementAsync(m_handle.m_referenceID, index).ConfigureAwait(false); } public override uint Length { get { return m_handle.m_array_numOfElements; } } diff --git a/source/nanoFramework.Tools.DebugLibrary.Shared/Runtime/RuntimeValue_Class.cs b/source/nanoFramework.Tools.DebugLibrary.Shared/Runtime/RuntimeValue_Class.cs index 19eb7fdf..2dd18b43 100644 --- a/source/nanoFramework.Tools.DebugLibrary.Shared/Runtime/RuntimeValue_Class.cs +++ b/source/nanoFramework.Tools.DebugLibrary.Shared/Runtime/RuntimeValue_Class.cs @@ -32,7 +32,7 @@ public override uint NumOfFields public override async Task GetFieldAsync(uint offset, uint fd) { - return await m_eng.GetFieldValueAsync(this, offset, fd); + return await m_eng.GetFieldValueAsync(this, offset, fd).ConfigureAwait(false); } } } diff --git a/source/nanoFramework.Tools.DebugLibrary.Shared/Runtime/RuntimeValue_Indirect.cs b/source/nanoFramework.Tools.DebugLibrary.Shared/Runtime/RuntimeValue_Indirect.cs index 2ee97519..10f79b3c 100644 --- a/source/nanoFramework.Tools.DebugLibrary.Shared/Runtime/RuntimeValue_Indirect.cs +++ b/source/nanoFramework.Tools.DebugLibrary.Shared/Runtime/RuntimeValue_Indirect.cs @@ -81,17 +81,17 @@ internal override async Task SetStringValueAsync(string val) { if (m_value == null) throw new NotImplementedException(); - await m_value.SetStringValueAsync(val); + await m_value.SetStringValueAsync(val).ConfigureAwait(false); } public override async Task GetFieldAsync(uint offset, uint fd) { - return (m_value == null) ? null : await m_value.GetFieldAsync(offset, fd); + return (m_value == null) ? null : await m_value.GetFieldAsync(offset, fd).ConfigureAwait(false); } public override async Task GetElementAsync(uint index) { - return (m_value == null) ? null : await m_value.GetElementAsync(index); + return (m_value == null) ? null : await m_value.GetElementAsync(index).ConfigureAwait(false); } } } diff --git a/source/nanoFramework.Tools.DebugLibrary.Shared/Runtime/RuntimeValue_String.cs b/source/nanoFramework.Tools.DebugLibrary.Shared/Runtime/RuntimeValue_String.cs index 207d3735..71f1ffc1 100644 --- a/source/nanoFramework.Tools.DebugLibrary.Shared/Runtime/RuntimeValue_String.cs +++ b/source/nanoFramework.Tools.DebugLibrary.Shared/Runtime/RuntimeValue_String.cs @@ -70,7 +70,7 @@ internal override async Task SetStringValueAsync(string val) throw new ArgumentException("String must have same length"); } - var writeResult = await m_eng.WriteMemoryAsync(m_handle.m_charsInString, buf); + var writeResult = await m_eng.WriteMemoryAsync(m_handle.m_charsInString, buf).ConfigureAwait(false); if (writeResult.success == false) { throw new ArgumentException("Cannot write string"); diff --git a/source/nanoFramework.Tools.DebugLibrary.Shared/SRecordFile.cs b/source/nanoFramework.Tools.DebugLibrary.Shared/SRecordFile.cs index c3bc02f8..e342f75d 100644 --- a/source/nanoFramework.Tools.DebugLibrary.Shared/SRecordFile.cs +++ b/source/nanoFramework.Tools.DebugLibrary.Shared/SRecordFile.cs @@ -38,9 +38,11 @@ static public async Task>> ParseAsync(StorageFile file) throw new System.IO.FileNotFoundException(String.Format("Cannot find {0}", file)); } +#pragma warning disable ConfigureAwaitChecker // CAC001 var textLines = await FileIO.ReadLinesAsync(file); +#pragma warning restore ConfigureAwaitChecker // CAC001 - foreach(string line in textLines) + foreach (string line in textLines) { int lineNum = 0; diff --git a/source/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/ConnectionSource.cs b/source/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/ConnectionSource.cs index b65dd956..dcca4f54 100644 --- a/source/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/ConnectionSource.cs +++ b/source/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/ConnectionSource.cs @@ -8,7 +8,7 @@ namespace nanoFramework.Tools.Debugger.WireProtocol public enum ConnectionSource { Unknown = 0, - NanoBooter, - NanoCLR, + nanoBooter, + nanoCLR, }; } diff --git a/source/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Controller.cs b/source/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Controller.cs index 13c18ec4..46c6a214 100644 --- a/source/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Controller.cs +++ b/source/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Controller.cs @@ -69,7 +69,7 @@ internal void SetMarker(Packet bp, string sig) public async Task QueueOutputAsync(MessageRaw raw, CancellationToken cancellationToken) { Debug.WriteLine("QueueOutputAsync 1"); - await SendRawBufferAsync(raw.Header, TimeSpan.FromMilliseconds(1000), cancellationToken); + await SendRawBufferAsync(raw.Header, TimeSpan.FromMilliseconds(1000), cancellationToken).ConfigureAwait(false); // check for cancelation request if (cancellationToken.IsCancellationRequested) @@ -83,7 +83,7 @@ public async Task QueueOutputAsync(MessageRaw raw, CancellationToken cance { Debug.WriteLine("QueueOutputAsync 2"); - await SendRawBufferAsync(raw.Payload, TimeSpan.FromMilliseconds(1000), cancellationToken); + await SendRawBufferAsync(raw.Payload, TimeSpan.FromMilliseconds(1000), cancellationToken).ConfigureAwait(false); } return true; @@ -122,7 +122,7 @@ public async Task SendRawBufferAsync(byte[] buffer, TimeSpan waiTimeout, C { Debug.WriteLine("SendRawBufferAsync"); - return await App.SendBufferAsync(buffer, waiTimeout, cancellationToken); + return await App.SendBufferAsync(buffer, waiTimeout, cancellationToken).ConfigureAwait(false); } internal async Task ReadBufferAsync(byte[] buffer, int offset, int bytesToRead, TimeSpan waitTimeout, CancellationToken cancellationToken) @@ -148,7 +148,7 @@ internal async Task ReadBufferAsync(byte[] buffer, int offset, int bytesToR } // read next chunk of data async - var readResult = await App.ReadBufferAsync((uint)bytesToRead, waitTimeout, cancellationToken); + var readResult = await App.ReadBufferAsync((uint)bytesToRead, waitTimeout, cancellationToken).ConfigureAwait(false); Debug.WriteLine("read {0} bytes", readResult.Length); // any byte read? diff --git a/source/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Engine.cs b/source/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Engine.cs index 45532002..cac50de8 100644 --- a/source/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Engine.cs +++ b/source/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Engine.cs @@ -147,7 +147,7 @@ private void InitializeLocal(IPort pd, INanoDevice device) public bool IsConnectedTonanoCLR { - get { return ConnectionSource == ConnectionSource.NanoCLR; } + get { return ConnectionSource == ConnectionSource.nanoCLR; } } public bool IsTargetBigEndian { get; internal set; } @@ -157,7 +157,7 @@ public async ValueTask ConnectAsync(int retries, int timeout, bool force = if (force || IsConnected == false) { // connect to device - if (await Device.ConnectAsync()) + if (await Device.ConnectAsync().ConfigureAwait(false)) { Commands.Monitor_Ping cmd = new Commands.Monitor_Ping(); @@ -165,7 +165,7 @@ public async ValueTask ConnectAsync(int retries, int timeout, bool force = cmd.m_source = Commands.Monitor_Ping.c_Ping_Source_Host; //cmd.m_dbg_flags = (m_stopDebuggerOnConnect ? Commands.Monitor_Ping.c_Ping_DbgFlag_Stop : 0); - IncomingMessage msg = await PerformRequestAsync(Commands.c_Monitor_Ping, Flags.c_NoCaching, cmd, retries, timeout); + IncomingMessage msg = await PerformRequestAsync(Commands.c_Monitor_Ping, Flags.c_NoCaching, cmd, retries, timeout).ConfigureAwait(false); if (msg.Payload == null) { @@ -186,26 +186,26 @@ public async ValueTask ConnectAsync(int retries, int timeout, bool force = // update flag IsConnected = true; - ConnectionSource = (reply == null || reply.m_source == Commands.Monitor_Ping.c_Ping_Source_NanoCLR) ? ConnectionSource.NanoCLR : ConnectionSource.NanoBooter; + ConnectionSource = (reply == null || reply.m_source == Commands.Monitor_Ping.c_Ping_Source_NanoCLR) ? ConnectionSource.nanoCLR : ConnectionSource.nanoBooter; if (m_silent) { - await SetExecutionModeAsync(Commands.Debugging_Execution_ChangeConditions.c_fDebugger_Quiet, 0); + await SetExecutionModeAsync(Commands.Debugging_Execution_ChangeConditions.c_fDebugger_Quiet, 0).ConfigureAwait(false); } // resume execution for older clients, since server tools no longer do this. if (!m_stopDebuggerOnConnect && (msg != null && msg.Payload == null)) { - await ResumeExecutionAsync(); + await ResumeExecutionAsync().ConfigureAwait(false); } } } - if ((force || Capabilities.IsUnknown) && ConnectionSource == ConnectionSource.NanoCLR) + if ((force || Capabilities.IsUnknown) && ConnectionSource == ConnectionSource.nanoCLR) { CancellationTokenSource cancellationTSource = new CancellationTokenSource(); - Capabilities = await DiscoverCLRCapabilitiesAsync(cancellationTSource.Token); + Capabilities = await DiscoverCLRCapabilitiesAsync(cancellationTSource.Token).ConfigureAwait(false); m_ctrl.Capabilities = Capabilities; } @@ -301,7 +301,7 @@ public void Dispose() private async Task PerformRequestAsync(uint command, uint flags, object payload, int retries = 0, int timeout = 2000) { - await semaphore.WaitAsync(); + await semaphore.WaitAsync().ConfigureAwait(false); //// check for cancelation request //if (cancellationToken.IsCancellationRequested) @@ -323,7 +323,7 @@ private async Task PerformRequestAsync(uint command, uint flags // create request Request request = new Request(m_ctrl, message, retries, timeout, null); - return await request.PerformRequestAsync(); + return await request.PerformRequestAsync().ConfigureAwait(false); } finally { @@ -333,7 +333,7 @@ private async Task PerformRequestAsync(uint command, uint flags private async Task PerformRequestAsync(OutgoingMessage message, CancellationToken cancellationToken, int retries = 3, int timeout = 500) { - await semaphore.WaitAsync(); + await semaphore.WaitAsync().ConfigureAwait(false); try { @@ -341,7 +341,7 @@ private async Task PerformRequestAsync(OutgoingMessage message, // create request Request request = new Request(m_ctrl, message, retries, timeout, null); - return await request.PerformRequestAsync(); + return await request.PerformRequestAsync().ConfigureAwait(false); } finally { @@ -356,10 +356,10 @@ private async Task> PerformRequestBatchAsync(List> PerformRequestBatchAsync(List SendBufferAsync(byte[] buffer, TimeSpan waiTimeout, CancellationToken cancellationToken) { - return await m_portDefinition.SendBufferAsync(buffer, waiTimeout, cancellationToken); + return await m_portDefinition.SendBufferAsync(buffer, waiTimeout, cancellationToken).ConfigureAwait(false); } public bool ProcessMessage(IncomingMessage msg, bool fReply) @@ -414,7 +414,7 @@ public void ProcessExited() public async Task ReadBufferAsync(uint bytesToRead, TimeSpan waitTimeout, CancellationToken cancellationToken) { - return await m_portDefinition.ReadBufferAsync(bytesToRead, waitTimeout, cancellationToken); + return await m_portDefinition.ReadBufferAsync(bytesToRead, waitTimeout, cancellationToken).ConfigureAwait(false); } private OutgoingMessage CreateMessage(uint cmd, uint flags, object payload) @@ -429,7 +429,7 @@ private OutgoingMessage CreateMessage(uint cmd, uint flags, object payload) { Commands.Monitor_MemoryMap cmd = new Commands.Monitor_MemoryMap(); - IncomingMessage reply = await PerformRequestAsync(Commands.c_Monitor_MemoryMap, 0, cmd); + IncomingMessage reply = await PerformRequestAsync(Commands.c_Monitor_MemoryMap, 0, cmd).ConfigureAwait(false); if (reply != null) { @@ -451,7 +451,7 @@ private OutgoingMessage CreateMessage(uint cmd, uint flags, object payload) // TODO replace with token argument CancellationTokenSource cancelTSource = new CancellationTokenSource(); - IncomingMessage reply = await PerformRequestAsync(Commands.c_Monitor_DeploymentMap, 0, cmd, 2, 10000); + IncomingMessage reply = await PerformRequestAsync(Commands.c_Monitor_DeploymentMap, 0, cmd, 2, 10000).ConfigureAwait(false); if (reply != null) { @@ -471,7 +471,7 @@ private OutgoingMessage CreateMessage(uint cmd, uint flags, object payload) // TODO replace with token argument CancellationTokenSource cancelTSource = new CancellationTokenSource(); - IncomingMessage reply = await PerformRequestAsync(Commands.c_Monitor_OemInfo, 0, null, 2, 1000); + IncomingMessage reply = await PerformRequestAsync(Commands.c_Monitor_OemInfo, 0, null, 2, 1000).ConfigureAwait(false); if (reply != null) { @@ -486,7 +486,7 @@ private OutgoingMessage CreateMessage(uint cmd, uint flags, object payload) // TODO replace with token argument CancellationTokenSource cancelTSource = new CancellationTokenSource(); - IncomingMessage reply = await PerformRequestAsync(Commands.c_Monitor_FlashSectorMap, 0, null, 1, 4000); + IncomingMessage reply = await PerformRequestAsync(Commands.c_Monitor_FlashSectorMap, 0, null, 1, 4000).ConfigureAwait(false); if (reply != null) { @@ -512,7 +512,7 @@ private OutgoingMessage CreateMessage(uint cmd, uint flags, object payload) cmd.m_address = address; cmd.m_length = length; - IncomingMessage reply = await PerformRequestAsync(Commands.c_Monitor_ReadMemory, 0, cmd); + IncomingMessage reply = await PerformRequestAsync(Commands.c_Monitor_ReadMemory, 0, cmd).ConfigureAwait(false); if (reply == null) { return (new byte[0], false); @@ -539,7 +539,7 @@ private OutgoingMessage CreateMessage(uint cmd, uint flags, object payload) public async Task<(byte[] buffer, bool success)> ReadMemoryAsync(uint address, uint length) { - return await ReadMemoryAsync(address, length, 0); + return await ReadMemoryAsync(address, length, 0).ConfigureAwait(false); } public async Task<(uint errorCode, bool success)> WriteMemoryAsync(uint address, byte[] buf, int offset, int length) @@ -570,7 +570,7 @@ private OutgoingMessage CreateMessage(uint cmd, uint flags, object payload) Debug.WriteLine($"Sending {packetLength} bytes to address { address.ToString("X8") }, {count} remaining..."); - IncomingMessage reply = await PerformRequestAsync(Commands.c_Monitor_WriteMemory, 0, cmd, 0, 2000); + IncomingMessage reply = await PerformRequestAsync(Commands.c_Monitor_WriteMemory, 0, cmd, 0, 2000).ConfigureAwait(false); Commands.Monitor_WriteMemory.Reply cmdReply = reply.Payload as Commands.Monitor_WriteMemory.Reply; @@ -589,7 +589,7 @@ private OutgoingMessage CreateMessage(uint cmd, uint flags, object payload) public async Task<(uint errorCode, bool success)> WriteMemoryAsync(uint address, byte[] buf) { - return await WriteMemoryAsync(address, buf, 0, buf.Length); + return await WriteMemoryAsync(address, buf, 0, buf.Length).ConfigureAwait(false); } public async Task<(uint errorCode, bool success)> EraseMemoryAsync(uint address, uint length) @@ -645,7 +645,7 @@ private OutgoingMessage CreateMessage(uint cmd, uint flags, object payload) timeout = (int)(length / (16 * 1024)) * eraseTimeout16kSector + 2 * extraTimeoutForErase; } - IncomingMessage reply = await PerformRequestAsync(Commands.c_Monitor_EraseMemory, 0, cmd, 0, timeout); + IncomingMessage reply = await PerformRequestAsync(Commands.c_Monitor_EraseMemory, 0, cmd, 0, timeout).ConfigureAwait(false); Commands.Monitor_EraseMemory.Reply cmdReply = reply.Payload as Commands.Monitor_EraseMemory.Reply; @@ -658,7 +658,7 @@ public async Task ExecuteMemoryAsync(uint address) cmd.m_address = address; - IncomingMessage reply = await PerformRequestAsync(Commands.c_Monitor_Execute, 0, cmd); + IncomingMessage reply = await PerformRequestAsync(Commands.c_Monitor_Execute, 0, cmd).ConfigureAwait(false); return IncomingMessage.IsPositiveAcknowledge(reply); } @@ -694,7 +694,7 @@ public async Task RebootDeviceAsync(RebootOption option = RebootOption.NormalReb { m_evtPing.Reset(); - await PerformRequestAsync(Commands.c_Monitor_Reboot, Flags.c_NoCaching, cmd, 0, 100); + await PerformRequestAsync(Commands.c_Monitor_Reboot, Flags.c_NoCaching, cmd, 0, 100).ConfigureAwait(false); // need to disconnect from the device? if (disconnectRequired) @@ -710,7 +710,7 @@ public async Task RebootDeviceAsync(RebootOption option = RebootOption.NormalReb public async Task ReconnectAsync(bool fSoftReboot) { - if (!await ConnectAsync(m_RebootTime.Retries, m_RebootTime.WaitMs(fSoftReboot), true, ConnectionSource.Unknown)) + if (!await ConnectAsync(m_RebootTime.Retries, m_RebootTime.WaitMs(fSoftReboot), true, ConnectionSource.Unknown).ConfigureAwait(false)) { if (m_fThrowOnCommunicationFailure) { @@ -724,7 +724,7 @@ public async Task ReconnectAsync(bool fSoftReboot) public async Task GetExecutionBasePtrAsync() { - IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_Execution_BasePtr, 0, null); + IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_Execution_BasePtr, 0, null).ConfigureAwait(false); if (reply != null) { Commands.Debugging_Execution_BasePtr.Reply cmdReply = reply.Payload as Commands.Debugging_Execution_BasePtr.Reply; @@ -745,7 +745,7 @@ public async Task GetExecutionBasePtrAsync() cmd.m_set = iSet; cmd.m_reset = iReset; - IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_Execution_ChangeConditions, Flags.c_NoCaching, cmd); + IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_Execution_ChangeConditions, Flags.c_NoCaching, cmd).ConfigureAwait(false); if (reply != null) { Commands.Debugging_Execution_ChangeConditions.Reply cmdReply = reply.Payload as Commands.Debugging_Execution_ChangeConditions.Reply; @@ -765,14 +765,14 @@ public async Task GetExecutionBasePtrAsync() public async Task PauseExecutionAsync() { - var ret = await SetExecutionModeAsync(Commands.Debugging_Execution_ChangeConditions.c_Stopped, 0); + var ret = await SetExecutionModeAsync(Commands.Debugging_Execution_ChangeConditions.c_Stopped, 0).ConfigureAwait(false); return ret.Item2; } public async Task ResumeExecutionAsync() { - var ret = await SetExecutionModeAsync(0, Commands.Debugging_Execution_ChangeConditions.c_Stopped); + var ret = await SetExecutionModeAsync(0, Commands.Debugging_Execution_ChangeConditions.c_Stopped).ConfigureAwait(false); return ret.Item2; } @@ -783,7 +783,7 @@ public async Task SetCurrentAppDomainAsync(uint id) cmd.m_id = id; - return IncomingMessage.IsPositiveAcknowledge(await PerformRequestAsync(Commands.c_Debugging_Execution_SetCurrentAppDomain, 0, cmd)); + return IncomingMessage.IsPositiveAcknowledge(await PerformRequestAsync(Commands.c_Debugging_Execution_SetCurrentAppDomain, 0, cmd).ConfigureAwait(false)); } public async Task SetBreakpointsAsync(Commands.Debugging_Execution_BreakpointDef[] breakpoints) @@ -792,14 +792,14 @@ public async Task SetBreakpointsAsync(Commands.Debugging_Execution_Breakpo cmd.m_data = breakpoints; - return IncomingMessage.IsPositiveAcknowledge(await PerformRequestAsync(Commands.c_Debugging_Execution_Breakpoints, 0, cmd)); + return IncomingMessage.IsPositiveAcknowledge(await PerformRequestAsync(Commands.c_Debugging_Execution_Breakpoints, 0, cmd).ConfigureAwait(false)); } public async Task GetBreakpointStatusAsync() { Commands.Debugging_Execution_BreakpointStatus cmd = new Commands.Debugging_Execution_BreakpointStatus(); - IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_Execution_BreakpointStatus, 0, cmd); + IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_Execution_BreakpointStatus, 0, cmd).ConfigureAwait(false); if (reply != null) { @@ -818,7 +818,7 @@ public async Task SetSecurityKeyAsync(byte[] key) cmd.m_key = key; - return await PerformRequestAsync(Commands.c_Debugging_Execution_SecurityKey, 0, cmd) != null; + return await PerformRequestAsync(Commands.c_Debugging_Execution_SecurityKey, 0, cmd).ConfigureAwait(false) != null; } public async Task UnlockDeviceAsync(byte[] blob) @@ -828,7 +828,7 @@ public async Task UnlockDeviceAsync(byte[] blob) Array.Copy(blob, 0, cmd.m_command, 0, 128); Array.Copy(blob, 128, cmd.m_hash, 0, 128); - return IncomingMessage.IsPositiveAcknowledge(await PerformRequestAsync(Commands.c_Debugging_Execution_Unlock, 0, cmd)); + return IncomingMessage.IsPositiveAcknowledge(await PerformRequestAsync(Commands.c_Debugging_Execution_Unlock, 0, cmd).ConfigureAwait(false)); } public async Task<(uint address, bool success)> AllocateMemoryAsync(uint size) @@ -837,7 +837,7 @@ public async Task UnlockDeviceAsync(byte[] blob) cmd.m_size = size; - IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_Execution_Allocate, 0, cmd); + IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_Execution_Allocate, 0, cmd).ConfigureAwait(false); if (reply != null) { Commands.Debugging_Execution_Allocate.Reply cmdReply = reply.Payload as Commands.Debugging_Execution_Allocate.Reply; @@ -904,7 +904,7 @@ public async Task CanUpgradeToSslAsync() cmd.m_flags = 0; - IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_UpgradeToSsl, Flags.c_NoCaching, cmd, 2, 5000); + IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_UpgradeToSsl, Flags.c_NoCaching, cmd, 2, 5000).ConfigureAwait(false); if (reply != null) { @@ -963,7 +963,7 @@ public async Task StartUpdateAsync( // TODO replace with token argument CancellationTokenSource cancelTSource = new CancellationTokenSource(); - IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_MFUpdate_Start, Flags.c_NoCaching, cmd, 2, 5000); + IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_MFUpdate_Start, Flags.c_NoCaching, cmd, 2, 5000).ConfigureAwait(false); if (reply != null) { @@ -992,7 +992,7 @@ public async Task StartUpdateAsync( cmd.m_authArgs = commandArgs; cmd.m_authArgsSize = (uint)commandArgs.Length; - IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_MFUpdate_AuthCmd, Flags.c_NoCaching, cmd); + IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_MFUpdate_AuthCmd, Flags.c_NoCaching, cmd).ConfigureAwait(false); if (reply != null) { @@ -1020,7 +1020,7 @@ public async Task UpdateAuthenticateAsync(int updateHandle, byte[] authent cmd.m_updateHandle = updateHandle; cmd.PrepareForSend(authenticationData); - IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_MFUpdate_Authenticate, Flags.c_NoCaching, cmd); + IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_MFUpdate_Authenticate, Flags.c_NoCaching, cmd).ConfigureAwait(false); if (reply != null) { @@ -1041,7 +1041,7 @@ private async Task UpdateGetMissingPacketsAsync(int updateHandle) cmd.m_updateHandle = updateHandle; - IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_MFUpdate_GetMissingPkts, Flags.c_NoCaching, cmd); + IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_MFUpdate_GetMissingPkts, Flags.c_NoCaching, cmd).ConfigureAwait(false); if (reply != null) { @@ -1068,7 +1068,7 @@ public async Task AddPacketAsync(int updateHandle, uint packetIndex, byte[ { if (!m_updateMissingPktTbl.ContainsKey(updateHandle)) { - await UpdateGetMissingPacketsAsync(updateHandle); + await UpdateGetMissingPacketsAsync(updateHandle).ConfigureAwait(false); } if (m_updateMissingPktTbl.ContainsKey(updateHandle) && m_updateMissingPktTbl[updateHandle].Length > 0) @@ -1092,7 +1092,7 @@ public async Task AddPacketAsync(int updateHandle, uint packetIndex, byte[ cmd.m_packetValidation = packetValidation; cmd.PrepareForSend(packetData); - IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_MFUpdate_AddPacket, Flags.c_NoCaching, cmd); + IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_MFUpdate_AddPacket, Flags.c_NoCaching, cmd).ConfigureAwait(false); if (reply != null) { Commands.Debugging_MFUpdate_AddPacket.Reply cmdReply = reply.Payload as Commands.Debugging_MFUpdate_AddPacket.Reply; @@ -1119,7 +1119,7 @@ public async Task InstallUpdateAsync(int updateHandle, byte[] validationDa cmd.PrepareForSend(validationData); - IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_MFUpdate_Install, Flags.c_NoCaching, cmd); + IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_MFUpdate_Install, Flags.c_NoCaching, cmd).ConfigureAwait(false); if (reply != null) { @@ -1136,7 +1136,7 @@ public async Task InstallUpdateAsync(int updateHandle, byte[] validationDa public async Task CreateThreadAsync(uint methodIndex, int scratchPadLocation) { - return await CreateThreadAsync(methodIndex, scratchPadLocation, 0); + return await CreateThreadAsync(methodIndex, scratchPadLocation, 0).ConfigureAwait(false); } public async Task CreateThreadAsync(uint methodIndex, int scratchPadLocation, uint pid) @@ -1149,7 +1149,7 @@ public async Task CreateThreadAsync(uint methodIndex, int scratchPadLocati cmd.m_scratchPad = scratchPadLocation; cmd.m_pid = pid; - IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_Thread_CreateEx, 0, cmd); + IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_Thread_CreateEx, 0, cmd).ConfigureAwait(false); if (reply != null) { @@ -1164,7 +1164,7 @@ public async Task CreateThreadAsync(uint methodIndex, int scratchPadLocati public async Task GetThreadListAsync() { - IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_Thread_List, 0, null); + IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_Thread_List, 0, null).ConfigureAwait(false); if (reply != null) { @@ -1185,7 +1185,7 @@ public async Task GetThreadListAsync() cmd.m_pid = pid; - IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_Thread_Stack, 0, cmd); + IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_Thread_Stack, 0, cmd).ConfigureAwait(false); if (reply != null) { @@ -1201,7 +1201,7 @@ public async Task KillThreadAsync(uint pid) cmd.m_pid = pid; - IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_Thread_Kill, 0, cmd); + IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_Thread_Kill, 0, cmd).ConfigureAwait(false); if (reply != null) { @@ -1219,7 +1219,7 @@ public async Task SuspendThreadAsync(uint pid) cmd.m_pid = pid; - return IncomingMessage.IsPositiveAcknowledge(await PerformRequestAsync(Commands.c_Debugging_Thread_Suspend, 0, cmd)); + return IncomingMessage.IsPositiveAcknowledge(await PerformRequestAsync(Commands.c_Debugging_Thread_Suspend, 0, cmd).ConfigureAwait(false)); } public async Task ResumeThreadAsync(uint pid) @@ -1228,7 +1228,7 @@ public async Task ResumeThreadAsync(uint pid) cmd.m_pid = pid; - return IncomingMessage.IsPositiveAcknowledge(await PerformRequestAsync(Commands.c_Debugging_Thread_Resume, 0, cmd)); + return IncomingMessage.IsPositiveAcknowledge(await PerformRequestAsync(Commands.c_Debugging_Thread_Resume, 0, cmd).ConfigureAwait(false)); } public Task GetThreadExceptionAsync(uint pid) @@ -1256,7 +1256,7 @@ public async Task UnwindThreadAsync(uint pid, uint depth) cmd.m_pid = pid; cmd.m_depth = depth; - return IncomingMessage.IsPositiveAcknowledge(await PerformRequestAsync(Commands.c_Debugging_Thread_Unwind, 0, cmd)); + return IncomingMessage.IsPositiveAcknowledge(await PerformRequestAsync(Commands.c_Debugging_Thread_Unwind, 0, cmd).ConfigureAwait(false)); } public async Task SetIPOfStackFrameAsync(uint pid, uint depth, uint IP, uint depthOfEvalStack) @@ -1269,7 +1269,7 @@ public async Task SetIPOfStackFrameAsync(uint pid, uint depth, uint IP, ui cmd.m_IP = IP; cmd.m_depthOfEvalStack = depthOfEvalStack; - return IncomingMessage.IsPositiveAcknowledge(await PerformRequestAsync(Commands.c_Debugging_Stack_SetIP, 0, cmd)); + return IncomingMessage.IsPositiveAcknowledge(await PerformRequestAsync(Commands.c_Debugging_Stack_SetIP, 0, cmd).ConfigureAwait(false)); } public async Task GetStackInfoAsync(uint pid, uint depth) @@ -1279,7 +1279,7 @@ public async Task SetIPOfStackFrameAsync(uint pid, uint depth, uint IP, ui cmd.m_pid = pid; cmd.m_depth = depth; - IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_Stack_Info, 0, cmd); + IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_Stack_Info, 0, cmd).ConfigureAwait(false); if (reply != null) { @@ -1298,7 +1298,7 @@ public async Task SetIPOfStackFrameAsync(uint pid, uint depth, uint IP, ui Commands.Debugging_TypeSys_AppDomains cmd = new Commands.Debugging_TypeSys_AppDomains(); - IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_TypeSys_AppDomains, 0, cmd); + IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_TypeSys_AppDomains, 0, cmd).ConfigureAwait(false); if (reply != null) { @@ -1312,7 +1312,7 @@ public async Task SetIPOfStackFrameAsync(uint pid, uint depth, uint IP, ui { Commands.Debugging_TypeSys_Assemblies cmd = new Commands.Debugging_TypeSys_Assemblies(); - IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_TypeSys_Assemblies, 0, cmd); + IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_TypeSys_Assemblies, 0, cmd).ConfigureAwait(false); if (reply != null) { @@ -1324,7 +1324,7 @@ public async Task SetIPOfStackFrameAsync(uint pid, uint depth, uint IP, ui public async Task> ResolveAllAssembliesAsync(CancellationToken cancellationToken) { - Commands.Debugging_TypeSys_Assemblies.Reply assemblies = await GetAssembliesAsync(cancellationToken); + Commands.Debugging_TypeSys_Assemblies.Reply assemblies = await GetAssembliesAsync(cancellationToken).ConfigureAwait(false); List resolveAssemblies = new List(); if (assemblies == null || assemblies.Data == null) @@ -1345,7 +1345,7 @@ public async Task SetIPOfStackFrameAsync(uint pid, uint depth, uint IP, ui requests.Add(CreateMessage(Commands.c_Debugging_Resolve_Assembly, 0, cmd)); } - List replies = await PerformRequestBatchAsync(requests, cancellationToken); + List replies = await PerformRequestBatchAsync(requests, cancellationToken).ConfigureAwait(false); foreach (IncomingMessage message in replies) { @@ -1364,7 +1364,7 @@ public async Task SetIPOfStackFrameAsync(uint pid, uint depth, uint IP, ui cmd.Idx = idx; - IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_Resolve_Assembly, 0, cmd); + IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_Resolve_Assembly, 0, cmd).ConfigureAwait(false); if (reply != null) { @@ -1389,7 +1389,7 @@ public enum StackValueKind /// Tuple with numOfArguments, numOfLocals, depthOfEvalStack and request success result. public async Task<(uint numOfArguments, uint numOfLocals, uint depthOfEvalStack, bool success)> GetStackFrameInfoAsync(uint pid, uint depth) { - Commands.Debugging_Stack_Info.Reply reply = await GetStackInfoAsync(pid, depth); + Commands.Debugging_Stack_Info.Reply reply = await GetStackInfoAsync(pid, depth).ConfigureAwait(false); if (reply == null) { @@ -1401,7 +1401,7 @@ public enum StackValueKind private async Task GetRuntimeValueAsync(uint msg, object cmd) { - IncomingMessage reply = await PerformRequestAsync(msg, 0, cmd); + IncomingMessage reply = await PerformRequestAsync(msg, 0, cmd).ConfigureAwait(false); if (reply != null && reply.Payload != null) { @@ -1421,12 +1421,12 @@ internal async Task GetFieldValueAsync(RuntimeValue val, uint offs cmd.m_offset = offset; cmd.m_fd = fd; - return await GetRuntimeValueAsync(Commands.c_Debugging_Value_GetField, cmd); + return await GetRuntimeValueAsync(Commands.c_Debugging_Value_GetField, cmd).ConfigureAwait(false); } public async Task GetStaticFieldValueAsync(uint fd) { - return await GetFieldValueAsync(null, 0, fd); + return await GetFieldValueAsync(null, 0, fd).ConfigureAwait(false); } internal async Task AssignRuntimeValueAsync(uint heapblockSrc, uint heapblockDst) @@ -1436,7 +1436,7 @@ internal async Task AssignRuntimeValueAsync(uint heapblockSrc, uin cmd.m_heapblockSrc = heapblockSrc; cmd.m_heapblockDst = heapblockDst; - return await GetRuntimeValueAsync(Commands.c_Debugging_Value_Assign, cmd); + return await GetRuntimeValueAsync(Commands.c_Debugging_Value_Assign, cmd).ConfigureAwait(false); } internal async Task SetBlockAsync(uint heapblock, uint dt, byte[] data) @@ -1448,7 +1448,7 @@ internal async Task SetBlockAsync(uint heapblock, uint dt, byte[] data) data.CopyTo(setBlock.m_value, 0); - return IncomingMessage.IsPositiveAcknowledge(await PerformRequestAsync(Commands.c_Debugging_Value_SetBlock, 0, setBlock)); + return IncomingMessage.IsPositiveAcknowledge(await PerformRequestAsync(Commands.c_Debugging_Value_SetBlock, 0, setBlock).ConfigureAwait(false)); } private OutgoingMessage CreateMessage_GetValue_Stack(uint pid, uint depth, StackValueKind kind, uint index) @@ -1469,14 +1469,14 @@ public async Task ResizeScratchPadAsync(int size) cmd.m_size = size; - return IncomingMessage.IsPositiveAcknowledge(await PerformRequestAsync(Commands.c_Debugging_Value_ResizeScratchPad, 0, cmd)); + return IncomingMessage.IsPositiveAcknowledge(await PerformRequestAsync(Commands.c_Debugging_Value_ResizeScratchPad, 0, cmd).ConfigureAwait(false)); } public async Task GetStackFrameValueAsync(uint pid, uint depth, StackValueKind kind, uint index, CancellationToken cancellationToken) { OutgoingMessage cmd = CreateMessage_GetValue_Stack(pid, depth, kind, index); - IncomingMessage reply = await PerformRequestAsync(cmd, cancellationToken, 10, 200); + IncomingMessage reply = await PerformRequestAsync(cmd, cancellationToken, 10, 200).ConfigureAwait(false); if (reply != null) { @@ -1499,7 +1499,7 @@ public async Task GetStackFrameValueAllAsync(uint pid, uint dept cmds.Add(CreateMessage_GetValue_Stack(pid, depth, kind, i)); } - List replies = await PerformRequestBatchAsync(cmds, cancellationToken); + List replies = await PerformRequestBatchAsync(cmds, cancellationToken).ConfigureAwait(false); if (replies != null) { @@ -1525,7 +1525,7 @@ public async Task GetArrayElementAsync(uint arrayReferenceId, uint cmd.m_heapblock = arrayReferenceId; cmd.m_index = index; - RuntimeValue rtv = await GetRuntimeValueAsync(Commands.c_Debugging_Value_GetArray, cmd); + RuntimeValue rtv = await GetRuntimeValueAsync(Commands.c_Debugging_Value_GetArray, cmd).ConfigureAwait(false); if (rtv != null) { @@ -1545,7 +1545,7 @@ internal async Task SetArrayElementAsync(uint heapblock, uint index, byte[ data.CopyTo(cmd.m_value, 0); - return IncomingMessage.IsPositiveAcknowledge(await PerformRequestAsync(Commands.c_Debugging_Value_SetArray, 0, cmd)); + return IncomingMessage.IsPositiveAcknowledge(await PerformRequestAsync(Commands.c_Debugging_Value_SetArray, 0, cmd).ConfigureAwait(false)); } public Task GetScratchPadValueAsync(int index) @@ -1574,11 +1574,11 @@ public async Task AllocateStringAsync(int scratchPadLocation, stri cmd.m_index = scratchPadLocation; cmd.m_size = (uint)Encoding.UTF8.GetByteCount(val); - RuntimeValue rtv = await GetRuntimeValueAsync(Commands.c_Debugging_Value_AllocateString, cmd); + RuntimeValue rtv = await GetRuntimeValueAsync(Commands.c_Debugging_Value_AllocateString, cmd).ConfigureAwait(false); if (rtv != null) { - await rtv.SetStringValueAsync(val); + await rtv.SetStringValueAsync(val).ConfigureAwait(false); } return rtv; @@ -1606,7 +1606,7 @@ public Task AllocateArrayAsync(int scratchPadLocation, uint td, in cmd.m_td = td; - IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_Resolve_Type, 0, cmd); + IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_Resolve_Type, 0, cmd).ConfigureAwait(false); if (reply != null) { @@ -1636,7 +1636,7 @@ public Task AllocateArrayAsync(int scratchPadLocation, uint td, in cmd.m_md = md; - IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_Resolve_Method, 0, cmd); + IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_Resolve_Method, 0, cmd).ConfigureAwait(false); if (reply != null) { @@ -1667,7 +1667,7 @@ public Task AllocateArrayAsync(int scratchPadLocation, uint td, in cmd.m_fd = fd; - IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_Resolve_Field, 0, cmd); + IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_Resolve_Field, 0, cmd).ConfigureAwait(false); if (reply != null) { Commands.Debugging_Resolve_Field.Reply cmdReply = reply.Payload as Commands.Debugging_Resolve_Field.Reply; @@ -1697,7 +1697,7 @@ public Task AllocateArrayAsync(int scratchPadLocation, uint td, in cmd.m_id = appDomainID; - IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_Resolve_AppDomain, 0, cmd); + IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_Resolve_AppDomain, 0, cmd).ConfigureAwait(false); if (reply != null) { @@ -1709,21 +1709,21 @@ public Task AllocateArrayAsync(int scratchPadLocation, uint td, in public async Task GetTypeNameAsync(uint td) { - Commands.Debugging_Resolve_Type.Result resolvedType = await ResolveTypeAsync(td); + Commands.Debugging_Resolve_Type.Result resolvedType = await ResolveTypeAsync(td).ConfigureAwait(false); return (resolvedType != null) ? resolvedType.m_name : null; } public async Task GetMethodNameAsync(uint md, bool fIncludeType) { - Commands.Debugging_Resolve_Method.Result resolvedMethod = await ResolveMethodAsync(md); + Commands.Debugging_Resolve_Method.Result resolvedMethod = await ResolveMethodAsync(md).ConfigureAwait(false); string name = null; if (resolvedMethod != null) { if (fIncludeType) { - name = string.Format("{0}::{1}", await GetTypeNameAsync(resolvedMethod.m_td), resolvedMethod.m_name); + name = string.Format("{0}::{1}", await GetTypeNameAsync(resolvedMethod.m_td).ConfigureAwait(false), resolvedMethod.m_name); } else { @@ -1741,7 +1741,7 @@ public async Task GetMethodNameAsync(uint md, bool fIncludeType) /// Tuple with field name, td and offset. public async Task<(string td, uint offset, uint success)> GetFieldNameAsync(uint fd) { - Commands.Debugging_Resolve_Field.Result resolvedField = await ResolveFieldAsync(fd); + Commands.Debugging_Resolve_Field.Result resolvedField = await ResolveFieldAsync(fd).ConfigureAwait(false); if (resolvedField != null) { @@ -1758,7 +1758,7 @@ public async Task GetVirtualMethodAsync(uint md, RuntimeValue obj) cmd.m_md = md; cmd.m_obj = obj.ReferenceId; - IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_Resolve_VirtualMethod, 0, cmd); + IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_Resolve_VirtualMethod, 0, cmd).ConfigureAwait(false); if (reply != null) { @@ -1779,7 +1779,7 @@ public async Task GetVirtualMethodAsync(uint md, RuntimeValue obj) /// Tuple with widthInWords, heightInPixels, buffer and request result success. public async Task<(ushort widthInWords, ushort heightInPixels, uint[] buf, bool success)> GetFrameBufferAsync() { - IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_Lcd_GetFrame, 0, null); + IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_Lcd_GetFrame, 0, null).ConfigureAwait(false); if (reply != null) { Commands.Debugging_Lcd_GetFrame.Reply cmdReply = reply.Payload as Commands.Debugging_Lcd_GetFrame.Reply; @@ -1964,13 +1964,13 @@ public Task InjectButtonsAsync(uint pressed, uint released) public async Task> GetThreadsAsync() { List threads = new List(); - uint[] pids = await GetThreadListAsync(); + uint[] pids = await GetThreadListAsync().ConfigureAwait(false); if (pids != null) { for (int i = 0; i < pids.Length; i++) { - Commands.Debugging_Thread_Stack.Reply reply = await GetThreadStackAsync(pids[i]); + Commands.Debugging_Thread_Stack.Reply reply = await GetThreadStackAsync(pids[i]).ConfigureAwait(false); if (reply != null) { @@ -1984,7 +1984,7 @@ public async Task> GetThreadsAsync() for (int j = 0; j < depth; j++) { - ts.m_calls[depth - 1 - j] = String.Format("{0} [IP:{1:X4}]", await GetMethodNameAsync(reply.m_data[j].m_md, true), reply.m_data[j].m_IP); + ts.m_calls[depth - 1 - j] = String.Format("{0} [IP:{1:X4}]", await GetMethodNameAsync(reply.m_data[j].m_md, true).ConfigureAwait(false), reply.m_data[j].m_IP); } threads.Add(ts); @@ -2006,7 +2006,7 @@ public async Task> GetThreadsAsync() /// Tuple with entrypoint, storageStart, storageLength and request success public async Task<(uint entrypoint, uint storageStart, uint storageLength, bool success)> DeploymentGetStatusWithResultAsync() { - Commands.DebuggingDeploymentStatus.Reply status = await DeploymentGetStatusAsync(); + Commands.DebuggingDeploymentStatus.Reply status = await DeploymentGetStatusAsync().ConfigureAwait(false); if (status != null) { @@ -2026,7 +2026,7 @@ public async Task> GetThreadsAsync() Commands.DebuggingDeploymentStatus cmd = new Commands.DebuggingDeploymentStatus(); Commands.DebuggingDeploymentStatus.Reply cmdReply = null; - IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_Deployment_Status, Flags.c_NoCaching, cmd, 2, 10000); + IncomingMessage reply = await PerformRequestAsync(Commands.c_Debugging_Deployment_Status, Flags.c_NoCaching, cmd, 2, 10000).ConfigureAwait(false); if (reply != null) { @@ -2044,13 +2044,13 @@ public async Task Info_SetJMCAsync(bool fJMC, ReflectionDefinition.Kind ki cmd.m_kind = (uint)kind; cmd.m_raw = index; - return IncomingMessage.IsPositiveAcknowledge(await PerformRequestAsync(Commands.c_Debugging_Info_SetJMC, 0, cmd)); + return IncomingMessage.IsPositiveAcknowledge(await PerformRequestAsync(Commands.c_Debugging_Info_SetJMC, 0, cmd).ConfigureAwait(false)); } private async Task DeploymentExecuteIncrementalAsync(List assemblies, IProgress progress) { // get flash sector map from device - var flashSectorMap = await GetFlashSectorMapAsync(); + var flashSectorMap = await GetFlashSectorMapAsync().ConfigureAwait(false); // check if we do have the map if (flashSectorMap != null) @@ -2115,7 +2115,7 @@ private async Task DeploymentExecuteIncrementalAsync(List assembli foreach (DeploymentBlock block in blocksToDeploy) { - var eraseResult = await EraseMemoryAsync((uint)block.StartAddress, 1); + var eraseResult = await EraseMemoryAsync((uint)block.StartAddress, 1).ConfigureAwait(false); if (!eraseResult.success) { progress?.Report(($"FAILED to erase device memory @0x{block.StartAddress.ToString("X8")} with Length=0x{block.Size.ToString("X8")}")); @@ -2123,7 +2123,7 @@ private async Task DeploymentExecuteIncrementalAsync(List assembli return false; } - var writeResult = await WriteMemoryAsync((uint)block.StartAddress, block.DeploymentData); + var writeResult = await WriteMemoryAsync((uint)block.StartAddress, block.DeploymentData).ConfigureAwait(false); if (!writeResult.success) { progress?.Report(($"FAILED to write device memory @0x{block.StartAddress.ToString("X8")} with Length={block.Size.ToString("X8")}")); @@ -2151,7 +2151,7 @@ private async Task DeploymentExecuteFullAsync(List assemblies, IPr byte[] closeHeader = new byte[8]; // perform request - var reply = await DeploymentGetStatusWithResultAsync(); + var reply = await DeploymentGetStatusWithResultAsync().ConfigureAwait(false); // check if request was successfully executed if (!reply.success) @@ -2181,7 +2181,7 @@ private async Task DeploymentExecuteFullAsync(List assemblies, IPr return false; } - var eraseResult = await EraseMemoryAsync(storageStart, deployLength); + var eraseResult = await EraseMemoryAsync(storageStart, deployLength).ConfigureAwait(false); if (!eraseResult.success) { @@ -2198,7 +2198,7 @@ private async Task DeploymentExecuteFullAsync(List assemblies, IPr return false; } - var writeResult1 = await WriteMemoryAsync(storageStart, assembly); + var writeResult1 = await WriteMemoryAsync(storageStart, assembly).ConfigureAwait(false); if (!writeResult1.success) { @@ -2208,7 +2208,7 @@ private async Task DeploymentExecuteFullAsync(List assemblies, IPr storageStart += (uint)assembly.Length; } - var writeResult2 = await WriteMemoryAsync(storageStart, closeHeader); + var writeResult2 = await WriteMemoryAsync(storageStart, closeHeader).ConfigureAwait(false); if (!writeResult2.success) { return false; @@ -2226,7 +2226,7 @@ public async Task DeploymentExecuteAsync(List assemblies, bool fRe { bool fDeployedOK = false; - if (!await PauseExecutionAsync()) + if (!await PauseExecutionAsync().ConfigureAwait(false)) { return false; } @@ -2235,7 +2235,7 @@ public async Task DeploymentExecuteAsync(List assemblies, bool fRe { progress?.Report("Incrementally deploying assemblies to device"); - fDeployedOK = await DeploymentExecuteIncrementalAsync(assemblies, progress); + fDeployedOK = await DeploymentExecuteIncrementalAsync(assemblies, progress).ConfigureAwait(false); } else { @@ -2258,7 +2258,7 @@ public async Task DeploymentExecuteAsync(List assemblies, bool fRe progress?.Report("Rebooting device..."); - await RebootDeviceAsync(RebootOption.RebootClrOnly); + await RebootDeviceAsync(RebootOption.RebootClrOnly).ConfigureAwait(false); } } @@ -2272,7 +2272,7 @@ public async Task DeploymentExecuteAsync(List assemblies, bool fRe cmd.m_parm1 = iSet; cmd.m_parm2 = iReset; - IncomingMessage reply = await PerformRequestAsync(Commands.c_Profiling_Command, 0, cmd); + IncomingMessage reply = await PerformRequestAsync(Commands.c_Profiling_Command, 0, cmd).ConfigureAwait(false); if (reply != null) { Commands.Profiling_Command.Reply cmdReply = reply.Payload as Commands.Profiling_Command.Reply; @@ -2294,7 +2294,7 @@ public async Task FlushProfilingStreamAsync() { Commands.Profiling_Command cmd = new Commands.Profiling_Command(); cmd.m_command = Commands.Profiling_Command.c_Command_FlushStream; - await PerformRequestAsync(Commands.c_Profiling_Command, 0, cmd); + await PerformRequestAsync(Commands.c_Profiling_Command, 0, cmd).ConfigureAwait(false); return true; } @@ -2307,14 +2307,14 @@ private async Task DiscoverCLRCapabilityAsync(uint caps) cmd.m_caps = caps; - return await PerformRequestAsync(Commands.c_Debugging_Execution_QueryCLRCapabilities, 0, cmd, 5, 1000); + return await PerformRequestAsync(Commands.c_Debugging_Execution_QueryCLRCapabilities, 0, cmd, 5, 1000).ConfigureAwait(false); } private async Task DiscoverCLRCapabilityUintAsync(uint caps) { uint ret = 0; - IncomingMessage reply = await DiscoverCLRCapabilityAsync(caps); + IncomingMessage reply = await DiscoverCLRCapabilityAsync(caps).ConfigureAwait(false); if (reply != null) { @@ -2339,14 +2339,14 @@ private async Task DiscoverCLRCapabilityUintAsync(uint caps) { Debug.WriteLine("DiscoverCLRCapability"); - return (CLRCapabilities.Capability)await DiscoverCLRCapabilityUintAsync(Commands.Debugging_Execution_QueryCLRCapabilities.c_CapabilityFlags); + return (CLRCapabilities.Capability)await DiscoverCLRCapabilityUintAsync(Commands.Debugging_Execution_QueryCLRCapabilities.c_CapabilityFlags).ConfigureAwait(false); } private async Task DiscoverSoftwareVersionPropertiesAsync() { Debug.WriteLine("DiscoverSoftwareVersionProperties"); - IncomingMessage reply = await DiscoverCLRCapabilityAsync(Commands.Debugging_Execution_QueryCLRCapabilities.c_CapabilitySoftwareVersion); + IncomingMessage reply = await DiscoverCLRCapabilityAsync(Commands.Debugging_Execution_QueryCLRCapabilities.c_CapabilitySoftwareVersion).ConfigureAwait(false); Commands.Debugging_Execution_QueryCLRCapabilities.SoftwareVersion ver = new Commands.Debugging_Execution_QueryCLRCapabilities.SoftwareVersion(); @@ -2371,7 +2371,7 @@ private async Task DiscoverCLRCapabilityUintAsync(uint caps) { Debug.WriteLine("DiscoverCLRCapabilityLCD"); - IncomingMessage reply = await DiscoverCLRCapabilityAsync(Commands.Debugging_Execution_QueryCLRCapabilities.c_CapabilityLCD); + IncomingMessage reply = await DiscoverCLRCapabilityAsync(Commands.Debugging_Execution_QueryCLRCapabilities.c_CapabilityLCD).ConfigureAwait(false); Commands.Debugging_Execution_QueryCLRCapabilities.LCD lcd = new Commands.Debugging_Execution_QueryCLRCapabilities.LCD(); @@ -2396,7 +2396,7 @@ private async Task DiscoverCLRCapabilityUintAsync(uint caps) { Debug.WriteLine("DiscoverHalSystemInfoProperties"); - IncomingMessage reply = await DiscoverCLRCapabilityAsync(Commands.Debugging_Execution_QueryCLRCapabilities.c_CapabilityHalSystemInfo); + IncomingMessage reply = await DiscoverCLRCapabilityAsync(Commands.Debugging_Execution_QueryCLRCapabilities.c_CapabilityHalSystemInfo).ConfigureAwait(false); Commands.Debugging_Execution_QueryCLRCapabilities.HalSystemInfo halSystemInfo = new Commands.Debugging_Execution_QueryCLRCapabilities.HalSystemInfo(); @@ -2425,7 +2425,7 @@ private async Task DiscoverCLRCapabilityUintAsync(uint caps) { Debug.WriteLine("DiscoverClrInfoProperties"); - IncomingMessage reply = await DiscoverCLRCapabilityAsync(Commands.Debugging_Execution_QueryCLRCapabilities.c_CapabilityClrInfo); + IncomingMessage reply = await DiscoverCLRCapabilityAsync(Commands.Debugging_Execution_QueryCLRCapabilities.c_CapabilityClrInfo).ConfigureAwait(false); Commands.Debugging_Execution_QueryCLRCapabilities.ClrInfo clrInfo = new Commands.Debugging_Execution_QueryCLRCapabilities.ClrInfo(); @@ -2451,7 +2451,7 @@ private async Task DiscoverCLRCapabilityUintAsync(uint caps) Debug.WriteLine("=============================="); Debug.WriteLine("DiscoverTargetInfoProperties"); - IncomingMessage reply = await DiscoverCLRCapabilityAsync(Commands.Debugging_Execution_QueryCLRCapabilities.c_CapabilitySolutionReleaseInfo); + IncomingMessage reply = await DiscoverCLRCapabilityAsync(Commands.Debugging_Execution_QueryCLRCapabilities.c_CapabilitySolutionReleaseInfo).ConfigureAwait(false); ReleaseInfo targetInfo = new ReleaseInfo(); @@ -2474,7 +2474,7 @@ private async Task DiscoverCLRCapabilityUintAsync(uint caps) private async Task DiscoverCLRCapabilitiesAsync(CancellationToken cancellationToken) { - var clrFlags = await DiscoverCLRCapabilityFlagsAsync(); + var clrFlags = await DiscoverCLRCapabilityFlagsAsync().ConfigureAwait(false); // check for cancelation request if (cancellationToken.IsCancellationRequested) { @@ -2483,7 +2483,7 @@ private async Task DiscoverCLRCapabilitiesAsync(CancellationTok return null; } - var clrLcd = await DiscoverCLRCapabilityLCDAsync(); + var clrLcd = await DiscoverCLRCapabilityLCDAsync().ConfigureAwait(false); // check for cancelation request if (cancellationToken.IsCancellationRequested) { @@ -2492,7 +2492,7 @@ private async Task DiscoverCLRCapabilitiesAsync(CancellationTok return null; } - var softwareVersion = await DiscoverSoftwareVersionPropertiesAsync(); + var softwareVersion = await DiscoverSoftwareVersionPropertiesAsync().ConfigureAwait(false); // check for cancelation request if (cancellationToken.IsCancellationRequested) { @@ -2501,7 +2501,7 @@ private async Task DiscoverCLRCapabilitiesAsync(CancellationTok return null; } - var halSysInfo = await DiscoverHalSystemInfoPropertiesAsync(); + var halSysInfo = await DiscoverHalSystemInfoPropertiesAsync().ConfigureAwait(false); // check for cancelation request if (cancellationToken.IsCancellationRequested) { @@ -2510,7 +2510,7 @@ private async Task DiscoverCLRCapabilitiesAsync(CancellationTok return null; } - var clrInfo = await DiscoverClrInfoPropertiesAsync(); + var clrInfo = await DiscoverClrInfoPropertiesAsync().ConfigureAwait(false); // check for cancelation request if (cancellationToken.IsCancellationRequested) { @@ -2519,7 +2519,7 @@ private async Task DiscoverCLRCapabilitiesAsync(CancellationTok return null; } - var solutionInfo = await DiscoverTargetInfoPropertiesAsync(); + var solutionInfo = await DiscoverTargetInfoPropertiesAsync().ConfigureAwait(false); // check for cancelation request if (cancellationToken.IsCancellationRequested) { diff --git a/source/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/IncomingMessage.cs b/source/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/IncomingMessage.cs index 7c5def28..588961cc 100644 --- a/source/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/IncomingMessage.cs +++ b/source/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/IncomingMessage.cs @@ -93,7 +93,7 @@ static public async Task ReplyBadPacketAsync(IController ctrl, uint flags, //What is this for? Nack + Ping? What can the nanoCLR possibly do with this information? OutgoingMessage msg = new OutgoingMessage(ctrl, new WireProtocol.Converter(), Commands.c_Monitor_Ping, Flags.c_NonCritical | Flags.c_NACK | flags, null); - return await msg.SendAsync(cancellationToken); + return await msg.SendAsync(cancellationToken).ConfigureAwait(false); } public async Task ReplyAsync(Converter converter, uint flags, object payload, CancellationToken cancellationToken) @@ -101,7 +101,7 @@ public async Task ReplyAsync(Converter converter, uint flags, object paylo OutgoingMessage msgReply = new OutgoingMessage(this, converter, flags, payload); - return await msgReply.SendAsync(cancellationToken); + return await msgReply.SendAsync(cancellationToken).ConfigureAwait(false); } } } diff --git a/source/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/MessageReassembler.cs b/source/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/MessageReassembler.cs index 96903ff7..1deb4bf4 100644 --- a/source/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/MessageReassembler.cs +++ b/source/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/MessageReassembler.cs @@ -102,7 +102,7 @@ internal async Task ProcessAsync(CancellationToken cancellation // need to have a timeout to cancel the read task otherwise it may end up waiting forever for this to return // because we have an external cancellation token and the above timeout cancellation token, need to combine both - bytesRead = await _parent.ReadBufferAsync(_messageRaw.Header, _rawPos, count, request.waitRetryTimeout, cancellationToken.AddTimeout(request.waitRetryTimeout)); + bytesRead = await _parent.ReadBufferAsync(_messageRaw.Header, _rawPos, count, request.waitRetryTimeout, cancellationToken.AddTimeout(request.waitRetryTimeout)).ConfigureAwait(false); _rawPos += bytesRead; @@ -145,7 +145,7 @@ internal async Task ProcessAsync(CancellationToken cancellation // need to have a timeout to cancel the read task otherwise it may end up waiting forever for this to return // because we have an external cancellation token and the above timeout cancellation token, need to combine both - bytesRead = await _parent.ReadBufferAsync(_messageRaw.Header, _rawPos, count, request.waitRetryTimeout, cancellationToken.AddTimeout(request.waitRetryTimeout)); + bytesRead = await _parent.ReadBufferAsync(_messageRaw.Header, _rawPos, count, request.waitRetryTimeout, cancellationToken.AddTimeout(request.waitRetryTimeout)).ConfigureAwait(false); _rawPos += bytesRead; @@ -220,7 +220,7 @@ internal async Task ProcessAsync(CancellationToken cancellation // need to have a timeout to cancel the read task otherwise it may end up waiting forever for this to return // because we have an external cancellation token and the above timeout cancellation token, need to combine both - bytesRead = await _parent.ReadBufferAsync(_messageRaw.Payload, _rawPos, count, request.waitRetryTimeout, cancellationToken.AddTimeout(request.waitRetryTimeout)); + bytesRead = await _parent.ReadBufferAsync(_messageRaw.Payload, _rawPos, count, request.waitRetryTimeout, cancellationToken.AddTimeout(request.waitRetryTimeout)).ConfigureAwait(false); _rawPos += bytesRead; @@ -246,7 +246,7 @@ internal async Task ProcessAsync(CancellationToken cancellation _messageRaw.Payload = null; } - if (await ProcessMessage(GetCompleteMessage(), fReply, cancellationToken)) + if (await ProcessMessage(GetCompleteMessage(), fReply, cancellationToken).ConfigureAwait(false)) { DebuggerEventSource.Log.WireProtocolReceiveState(_state); @@ -285,7 +285,7 @@ internal async Task ProcessAsync(CancellationToken cancellation { // FIXME // evaluate the purpose of this reply back to the NanoFramework device, the nanoCLR doesn't seem to have to handle this. In the end it looks like this does have any real purpose and will only be wasting CPU. - await IncomingMessage.ReplyBadPacketAsync(_parent, Flags.c_BadPayload, cancellationToken); + await IncomingMessage.ReplyBadPacketAsync(_parent, Flags.c_BadPayload, cancellationToken).ConfigureAwait(false); return GetCompleteMessage(); } @@ -387,7 +387,7 @@ public async Task ProcessMessage(IncomingMessage msg, bool fReply, Cancell // FIXME //cmdReply.m_dbg_flags = (m_stopDebuggerOnConnect ? Commands.Monitor_Ping.c_Ping_DbgFlag_Stop : 0); - await msg.ReplyAsync(_parent.CreateConverter(), Flags.c_NonCritical, cmdReply, cancellationToken); + await msg.ReplyAsync(_parent.CreateConverter(), Flags.c_NonCritical, cmdReply, cancellationToken).ConfigureAwait(false); //m_evtPing.Set(); diff --git a/source/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/OutgoingMessage.cs b/source/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/OutgoingMessage.cs index 05b873bc..ae4e1198 100644 --- a/source/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/OutgoingMessage.cs +++ b/source/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/OutgoingMessage.cs @@ -98,7 +98,7 @@ internal async Task SendAsync(CancellationToken cancellationToken) , _base.Header.Size ); - return await _parent.QueueOutputAsync(_raw, cancellationToken); + return await _parent.QueueOutputAsync(_raw, cancellationToken).ConfigureAwait(false); } } } diff --git a/source/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Request.cs b/source/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Request.cs index 3abcef39..bb3c9b5b 100644 --- a/source/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Request.cs +++ b/source/nanoFramework.Tools.DebugLibrary.Shared/WireProtocol/Request.cs @@ -134,7 +134,7 @@ internal async Task PerformRequestAsync() // send message // add a cancellation token to force cancel, the send - if (await outgoingMsg.SendAsync(cTSource.Token)) + if (await outgoingMsg.SendAsync(cTSource.Token).ConfigureAwait(false)) { // if this request is for a reboot, we won't be able to receive the reply right away because the device is rebooting if(outgoingMsg.Header.Cmd == Commands.c_Monitor_Reboot) @@ -152,7 +152,7 @@ internal async Task PerformRequestAsync() { // need to have a timeout to cancel the process task otherwise it may end up waiting forever for this to return // because we have an external cancellation token and the above timeout cancellation token, need to combine both - reply = await reassembler.ProcessAsync(cTSource.Token.AddTimeout(waitRetryTimeout)); + reply = await reassembler.ProcessAsync(cTSource.Token.AddTimeout(waitRetryTimeout)).ConfigureAwait(false); } catch(Exception ex) {