From 62d07d908cc944a15971640303d69fb58d6f562c Mon Sep 17 00:00:00 2001
From: Andy Jordan <andy.jordan@microsoft.com>
Date: Mon, 28 Nov 2022 13:59:33 -0800
Subject: [PATCH] Use the `LspSerializer` in `CodeActions` and `SendTelemetry`

---
 .../Services/CodeLens/ReferencesCodeLensProvider.cs       | 6 +++---
 .../Services/TextDocument/Handlers/CodeActionHandler.cs   | 8 +++++++-
 .../Services/Workspace/Handlers/ConfigurationHandler.cs   | 3 ++-
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/PowerShellEditorServices/Services/CodeLens/ReferencesCodeLensProvider.cs b/src/PowerShellEditorServices/Services/CodeLens/ReferencesCodeLensProvider.cs
index 02cff641d..eb50ce2d5 100644
--- a/src/PowerShellEditorServices/Services/CodeLens/ReferencesCodeLensProvider.cs
+++ b/src/PowerShellEditorServices/Services/CodeLens/ReferencesCodeLensProvider.cs
@@ -154,9 +154,9 @@ public async Task<CodeLens> ResolveCodeLens(
                     Title = GetReferenceCountHeader(referenceLocations.Length),
                     Arguments = JArray.FromObject(new object[]
                     {
-                    scriptFile.DocumentUri,
-                    codeLens.Range.Start,
-                    referenceLocations
+                        scriptFile.DocumentUri,
+                        codeLens.Range.Start,
+                        referenceLocations
                     },
                     LspSerializer.Instance.JsonSerializer)
                 }
diff --git a/src/PowerShellEditorServices/Services/TextDocument/Handlers/CodeActionHandler.cs b/src/PowerShellEditorServices/Services/TextDocument/Handlers/CodeActionHandler.cs
index 8ea7eca70..2681baa19 100644
--- a/src/PowerShellEditorServices/Services/TextDocument/Handlers/CodeActionHandler.cs
+++ b/src/PowerShellEditorServices/Services/TextDocument/Handlers/CodeActionHandler.cs
@@ -5,6 +5,7 @@
 using System.Collections.Generic;
 using System.Threading;
 using System.Threading.Tasks;
+using Newtonsoft.Json.Linq;
 using Microsoft.Extensions.Logging;
 using Microsoft.PowerShell.EditorServices.Services;
 using Microsoft.PowerShell.EditorServices.Services.TextDocument;
@@ -12,6 +13,7 @@
 using OmniSharp.Extensions.LanguageServer.Protocol.Client.Capabilities;
 using OmniSharp.Extensions.LanguageServer.Protocol.Document;
 using OmniSharp.Extensions.LanguageServer.Protocol.Models;
+using OmniSharp.Extensions.LanguageServer.Protocol.Serialization;
 
 namespace Microsoft.PowerShell.EditorServices.Handlers
 {
@@ -131,7 +133,11 @@ public override async Task<CommandOrCodeActionContainer> Handle(CodeActionParams
                         {
                             Title = title,
                             Name = "PowerShell.ShowCodeActionDocumentation",
-                            Arguments = Newtonsoft.Json.Linq.JArray.FromObject(new[] { diagnostic.Code?.String })
+                            Arguments = JArray.FromObject(new object[]
+                            {
+                                diagnostic.Code?.String
+                            },
+                            LspSerializer.Instance.JsonSerializer)
                         }
                     });
                 }
diff --git a/src/PowerShellEditorServices/Services/Workspace/Handlers/ConfigurationHandler.cs b/src/PowerShellEditorServices/Services/Workspace/Handlers/ConfigurationHandler.cs
index ea7214a0a..0fa74996a 100644
--- a/src/PowerShellEditorServices/Services/Workspace/Handlers/ConfigurationHandler.cs
+++ b/src/PowerShellEditorServices/Services/Workspace/Handlers/ConfigurationHandler.cs
@@ -12,6 +12,7 @@
 using Microsoft.PowerShell.EditorServices.Services.Configuration;
 using Newtonsoft.Json.Linq;
 using OmniSharp.Extensions.LanguageServer.Protocol.Models;
+using OmniSharp.Extensions.LanguageServer.Protocol.Serialization;
 using OmniSharp.Extensions.LanguageServer.Protocol.Server;
 using OmniSharp.Extensions.LanguageServer.Protocol.Window;
 using OmniSharp.Extensions.LanguageServer.Protocol.Workspace;
@@ -158,7 +159,7 @@ private void SendFeatureChangesTelemetry(LanguageServerSettingsWrapper incomingS
                 ExtensionData = new PsesTelemetryEvent
                 {
                     EventName = "NonDefaultPsesFeatureConfiguration",
-                    Data = JObject.FromObject(configChanges)
+                    Data = JObject.FromObject(configChanges, LspSerializer.Instance.JsonSerializer)
                 }
             });
         }
