/// <summary> /// Formats the value for display in the debugger, e.g. for the Value column in the Watch /// window. Mostly based on the Natvis <DisplayString> nodes. /// </summary> internal async Task <string> FormatDisplayStringAsync(IVariableInformation variable) { try { return(await FormatDisplayStringAsync( BuildFormatStringContext <DisplayStringType>( variable, e => new DisplayStringElement(e)), variable)); } catch (ExpressionEvaluationFailed ex) { _logger.Log(NatvisLoggingLevel.ERROR, $"Failed to format natvis display string. Reason: {ex.Message}."); return(await variable.ValueAsync()); } }
public static ErrorVariableInformation LogAndGetExpandChildrenValidationError( NatvisLoggingLevel loggingLevel, NatvisDiagnosticLogger logger, string visualizerName, string typeName, string errorCause) { string errMessage = $"(Natvis) Failed to expand {visualizerName} node for type " + $"'{typeName}'. Reason: {errorCause}."; logger.Log(loggingLevel, errMessage); return(new ErrorVariableInformation("<Error>", errMessage)); }
/// <summary> /// Writes a log to Trace and this.logger. /// </summary> void TraceWriteLine(NatvisLoggingLevel level, string message) { if (_logger.ShouldLog(level)) { _logger.Log(level, message); } else { string traceMsg = message; if (level == NatvisLoggingLevel.ERROR) { traceMsg = "ERROR: " + message; } Trace.WriteLine(traceMsg); } }