@@ -129,7 +129,7 @@ public AnalysisService(IConsoleHost consoleHost, string settingsPath = null)
129129 #region Public Methods
130130
131131 /// <summary>
132- /// Performs semantic analysis on the given ScriptFile and returns
132+ /// Perform semantic analysis on the given ScriptFile and returns
133133 /// an array of ScriptFileMarkers.
134134 /// </summary>
135135 /// <param name="file">The ScriptFile which will be analyzed for semantic markers.</param>
@@ -139,46 +139,17 @@ public ScriptFileMarker[] GetSemanticMarkers(ScriptFile file)
139139 return GetSemanticMarkers ( file , activeRules , settingsPath ) ;
140140 }
141141
142+ /// <summary>
143+ /// Perform semantic analysis on the given ScriptFile with the given settings.
144+ /// </summary>
145+ /// <param name="file">The ScriptFile to be analyzed.</param>
146+ /// <param name="settings">ScriptAnalyzer settings</param>
147+ /// <returns></returns>
142148 public ScriptFileMarker [ ] GetSemanticMarkers ( ScriptFile file , Hashtable settings )
143149 {
144150 return GetSemanticMarkers < Hashtable > ( file , null , settings ) ;
145151 }
146152
147- private ScriptFileMarker [ ] GetSemanticMarkers < TSettings > (
148- ScriptFile file ,
149- string [ ] rules ,
150- TSettings settings ) where TSettings : class
151- {
152- if ( this . scriptAnalyzerModuleInfo != null
153- && file . IsAnalysisEnabled
154- && ( typeof ( TSettings ) == typeof ( string ) || typeof ( TSettings ) == typeof ( Hashtable ) )
155- && ( rules != null || settings != null ) )
156- {
157- // TODO: This is a temporary fix until we can change how
158- // ScriptAnalyzer invokes their async tasks.
159- // TODO: Make this async
160- Task < ScriptFileMarker [ ] > analysisTask =
161- Task . Factory . StartNew < ScriptFileMarker [ ] > (
162- ( ) =>
163- {
164- return
165- GetDiagnosticRecords ( file , rules , settings )
166- . Select ( ScriptFileMarker . FromDiagnosticRecord )
167- . ToArray ( ) ;
168- } ,
169- CancellationToken . None ,
170- TaskCreationOptions . None ,
171- TaskScheduler . Default ) ;
172- analysisTask . Wait ( ) ;
173- return analysisTask . Result ;
174- }
175- else
176- {
177- // Return an empty marker list
178- return new ScriptFileMarker [ 0 ] ;
179- }
180- }
181-
182153 /// <summary>
183154 /// Returns a list of builtin-in PSScriptAnalyzer rules
184155 /// </summary>
@@ -220,6 +191,42 @@ public void Dispose()
220191 #endregion // public methods
221192
222193 #region Private Methods
194+
195+ private ScriptFileMarker [ ] GetSemanticMarkers < TSettings > (
196+ ScriptFile file ,
197+ string [ ] rules ,
198+ TSettings settings ) where TSettings : class
199+ {
200+ if ( this . scriptAnalyzerModuleInfo != null
201+ && file . IsAnalysisEnabled
202+ && ( typeof ( TSettings ) == typeof ( string ) || typeof ( TSettings ) == typeof ( Hashtable ) )
203+ && ( rules != null || settings != null ) )
204+ {
205+ // TODO: This is a temporary fix until we can change how
206+ // ScriptAnalyzer invokes their async tasks.
207+ // TODO: Make this async
208+ Task < ScriptFileMarker [ ] > analysisTask =
209+ Task . Factory . StartNew < ScriptFileMarker [ ] > (
210+ ( ) =>
211+ {
212+ return
213+ GetDiagnosticRecords ( file , rules , settings )
214+ . Select ( ScriptFileMarker . FromDiagnosticRecord )
215+ . ToArray ( ) ;
216+ } ,
217+ CancellationToken . None ,
218+ TaskCreationOptions . None ,
219+ TaskScheduler . Default ) ;
220+ analysisTask . Wait ( ) ;
221+ return analysisTask . Result ;
222+ }
223+ else
224+ {
225+ // Return an empty marker list
226+ return new ScriptFileMarker [ 0 ] ;
227+ }
228+ }
229+
223230 private void FindPSScriptAnalyzer ( )
224231 {
225232 lock ( runspaceLock )
0 commit comments