コード例 #1
0
        private async Task <ScriptFileMarker[]> GetSemanticMarkersFromCommandAsync(PSCommand command, Runspace runspace)
        {
            PowerShellResult result = await InvokePowerShellAsync(command, runspace).ConfigureAwait(false);

            IReadOnlyCollection <PSObject> diagnosticResults = result?.Output ?? s_emptyDiagnosticResult;

            _logger.LogDebug(String.Format("Found {0} violations", diagnosticResults.Count));

            var scriptMarkers = new ScriptFileMarker[diagnosticResults.Count];
            int i             = 0;

            foreach (PSObject diagnostic in diagnosticResults)
            {
                // scriptMarkers[i] = ScriptFileMarker.FromDiagnosticRecord(diagnostic);
                scriptMarkers[i] = ScriptFileMarker.FromUpgradePlan(diagnostic);
                if (scriptMarkers[i].RuleName != "ReadyToUpgradeCmdletParameter")
                {
                    i++;
                }
            }

            Array.Resize(ref scriptMarkers, i);

            return(scriptMarkers);
        }
コード例 #2
0
        private async Task <ScriptFileMarker[]> GetSemanticMarkersFromCommandAsync(PSCommand command)
        {
            PowerShellResult result = await InvokePowerShellAsync(command).ConfigureAwait(false);

            IReadOnlyCollection <PSObject> diagnosticResults = result?.Output ?? s_emptyDiagnosticResult;

            _logger.LogDebug(String.Format("Found {0} violations", diagnosticResults.Count));

            var scriptMarkers = new ScriptFileMarker[diagnosticResults.Count];
            int i             = 0;

            foreach (PSObject diagnostic in diagnosticResults)
            {
                // scriptMarkers[i] = ScriptFileMarker.FromDiagnosticRecord(diagnostic);
                scriptMarkers[i] = ScriptFileMarker.FromUpgradePlan(diagnostic);
                i++;
            }

            return(scriptMarkers);
        }