File tree Expand file tree Collapse file tree 3 files changed +32
-3
lines changed
PowerShellEditorServices.Protocol
PowerShellEditorServices/Analysis Expand file tree Collapse file tree 3 files changed +32
-3
lines changed Original file line number Diff line number Diff line change 33// Licensed under the MIT license. See LICENSE file in the project root for full license information.
44//
55
6+ using System . Collections ;
67using Microsoft . PowerShell . EditorServices . Protocol . MessageProtocol ;
8+ using System . Collections . Generic ;
79
810namespace Microsoft . PowerShell . EditorServices . Protocol . LanguageServer
911{
@@ -28,9 +30,15 @@ class ScriptFileMarkerRequestParams
2830 public string filePath ;
2931
3032 /// <summary>
31- /// Settings to provided to ScriptAnalyzer to get the markers.
33+ /// Settings to be provided to ScriptAnalyzer to get the markers.
34+ ///
35+ /// We have this unusual structure because JSON deserializer
36+ /// does not deserialize nested hashtables. i.e. it won't
37+ /// deserialize a hashtable within a hashtable. But in this case,
38+ /// i.e. a hashtable within a dictionary, it will deserialize
39+ /// the hashtable.
3240 /// </summary>
33- public string settings ;
41+ public Dictionary < string , Hashtable > settings ;
3442 }
3543
3644 /// <summary>
Original file line number Diff line number Diff line change @@ -239,7 +239,7 @@ private async Task HandleScriptFileMarkersRequest(
239239 {
240240 var markers = editorSession . AnalysisService . GetSemanticMarkers (
241241 editorSession . Workspace . GetFile ( requestParams . filePath ) ,
242- editorSession . LanguageService . GetHashtableFromString ( requestParams . settings ) ) ;
242+ editorSession . AnalysisService . GetPSSASettingsHashtable ( requestParams . settings ) ) ;
243243 await requestContext . SendResult ( new ScriptFileMarkerRequestResultParams {
244244 markers = markers
245245 } ) ;
Original file line number Diff line number Diff line change @@ -175,6 +175,27 @@ public IEnumerable<string> GetPSScriptAnalyzerRules()
175175 return ruleNames ;
176176 }
177177
178+ /// <summary>
179+ /// Construct a PSScriptAnalyzer settings hashtable
180+ /// </summary>
181+ /// <param name="ruleSettingsMap">A settings hashtable</param>
182+ /// <returns></returns>
183+ public Hashtable GetPSSASettingsHashtable ( IDictionary < string , Hashtable > ruleSettingsMap )
184+ {
185+ var hashtable = new Hashtable ( ) ;
186+ var ruleSettingsHashtable = new Hashtable ( ) ;
187+
188+ hashtable [ "IncludeRules" ] = ruleSettingsMap . Keys . ToArray < object > ( ) ;
189+ hashtable [ "Rules" ] = ruleSettingsHashtable ;
190+
191+ foreach ( var kvp in ruleSettingsMap )
192+ {
193+ ruleSettingsHashtable . Add ( kvp . Key , kvp . Value ) ;
194+ }
195+
196+ return hashtable ;
197+ }
198+
178199 /// <summary>
179200 /// Disposes the runspace being used by the analysis service.
180201 /// </summary>
You can’t perform that action at this time.
0 commit comments