/// <summary> /// Get comment help text for a PowerShell function definition. /// </summary> /// <param name="functionText">The text of the function to get comment help for.</param> /// <param name="helpLocation">A string referring to which location comment help should be placed around the function.</param> /// <param name="forBlockComment">If true, block comment help will be supplied.</param> /// <returns></returns> public async Task <string> GetCommentHelpText(string functionText, string helpLocation, bool forBlockComment) { if (AnalysisEngine == null) { return(null); } Hashtable commentHelpSettings = AnalysisService.GetCommentHelpRuleSettings(helpLocation, forBlockComment); ScriptFileMarker[] analysisResults = await AnalysisEngine.AnalyzeScriptAsync(functionText, commentHelpSettings).ConfigureAwait(false); if (analysisResults.Length == 0 || !analysisResults[0].Corrections.Any()) { return(null); } return(analysisResults[0].Corrections.First().Edit.Text); }
/// <summary> /// Get comment help text for a PowerShell function definition. /// </summary> /// <param name="functionText">The text of the function to get comment help for.</param> /// <param name="helpLocation">A string referring to which location comment help should be placed around the function.</param> /// <param name="forBlockComment">If true, block comment help will be supplied.</param> /// <returns></returns> public async Task <string> GetCommentHelpText(string functionText, string helpLocation, bool forBlockComment) { if (AnalysisEngine == null) { return(null); } Hashtable commentHelpSettings = AnalysisService.GetCommentHelpRuleSettings(helpLocation, forBlockComment); ScriptFileMarker[] analysisResults = await AnalysisEngine.AnalyzeScriptAsync(powerShell.Runspace, _azureRmVersion, _azVersion, functionText, commentHelpSettings).ConfigureAwait(false); if (analysisResults.Length == 0 || analysisResults[0]?.Correction?.Edits == null || analysisResults[0].Correction.Edits.Count() == 0) { return(null); } return(analysisResults[0].Correction.Edits[0].Text); }