Skip to content

Commit

Permalink
Modified regexes uses for group-match. (#79988)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilonatommy committed Dec 27, 2022
1 parent c84d95d commit cf91dbe
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/mono/wasm/debugger/BrowserDebugProxy/MonoSDBHelper.cs
Expand Up @@ -804,12 +804,12 @@ internal sealed class MonoSDBHelper
private SessionId sessionId;

internal readonly ILogger logger;
private static readonly Regex regexForAsyncLocals = new(@"\<([^)]*)\>([^)]*)([_][_])([0-9]*)", RegexOptions.Singleline); //<testCSharpScope>5__1
private static readonly Regex regexForVBAsyncLocals = new(@"\$VB\$ResumableLocal_([^)]*)\$([0-9]*)", RegexOptions.Singleline); //$VB$ResumableLocal_testVbScope$2
private static readonly Regex regexForVBAsyncMethodName = new(@"VB\$StateMachine_([0-9]*)_([^)]*)", RegexOptions.Singleline); //VB$StateMachine_2_RunVBScope
private static readonly Regex regexForAsyncLocals = new(@"\<(?<varName>[^)]*)\>(?<varId>[^)]*)(__)(?<scopeId>\d+)", RegexOptions.Singleline); //<testCSharpScope>5__1 // works
private static readonly Regex regexForVBAsyncLocals = new(@"\$VB\$ResumableLocal_(?<varName>[^\$]*)\$(?<scopeId>\d+)", RegexOptions.Singleline); //$VB$ResumableLocal_testVbScope$2
private static readonly Regex regexForVBAsyncMethodName = new(@"VB\$StateMachine_(\d+)_(?<methodName>.*)", RegexOptions.Singleline); //VB$StateMachine_2_RunVBScope
private static readonly Regex regexForAsyncMethodName = new (@"\<([^>]*)\>([d][_][_])([0-9]*)", RegexOptions.Compiled);
private static readonly Regex regexForGenericArgs = new (@"[`][0-9]+", RegexOptions.Compiled);
private static readonly Regex regexForNestedLeftRightAngleBrackets = new ("^(((?'Open'<)[^<>]*)+((?'Close-Open'>)[^<>]*)+)*(?(Open)(?!))[^<>]*", RegexOptions.Compiled);
private static readonly Regex regexForNestedLeftRightAngleBrackets = new ("^(((?'Open'<)[^<>]*)+((?'Close-Open'>)[^<>]*)+)*(?(Open)(?!))[^<>]*", RegexOptions.Compiled); // <ContinueWithStaticAsync>b__3_0
public JObjectValueCreator ValueCreator { get; init; }

public static int GetNewId() { return cmdId++; }
Expand Down Expand Up @@ -1291,27 +1291,27 @@ public async Task<string> GetPrettyMethodName(int methodId, bool isAnonymous, Ca
{
var match = regexForVBAsyncMethodName.Match(klassName);
if (match.Success)
ret = ret.Insert(0, match.Groups[2].Value);
ret = ret.Insert(0, match.Groups["methodName"].Value);
else
ret = ret.Insert(0, klassName);
}
else
{
var matchOnClassName = regexForNestedLeftRightAngleBrackets.Match(klassName);
if (matchOnClassName.Success && matchOnClassName.Groups[5].Captures.Count > 0)
klassName = matchOnClassName.Groups[5].Captures[0].Value;
if (matchOnClassName.Success && matchOnClassName.Groups["Close"].Captures.Count > 0)
klassName = matchOnClassName.Groups["Close"].Captures[0].Value;
if (ret.Length > 0)
ret = ret.Insert(0, ".");
ret = ret.Insert(0, klassName);
}
}
var methodName = retDebuggerCmdReader.ReadString();
var matchOnMethodName = regexForNestedLeftRightAngleBrackets.Match(methodName);
if (matchOnMethodName.Success && matchOnMethodName.Groups[5].Captures.Count > 0)
if (matchOnMethodName.Success && matchOnMethodName.Groups["Close"].Captures.Count > 0)
{
if (isAnonymous && anonymousMethodId.Length == 0 && methodName.Contains("__"))
anonymousMethodId = methodName.Substring(methodName.IndexOf("__") + 2);
methodName = matchOnMethodName.Groups[5].Captures[0].Value;
methodName = matchOnMethodName.Groups["Close"].Captures[0].Value;
ret.Append($".{methodName}");
}
if (isAnonymous && anonymousMethodId.Length > 0)
Expand Down Expand Up @@ -2010,9 +2010,9 @@ public async Task<JArray> GetHoistedLocalVariables(MethodInfoWithDebugInformatio
var match = regexForAsyncLocals.Match(fieldName);
if (match.Success)
{
if (!method.Info.ContainsAsyncScope(Convert.ToInt32(match.Groups[4].Value), offset))
if (!method.Info.ContainsAsyncScope(Convert.ToInt32(match.Groups["scopeId"].Value), offset))
continue;
asyncLocal["name"] = match.Groups[1].Value;
asyncLocal["name"] = match.Groups["varName"].Value;
}
}
//VB language
Expand All @@ -2025,9 +2025,9 @@ public async Task<JArray> GetHoistedLocalVariables(MethodInfoWithDebugInformatio
var match = regexForVBAsyncLocals.Match(fieldName);
if (match.Success)
{
if (!method.Info.ContainsAsyncScope(Convert.ToInt32(match.Groups[2].Value) + 1, offset))
if (!method.Info.ContainsAsyncScope(Convert.ToInt32(match.Groups["scopeId"].Value) + 1, offset))
continue;
asyncLocal["name"] = match.Groups[1].Value;
asyncLocal["name"] = match.Groups["varName"].Value;
}
}
else if (fieldName.StartsWith("$"))
Expand Down

0 comments on commit cf91dbe

Please sign in to comment.