Skip to content

Commit 071285f

Browse files
committed
- WDBG UX improvements
1 parent 6a392c5 commit 071285f

File tree

5 files changed

+33
-7
lines changed

5 files changed

+33
-7
lines changed

src/out/static_content/-wdbg/dbg-inject.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,8 @@ public static (string script, string decoratedScript, int[] breakpoints)[] Proce
258258
variablesToAnalyse = variablesToAnalyse.Except(invalidVariables[indexInErrorOutput]).ToList();
259259
}
260260

261-
var inspectionObjects = string.Join(", ", variablesToAnalyse.Select(x => $"(\"{x}\", {x})"));
261+
// var inspectionObjects = string.Join(", ", variablesToAnalyse.Select(x => $"(\"{x}\", {x})"));
262+
var inspectionObjects = string.Join(", ", variablesToAnalyse.Select(x => $"{x}.v()"));
262263

263264
if (scope.File == script && lines.Count() >= scope.StartLine)
264265
{

src/out/static_content/-wdbg/dbg-runtime.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919

2020
public static class DBG
2121
{
22+
public static (string, object) v(this object value, [CallerArgumentExpression("value")] string expr = null)
23+
{
24+
return (expr, value);
25+
}
26+
2227
static DBG()
2328
{
2429
if (Environment.GetEnvironmentVariable("CSS_WEB_DEBUGGING_URL") == null)
@@ -836,6 +841,10 @@ static public string ReplaceClrAliaces(this string text, bool hideSystemNamespac
836841

837842
public static string ToReadable(this string methodName)
838843
{
844+
if (methodName.Contains("<Main>")) // at runtime CLR decorates even normal mail (e.g. if it is async)
845+
return "Main";
846+
847+
// classless main, local methods and lambdas
839848
var result = methodName?
840849
.Replace("<", "")
841850
.Replace(">", "")
@@ -863,14 +872,17 @@ public static string[] GetCallChain(this StackFrame[] frames)
863872

864873
if (method != null)
865874
{
866-
var declaringType = method.DeclaringType?.Name ?? "UnknownType";
875+
var declaringType = method.DeclaringType?.FullName ?? "UnknownType";
867876

868877
// local methods and lambdas
869878
//<<Main>$>g__setup_say_hello|0_0
870879
//<<Main>$>g__test|0_1
871880
//<Main>$
872881

873882
var methodName = method.Name?.ToReadable() ?? "UnknownMethod";
883+
if (method.ReflectedType.FullName?.Contains("+<Main>") == true)
884+
methodName = "Main";
885+
874886
var fileName = frame.GetFileName() ?? "";
875887
var lineNumber = frame.GetFileLineNumber();
876888

src/out/static_content/-wdbg/dbg-server/Pages/CodeMirrorPage.razor

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,7 @@
510510
async Task<string> GetUndoBuffer() { try{ return await js<string>("codemirrorInterop.getUndoBuffer");} catch (Exception e) { e.Log(); } return ""; }
511511
async Task SetUndoBuffer(string buffer) { try{ await js("codemirrorInterop.setUndoBuffer", buffer);} catch (Exception e) { e.Log(); } }
512512
async Task FocusEditor() { try { await js("codemirrorInterop.focusEditor"); } catch (Exception e) { e.Log(); } }
513+
async Task BrowserLog(string message) { try { await js("codemirrorInterop.log", message); } catch (Exception e) { e.Log(); } }
513514

514515
async Task OnThemeChanged(ChangeEventArgs e)
515516
{

src/out/static_content/-wdbg/dbg-server/Pages/CodeMirrorPage.razor.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
using Microsoft.AspNetCore.Components;
2-
using Microsoft.AspNetCore.Components.Forms;
3-
using Microsoft.AspNetCore.Components.Web;
4-
using Microsoft.JSInterop;
5-
using System;
1+
using System;
62
using System.Diagnostics;
73
using System.IO;
84
using System.Linq;
95
using System.Runtime.InteropServices;
106
using System.Text.Json;
7+
using Microsoft.AspNetCore.Components;
8+
using Microsoft.AspNetCore.Components.Forms;
9+
using Microsoft.AspNetCore.Components.Web;
10+
using Microsoft.JSInterop;
1111
using wdbg.cs_script;
1212

1313
namespace wdbg.Pages;
@@ -330,6 +330,7 @@ public async Task OpenScriptFolder()
330330
}
331331
catch (Exception e) { e.Log(); }
332332
}
333+
333334
public async Task OpenScriptDebugFolder()
334335
{
335336
try
@@ -545,6 +546,8 @@ public async Task StartGeneratingDebugMetadata(bool showNotification)
545546
{
546547
var error = e.Message ?? "Generating debug information for the loaded script has failed.";
547548

549+
_ = BrowserLog(error);
550+
548551
if (e.Message?.Contains("Error: Specified file could not be compiled.") == true)
549552
{
550553
Editor.DebugGenerationError =
@@ -553,7 +556,12 @@ public async Task StartGeneratingDebugMetadata(bool showNotification)
553556
}
554557

555558
if (showNotification)
559+
{
560+
if (error.Length > 400)
561+
error = error.Substring(0, 400) + "... (error text is truncated, see browser console log for the complete error text)";
556562
Editor.ShowToastError(error); // failures can happen (e.g. *.dbg.cs is still locked)
563+
}
564+
557565

558566
Editor.ResetDbgGenerator();
559567
Editor.LoadedScriptDbg = null;

src/out/static_content/-wdbg/dbg-server/wwwroot/codemirrorInterop.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,4 +1228,8 @@ window.codemirrorInterop.triggerCompletion = function () {
12281228
return true;
12291229
}
12301230
return false;
1231+
};
1232+
1233+
window.codemirrorInterop.log = function (message) {
1234+
console.log(message);
12311235
};

0 commit comments

Comments
 (0)