private void CheckResult()

in src/extensions/speech_extension/helpers/output_helper.cs [2132:2186]


        private void CheckResult()
        {
            var jmesValue = _values.GetOrDefault("check.result.jmes", null);
            if (jmesValue != null)
            {
                // default to a failed state to prevent false positives
                bool checkEval = false;

                // Match our detailed result.
                foreach (RecognitionResult result in _outputResultCache!)
                {
                    // TODO: add other result types
                    if (result.Reason == ResultReason.RecognizedSpeech || result.Reason == ResultReason.TranslatedSpeech ||
                        result.Reason == ResultReason.Canceled || result.Reason == ResultReason.NoMatch)
                    {
                        var jmes = new JmesPath();

                        var serviceResultJson = result.Properties.GetProperty(PropertyId.SpeechServiceResponse_JsonResult);
                        if(String.IsNullOrEmpty(serviceResultJson))
                        {
                            checkEval = false;
                            ColorHelpers.SetErrorColors();
                            Console.WriteLine();
                            Console.WriteLine($"Check result command specified, but no result json was returned from the service");
                            Console.WriteLine();
                            ColorHelpers.ResetColor();
                            break;
                        }

                        var jmesResult = jmes.Transform(serviceResultJson, jmesValue);

                        // If this is "false" they wrote an expression that returned "false"
                        // if this is "null" they wrote an expression looking for an item that doesn't exist.
                        if (String.Compare("null", jmesResult, true) == 0 ||
                            String.Compare(Boolean.FalseString, jmesResult, true) == 0)
                        {
                            checkEval = false;
                            ColorHelpers.SetErrorColors();
                            Console.WriteLine();
                            Console.WriteLine($"Check script: {jmesValue}");
                            Console.WriteLine($"JSON: {serviceResultJson}");
                            Console.WriteLine();
                            Console.WriteLine($"Check result: Failed");
                            ColorHelpers.ResetColor();
                        }
                        else
                        {
                            checkEval = true;
                            break; //is this problematic? Should we be checking all entries?
                        }
                    }
                }
                SetPassed(checkEval);
            }
        }