Browse Source

fixes: Debugger Attached

- Add Code Comment to describe the behaviour
- Add Timeout
- Add Log
pull/6972/head
Giuseppe Lippolis 5 years ago
parent
commit
2eebb316ef
  1. 28
      src/Avalonia.Build.Tasks/XamlCompilerTaskExecutor.cs

28
src/Avalonia.Build.Tasks/XamlCompilerTaskExecutor.cs

@ -84,8 +84,32 @@ namespace Avalonia.Build.Tasks
{
if (debuggerLaunch)
{
System.Diagnostics.Debugger.Launch();
while(!System.Diagnostics.Debugger.IsAttached) System.Threading.Thread.Sleep(100);
// According this https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.debugger.launch?view=net-6.0#remarks
// documentation, on not windows platform Debugger.Launch() always return true without running a debugger.
if (System.Diagnostics.Debugger.Launch())
{
// Set timeout at 1 minut.
var time = new System.Diagnostics.Stopwatch();
var timeout = TimeSpan.FromMinutes(1);
time.Start();
// wait for the debugger to be attacked or timeout.
while (!System.Diagnostics.Debugger.IsAttached && time.Elapsed < timeout)
{
engine.LogMessage($"Wating attach debugger. Elapsed {time.Elapsed}...", MessageImportance.Low);
System.Threading.Thread.Sleep(100);
}
time.Stop();
if (time.Elapsed >= timeout)
{
engine.LogMessage("Wating attach debugger timeout.", MessageImportance.Normal);
}
}
else
{
engine.LogMessage("Debugging cancelled.", MessageImportance.Normal);
}
}
var asm = typeSystem.TargetAssemblyDefinition;
var emres = new EmbeddedResources(asm);

Loading…
Cancel
Save