diff --git a/m365-developer-proxy-abstractions/PluginEvents.cs b/m365-developer-proxy-abstractions/PluginEvents.cs index 2649c6a4..0d0fe208 100644 --- a/m365-developer-proxy-abstractions/PluginEvents.cs +++ b/m365-developer-proxy-abstractions/PluginEvents.cs @@ -100,13 +100,13 @@ public OptionsLoadedArgs(InvocationContext context) { } public class RequestLog { - public string[] Message { get; set; } + public string[] MessageLines { get; set; } public MessageType MessageType { get; set; } public LoggingContext? Context { get; set; } - public RequestLog(string[] message, MessageType messageType, LoggingContext? context) + public RequestLog(string[] messageLines, MessageType messageType, LoggingContext? context) { - Message = message ?? throw new ArgumentNullException(nameof(message)); + MessageLines = messageLines ?? throw new ArgumentNullException(nameof(messageLines)); MessageType = messageType; Context = context; } diff --git a/m365-developer-proxy-plugins/Inspection/DevToolsPlugin.cs b/m365-developer-proxy-plugins/Inspection/DevToolsPlugin.cs index 62cfd2a1..5cee34e7 100644 --- a/m365-developer-proxy-plugins/Inspection/DevToolsPlugin.cs +++ b/m365-developer-proxy-plugins/Inspection/DevToolsPlugin.cs @@ -117,14 +117,19 @@ private void SocketMessageReceived(string msg) if (message?.Method == "Network.getResponseBody") { var requestId = message.Params?.RequestId; - if (requestId is null || !responseBody.ContainsKey(requestId)) + if (requestId is null || + !responseBody.ContainsKey(requestId) || + // should never happen because the message is sent from devtools + // and Id is required on all socket messages but theoretically + // it is possible + message.Id is null) { return; } var result = new GetResponseBodyResult { - Id = (int)message.Id!, + Id = (int)message.Id, Result = new() { Body = responseBody[requestId].Body, @@ -286,7 +291,7 @@ private async void AfterRequestLog(object? sender, RequestLogArgs e) Entry = new() { Source = "network", - Text = string.Join(" ", e.RequestLog.Message), + Text = string.Join(" ", e.RequestLog.MessageLines), Level = Entry.GetLevel(e.RequestLog.MessageType), Timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), Url = e.RequestLog.Context?.Session.HttpClient.Request.Url, diff --git a/m365-developer-proxy-plugins/RequestLogs/ExecutionSummaryPlugin.cs b/m365-developer-proxy-plugins/RequestLogs/ExecutionSummaryPlugin.cs index 6586002b..8a8ab65c 100644 --- a/m365-developer-proxy-plugins/RequestLogs/ExecutionSummaryPlugin.cs +++ b/m365-developer-proxy-plugins/RequestLogs/ExecutionSummaryPlugin.cs @@ -336,7 +336,7 @@ private Dictionary>> GetGroup private string GetRequestMessage(RequestLog requestLog) { - return String.Join(' ', requestLog.Message); + return String.Join(' ', requestLog.MessageLines); } private string GetMethodAndUrl(RequestLog requestLog) diff --git a/m365-developer-proxy-plugins/RequestLogs/MinimalPermissionsGuidancePlugin.cs b/m365-developer-proxy-plugins/RequestLogs/MinimalPermissionsGuidancePlugin.cs index 78fab304..46ba4aed 100644 --- a/m365-developer-proxy-plugins/RequestLogs/MinimalPermissionsGuidancePlugin.cs +++ b/m365-developer-proxy-plugins/RequestLogs/MinimalPermissionsGuidancePlugin.cs @@ -46,7 +46,7 @@ private async void AfterRecordingStop(object? sender, RecordingArgs e) continue; } - var methodAndUrlString = request.Message.First(); + var methodAndUrlString = request.MessageLines.First(); var methodAndUrl = GetMethodAndUrl(methodAndUrlString); var requestsFromBatch = Array.Empty>(); diff --git a/m365-developer-proxy-plugins/RequestLogs/MinimalPermissionsPlugin.cs b/m365-developer-proxy-plugins/RequestLogs/MinimalPermissionsPlugin.cs index e15a6185..6150a526 100644 --- a/m365-developer-proxy-plugins/RequestLogs/MinimalPermissionsPlugin.cs +++ b/m365-developer-proxy-plugins/RequestLogs/MinimalPermissionsPlugin.cs @@ -49,7 +49,7 @@ private async void AfterRecordingStop(object? sender, RecordingArgs e) continue; } - var methodAndUrlString = request.Message.First(); + var methodAndUrlString = request.MessageLines.First(); var methodAndUrl = GetMethodAndUrl(methodAndUrlString); var uri = new Uri(methodAndUrl.Item2); diff --git a/m365-developer-proxy-plugins/RequestLogs/MockGeneratorPlugin.cs b/m365-developer-proxy-plugins/RequestLogs/MockGeneratorPlugin.cs index fe48ea42..985cbe6f 100644 --- a/m365-developer-proxy-plugins/RequestLogs/MockGeneratorPlugin.cs +++ b/m365-developer-proxy-plugins/RequestLogs/MockGeneratorPlugin.cs @@ -45,7 +45,7 @@ request.Context is null || continue; } - var methodAndUrlString = request.Message.First(); + var methodAndUrlString = request.MessageLines.First(); _logger?.LogDebug($"Processing request {methodAndUrlString}..."); var methodAndUrl = GetMethodAndUrl(methodAndUrlString);