if (type == "debug")
{
JToken a = args["args"];
- if (a?[0]?["value"]?.ToString() == MonoConstants.RUNTIME_IS_READY &&
- a?[1]?["value"]?.ToString() == "fe00e07a-5519-4dfe-b35a-f867dbaf2e28")
+ if (a is null)
+ break;
+
+ int aCount = a.Count();
+ if (aCount >= 2 &&
+ a[0]?["value"]?.ToString() == MonoConstants.RUNTIME_IS_READY &&
+ a[1]?["value"]?.ToString() == "fe00e07a-5519-4dfe-b35a-f867dbaf2e28")
{
- if (a.Count() > 2)
+ if (aCount > 2)
{
try
{
// The optional 3rd argument is the stringified assembly
// list so that we don't have to make more round trips
ExecutionContext context = GetContext(sessionId);
- string loaded = a?[2]?["value"]?.ToString();
+ string loaded = a[2]?["value"]?.ToString();
if (loaded != null)
context.LoadedFiles = JToken.Parse(loaded).ToObject<string[]>();
}
}
await RuntimeReady(sessionId, token);
}
- else if (a?[0]?["value"]?.ToString() == MonoConstants.EVENT_RAISED)
+ else if (aCount > 1 && a[0]?["value"]?.ToString() == MonoConstants.EVENT_RAISED)
{
if (a.Type != JTokenType.Array)
{
}
else
{
- if (JObjectTryParse(a?[2]?["value"]?.Value<string>(), out JObject raiseArgs) &&
+ if (aCount > 2 &&
+ JObjectTryParse(a?[2]?["value"]?.Value<string>(), out JObject raiseArgs) &&
JObjectTryParse(a?[1]?["value"]?.Value<string>(), out JObject eventArgs))
{
await OnJSEventRaised(sessionId, eventArgs, token);