private void TraceTreeResult(
            EvaluationContext context,
            Object result,
            ValueKind kind)
        {
            // Get the realized expression
            String realizedExpression = ConvertToRealizedExpression(context);

            // Format the result
            String traceValue = ExpressionUtility.FormatValue(context.SecretMasker, result, kind);

            // Only trace the realized expression if it is meaningfully different
            if (!String.Equals(realizedExpression, traceValue, StringComparison.Ordinal))
            {
                if (kind == ValueKind.Number &&
                    String.Equals(realizedExpression, $"'{traceValue}'", StringComparison.Ordinal))
                {
                    // Don't bother tracing the realized expression when the result is a number and the
                    // realized expresion is a precisely matching string.
                }
                else
                {
                    context.Trace.Info($"Expanded: {realizedExpression}");
                }
            }

            // Always trace the result
            context.Trace.Info($"Result: {traceValue}");
        }
        internal void SetTraceResult(
            ExpressionNode node,
            EvaluationResult result)
        {
            // Remove if previously added. This typically should not happen. This could happen
            // due to a badly authored function. So we'll handle it and track memory correctly.
            if (m_traceResults.TryGetValue(node, out String oldValue))
            {
                m_traceMemory.Remove(oldValue);
                m_traceResults.Remove(node);
            }

            // Check max memory
            String value = ExpressionUtility.FormatValue(SecretMasker, result);

            if (m_traceMemory.TryAdd(value))
            {
                // Store the result
                m_traceResults[node] = value;
            }
        }
Пример #3
0
 internal sealed override String ConvertToRealizedExpression(EvaluationContext context)
 {
     return(ExpressionUtility.FormatValue(null, Value, Kind));
 }
Пример #4
0
 internal sealed override String ConvertToExpression()
 {
     return(ExpressionUtility.FormatValue(null, Value, Kind));
 }