From e3ef986ba0c12e3f1b855955e71a5d237063dba6 Mon Sep 17 00:00:00 2001 From: Darren Kattan <1424395+dkattan@users.noreply.github.com> Date: Fri, 18 Jun 2021 08:37:23 -0500 Subject: [PATCH 1/3] Added null check for incomingSettings.Powershell to prevent SendFeatureChangesTelemetry from throwing an exception when accessing Powershell and its properties. --- .../Services/Workspace/Handlers/ConfigurationHandler.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PowerShellEditorServices/Services/Workspace/Handlers/ConfigurationHandler.cs b/src/PowerShellEditorServices/Services/Workspace/Handlers/ConfigurationHandler.cs index b89c3d127..8cf04e5de 100644 --- a/src/PowerShellEditorServices/Services/Workspace/Handlers/ConfigurationHandler.cs +++ b/src/PowerShellEditorServices/Services/Workspace/Handlers/ConfigurationHandler.cs @@ -51,7 +51,7 @@ public override async Task Handle(DidChangeConfigurationParams request, Ca { LanguageServerSettingsWrapper incomingSettings = request.Settings.ToObject(); this._logger.LogTrace("Handling DidChangeConfiguration"); - if (incomingSettings == null) + if (incomingSettings is null || incomingSettings.Powershell is null) { this._logger.LogTrace("Incoming settings were null"); return await Unit.Task.ConfigureAwait(false); From 49dcfefe5ec099baa83497418a026ef4f524a783 Mon Sep 17 00:00:00 2001 From: Darren Kattan <1424395+dkattan@users.noreply.github.com> Date: Fri, 18 Jun 2021 08:46:06 -0500 Subject: [PATCH 2/3] Added null check in GetProfilePathFromProfileObject to prevent NullReferenceException if profileObject is null. --- .../Commands/StartEditorServicesCommand.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/PowerShellEditorServices.Hosting/Commands/StartEditorServicesCommand.cs b/src/PowerShellEditorServices.Hosting/Commands/StartEditorServicesCommand.cs index 018a70224..6dbc5f1ae 100644 --- a/src/PowerShellEditorServices.Hosting/Commands/StartEditorServicesCommand.cs +++ b/src/PowerShellEditorServices.Hosting/Commands/StartEditorServicesCommand.cs @@ -378,7 +378,8 @@ private EditorServicesConfig CreateConfigObject() private string GetProfilePathFromProfileObject(PSObject profileObject, ProfileUserKind userKind, ProfileHostKind hostKind) { string profilePathName = $"{userKind}{hostKind}"; - + if (profileObject is null) + return null; string pwshProfilePath = (string)profileObject.Properties[profilePathName].Value; if (hostKind == ProfileHostKind.AllHosts) From 8f76f4f659e59e2b4bed20f3c469541a8a84fbf4 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Fri, 18 Jun 2021 18:23:38 -0700 Subject: [PATCH 3/3] Update src/PowerShellEditorServices.Hosting/Commands/StartEditorServicesCommand.cs --- .../Commands/StartEditorServicesCommand.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/PowerShellEditorServices.Hosting/Commands/StartEditorServicesCommand.cs b/src/PowerShellEditorServices.Hosting/Commands/StartEditorServicesCommand.cs index 6dbc5f1ae..0e698f812 100644 --- a/src/PowerShellEditorServices.Hosting/Commands/StartEditorServicesCommand.cs +++ b/src/PowerShellEditorServices.Hosting/Commands/StartEditorServicesCommand.cs @@ -379,7 +379,9 @@ private string GetProfilePathFromProfileObject(PSObject profileObject, ProfileUs { string profilePathName = $"{userKind}{hostKind}"; if (profileObject is null) + { return null; + } string pwshProfilePath = (string)profileObject.Properties[profilePathName].Value; if (hostKind == ProfileHostKind.AllHosts)