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 3
3
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
4
4
//
5
5
6
+ using System . Collections ;
6
7
using Microsoft . PowerShell . EditorServices . Protocol . MessageProtocol ;
8
+ using System . Collections . Generic ;
7
9
8
10
namespace Microsoft . PowerShell . EditorServices . Protocol . LanguageServer
9
11
{
@@ -28,9 +30,15 @@ class ScriptFileMarkerRequestParams
28
30
public string filePath ;
29
31
30
32
/// <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.
32
40
/// </summary>
33
- public string settings ;
41
+ public Dictionary < string , Hashtable > settings ;
34
42
}
35
43
36
44
/// <summary>
Original file line number Diff line number Diff line change @@ -239,7 +239,7 @@ private async Task HandleScriptFileMarkersRequest(
239
239
{
240
240
var markers = editorSession . AnalysisService . GetSemanticMarkers (
241
241
editorSession . Workspace . GetFile ( requestParams . filePath ) ,
242
- editorSession . LanguageService . GetHashtableFromString ( requestParams . settings ) ) ;
242
+ editorSession . AnalysisService . GetPSSASettingsHashtable ( requestParams . settings ) ) ;
243
243
await requestContext . SendResult ( new ScriptFileMarkerRequestResultParams {
244
244
markers = markers
245
245
} ) ;
Original file line number Diff line number Diff line change @@ -175,6 +175,27 @@ public IEnumerable<string> GetPSScriptAnalyzerRules()
175
175
return ruleNames ;
176
176
}
177
177
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
+
178
199
/// <summary>
179
200
/// Disposes the runspace being used by the analysis service.
180
201
/// </summary>
You can’t perform that action at this time.
0 commit comments