public static TypeFormatterOptions ToTypeFormatterOptions(this DbgValueFormatterTypeOptions options) { var res = TypeFormatterOptions.None; if ((options & DbgValueFormatterTypeOptions.Decimal) != 0) { res |= TypeFormatterOptions.UseDecimal; } if ((options & DbgValueFormatterTypeOptions.DigitSeparators) != 0) { res |= TypeFormatterOptions.DigitSeparators; } if ((options & DbgValueFormatterTypeOptions.IntrinsicTypeKeywords) != 0) { res |= TypeFormatterOptions.IntrinsicTypeKeywords; } if ((options & DbgValueFormatterTypeOptions.Tokens) != 0) { res |= TypeFormatterOptions.Tokens; } if ((options & DbgValueFormatterTypeOptions.Namespaces) != 0) { res |= TypeFormatterOptions.Namespaces; } return(res); }
public override void FormatType(DbgEvaluationInfo evalInfo, IDbgTextWriter output, DmdType type, DbgDotNetValue?value, DbgValueFormatterTypeOptions options, CultureInfo?cultureInfo) => new CSharpTypeFormatter(output, options.ToTypeFormatterOptions(), cultureInfo).Format(type, value);
public override void FormatType(DbgEvaluationInfo evalInfo, IDbgTextWriter output, DbgEngineValue value, DbgValueFormatterTypeOptions options, CultureInfo cultureInfo) { }
/// <summary> /// Gets value formatter type options /// </summary> /// <param name="formatSpecifiers">Format specifiers or null</param> /// <param name="options">Default options</param> /// <returns></returns> public static DbgValueFormatterTypeOptions GetValueFormatterTypeOptions(ReadOnlyCollection <string>?formatSpecifiers, DbgValueFormatterTypeOptions options) { if (formatSpecifiers is not null) { for (int i = 0; i < formatSpecifiers.Count; i++) { switch (formatSpecifiers[i]) { case Decimal: options |= DbgValueFormatterTypeOptions.Decimal; break; case Hexadecimal: options &= ~DbgValueFormatterTypeOptions.Decimal; break; case DigitSeparators: options |= DbgValueFormatterTypeOptions.DigitSeparators; break; case NoDigitSeparators: options &= ~DbgValueFormatterTypeOptions.DigitSeparators; break; case Namespaces: options |= DbgValueFormatterTypeOptions.Namespaces; break; case NoNamespaces: options &= ~DbgValueFormatterTypeOptions.Namespaces; break; case Intrinsics: options |= DbgValueFormatterTypeOptions.IntrinsicTypeKeywords; break; case NoIntrinsics: options &= ~DbgValueFormatterTypeOptions.IntrinsicTypeKeywords; break; case Tokens: options |= DbgValueFormatterTypeOptions.Tokens; break; case NoTokens: options &= ~DbgValueFormatterTypeOptions.Tokens; break; } } } return(options); }
protected override void FormatReturnValueMethodName(DbgEvaluationInfo evalInfo, IDbgTextWriter output, DbgValueFormatterTypeOptions typeOptions, DbgValueFormatterOptions valueOptions, CultureInfo?cultureInfo, DmdMethodBase method, DmdPropertyInfo?property) { var typeFormatter = new Formatters.VisualBasic.VisualBasicTypeFormatter(output, typeOptions.ToTypeFormatterOptions(), null); typeFormatter.Format(method.DeclaringType !, null); var valueFormatter = new Formatters.VisualBasic.VisualBasicPrimitiveValueFormatter(output, valueOptions.ToValueFormatterOptions(), cultureInfo); output.Write(DbgTextColor.Operator, "."); if (!(property is null)) { output.Write(MemberUtils.GetColor(property), Formatters.VisualBasic.VisualBasicTypeFormatter.GetFormattedIdentifier(property.Name)); valueFormatter.WriteTokenComment(property.MetadataToken); output.Write(DbgTextColor.Operator, "."); output.Write(DbgTextColor.Keyword, "Get"); valueFormatter.WriteTokenComment(method.MetadataToken); }
public override bool FormatExpectedType(DbgEvaluationInfo evalInfo, ITextColorWriter output, DbgDotNetFormatter formatter, DbgValueFormatterTypeOptions options, DbgValueFormatterOptions valueOptions, CultureInfo cultureInfo) => columnFormatter?.FormatExpectedType(evalInfo, output, formatter, options, valueOptions, cultureInfo) ?? FormatDebuggerDisplayAttributeType(evalInfo, output, formatter, valueOptions, cultureInfo);
public virtual bool FormatActualType(DbgEvaluationInfo evalInfo, ITextColorWriter output, DbgDotNetFormatter formatter, DbgValueFormatterTypeOptions options, DbgValueFormatterOptions valueOptions, CultureInfo cultureInfo) => false;
protected override void FormatReturnValueMethodName(DbgEvaluationInfo evalInfo, IDbgTextWriter output, DbgValueFormatterTypeOptions typeOptions, DbgValueFormatterOptions valueOptions, CultureInfo cultureInfo, DmdMethodBase method, DmdPropertyInfo property) { var typeFormatter = new Formatters.CSharp.CSharpTypeFormatter(output, typeOptions.ToTypeFormatterOptions(), null); typeFormatter.Format(method.DeclaringType, null); var valueFormatter = new Formatters.CSharp.CSharpPrimitiveValueFormatter(output, valueOptions.ToValueFormatterOptions(), cultureInfo); output.Write(DbgTextColor.Operator, "."); if ((object)property != null) { if (property.GetIndexParameters().Count != 0) { output.Write(DbgTextColor.Keyword, Keyword_this); WriteMethodParameterList(output, method, typeFormatter, GetAllMethodParameterTypes(property.GetMethodSignature()), IndexerParenOpen, IndexerParenClose); } else { output.Write(MemberUtils.GetColor(property), Formatters.CSharp.CSharpTypeFormatter.GetFormattedIdentifier(property.Name)); } valueFormatter.WriteTokenComment(property.MetadataToken); output.Write(DbgTextColor.Operator, "."); output.Write(DbgTextColor.Keyword, "get"); valueFormatter.WriteTokenComment(method.MetadataToken); } else { var methodColor = TypeFormatterUtils.GetColor(method, canBeModule: false); if (TypeFormatterUtils.TryGetMethodName(method.Name, out var containingMethodName, out var localFunctionName)) { output.Write(methodColor, Formatters.CSharp.CSharpTypeFormatter.GetFormattedIdentifier(containingMethodName)); output.Write(DbgTextColor.Operator, "."); output.Write(methodColor, Formatters.CSharp.CSharpTypeFormatter.GetFormattedIdentifier(localFunctionName)); valueFormatter.WriteTokenComment(method.MetadataToken); WriteGenericMethodArguments(output, method, typeFormatter); }
public override void FormatType(DbgEvaluationInfo evalInfo, ITextColorWriter output, DmdType type, DbgDotNetValue value, DbgValueFormatterTypeOptions options, CultureInfo cultureInfo) => new VisualBasicTypeFormatter(output, options.ToTypeFormatterOptions(), cultureInfo).Format(type, value);
public override void FormatType(DbgEvaluationContext context, ITextColorWriter output, DbgEngineValue value, DbgValueFormatterTypeOptions options, CancellationToken cancellationToken) { }
public virtual bool FormatExpectedType(DbgEvaluationInfo evalInfo, IDbgTextWriter output, DbgDotNetFormatter formatter, DbgValueFormatterTypeOptions options, DbgValueFormatterOptions valueOptions, CultureInfo cultureInfo) => false;
public override void FormatType(DbgEvaluationContext context, ITextColorWriter output, DmdType type, DbgDotNetValue value, DbgValueFormatterTypeOptions options, CultureInfo cultureInfo) => new CSharpTypeFormatter(output, options.ToTypeFormatterOptions(), cultureInfo).Format(type, value);
/// <summary> /// Formats a type /// </summary> /// <param name="evalInfo">Evaluation info</param> /// <param name="output">Output</param> /// <param name="type">Type to format</param> /// <param name="value">Value or null</param> /// <param name="options">Options</param> /// <param name="cultureInfo">Culture or null to use invariant culture</param> public abstract void FormatType(DbgEvaluationInfo evalInfo, IDbgTextWriter output, DmdType type, DbgDotNetValue value, DbgValueFormatterTypeOptions options, CultureInfo cultureInfo);
/// <summary> /// Formats a value's type /// </summary> /// <param name="evalInfo">Evaluation info</param> /// <param name="output">Output</param> /// <param name="value">Value to format</param> /// <param name="options">Options</param> /// <param name="cultureInfo">Culture or null to use invariant culture</param> public abstract void FormatType(DbgEvaluationInfo evalInfo, IDbgTextWriter output, DbgEngineValue value, DbgValueFormatterTypeOptions options, CultureInfo?cultureInfo);
protected override void FormatReturnValueMethodName(DbgEvaluationInfo evalInfo, IDbgTextWriter output, DbgValueFormatterTypeOptions typeOptions, DbgValueFormatterOptions valueOptions, CultureInfo?cultureInfo, DmdMethodBase method, DmdPropertyInfo?property) { var typeFormatter = new Formatters.CSharp.CSharpTypeFormatter(output, typeOptions.ToTypeFormatterOptions(), null); typeFormatter.Format(method.DeclaringType !, null); var valueFormatter = new Formatters.CSharp.CSharpPrimitiveValueFormatter(output, valueOptions.ToValueFormatterOptions(), cultureInfo); output.Write(DbgTextColor.Operator, "."); if (!(property is null)) { if (property.GetIndexParameters().Count != 0) { output.Write(DbgTextColor.Keyword, Keyword_this); WriteMethodParameterList(output, method, typeFormatter, GetAllMethodParameterTypes(property.GetMethodSignature()), IndexerParenOpen, IndexerParenClose); } else { output.Write(MemberUtils.GetColor(property), Formatters.CSharp.CSharpTypeFormatter.GetFormattedIdentifier(property.Name)); } valueFormatter.WriteTokenComment(property.MetadataToken); output.Write(DbgTextColor.Operator, "."); output.Write(DbgTextColor.Keyword, "get"); valueFormatter.WriteTokenComment(method.MetadataToken); }
/// <summary> /// Formats the value's type. The thread is blocked until the type has been formatted /// </summary> /// <param name="context">Evaluation context</param> /// <param name="output">Output</param> /// <param name="value">Value to format</param> /// <param name="options">Options</param> /// <param name="cancellationToken">Cancellation token</param> public abstract void FormatType(DbgEvaluationContext context, ITextColorWriter output, DbgValue value, DbgValueFormatterTypeOptions options, CancellationToken cancellationToken = default);
protected override void FormatReturnValueMethodName(DbgEvaluationInfo evalInfo, IDbgTextWriter output, DbgValueFormatterTypeOptions typeOptions, DbgValueFormatterOptions valueOptions, CultureInfo cultureInfo, DmdMethodBase method, DmdPropertyInfo property) { var typeFormatter = new Formatters.VisualBasic.VisualBasicTypeFormatter(output, typeOptions.ToTypeFormatterOptions(), null); typeFormatter.Format(method.DeclaringType, null); var valueFormatter = new Formatters.VisualBasic.VisualBasicPrimitiveValueFormatter(output, valueOptions.ToValueFormatterOptions(), cultureInfo); output.Write(DbgTextColor.Operator, "."); if ((object)property != null) { output.Write(MemberUtils.GetColor(property), Formatters.VisualBasic.VisualBasicTypeFormatter.GetFormattedIdentifier(property.Name)); valueFormatter.WriteTokenComment(property.MetadataToken); output.Write(DbgTextColor.Operator, "."); output.Write(DbgTextColor.Keyword, "Get"); valueFormatter.WriteTokenComment(method.MetadataToken); } else { var operatorInfo = Formatters.VisualBasic.Operators.TryGetOperatorInfo(method.Name); if (operatorInfo != null && method is DmdMethodInfo methodInfo) { for (int i = 0; i < operatorInfo.Length; i++) { if (i > 0) { output.Write(DbgTextColor.Text, " "); } var s = operatorInfo[i]; output.Write('A' <= s[0] && s[0] <= 'Z' ? DbgTextColor.Keyword : DbgTextColor.Operator, s); } WriteGenericMethodArguments(output, method, typeFormatter); } else { output.Write(TypeFormatterUtils.GetColor(method, canBeModule: true), Formatters.VisualBasic.VisualBasicTypeFormatter.GetFormattedIdentifier(method.Name)); valueFormatter.WriteTokenComment(method.MetadataToken); WriteGenericMethodArguments(output, method, typeFormatter); } } }
/// <summary> /// Formats the value's type. The thread is blocked until the type has been formatted /// </summary> /// <param name="context">Evaluation context</param> /// <param name="output">Output</param> /// <param name="value">Value to format</param> /// <param name="options">Options</param> /// <param name="cultureInfo">Culture or null to use invariant culture</param> /// <param name="cancellationToken">Cancellation token</param> public abstract void FormatType(DbgEvaluationContext context, ITextColorWriter output, DbgEngineValue value, DbgValueFormatterTypeOptions options, CultureInfo cultureInfo, CancellationToken cancellationToken);
public override void FormatType(DbgEvaluationContext context, ITextColorWriter output, DbgEngineValue value, DbgValueFormatterTypeOptions options, CancellationToken cancellationToken) { //TODO: output.Write(BoxedTextColor.Error, "TODO:"); }
/// <summary> /// Formats a type /// </summary> /// <param name="context">Evaluation context</param> /// <param name="output">Output</param> /// <param name="type">Type to format</param> /// <param name="value">Value or null</param> /// <param name="options">Options</param> /// <param name="cultureInfo">Culture or null to use invariant culture</param> public abstract void FormatType(DbgEvaluationContext context, ITextColorWriter output, DmdType type, DbgDotNetValue value, DbgValueFormatterTypeOptions options, CultureInfo cultureInfo);
public override void FormatType(DbgEvaluationInfo evalInfo, IDbgTextWriter output, DbgValue value, DbgValueFormatterTypeOptions options, CultureInfo cultureInfo) { if (evalInfo == null) { throw new ArgumentNullException(nameof(evalInfo)); } if (!(evalInfo.Context is DbgEvaluationContextImpl)) { throw new ArgumentException(); } if (evalInfo.Context.Language != Language) { throw new ArgumentException(); } if (evalInfo.Context.Runtime.RuntimeKindGuid != runtimeKindGuid) { throw new ArgumentException(); } if (output == null) { throw new ArgumentNullException(nameof(output)); } if (value == null) { throw new ArgumentNullException(nameof(value)); } if (!(value is DbgValueImpl valueImpl)) { throw new ArgumentException(); } if (value.Runtime.RuntimeKindGuid != runtimeKindGuid) { throw new ArgumentException(); } try { engineFormatter.FormatType(evalInfo, output, valueImpl.EngineValue, options, cultureInfo); } catch (Exception ex) when(ExceptionUtils.IsInternalDebuggerError(ex)) { WriteError(output); } }
public override void FormatType(DbgEvaluationContext context, ITextColorWriter output, DbgValue value, DbgValueFormatterTypeOptions options, CultureInfo cultureInfo, CancellationToken cancellationToken) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (!(context is DbgEvaluationContextImpl)) { throw new ArgumentException(); } if (context.Language != Language) { throw new ArgumentException(); } if (context.Runtime.RuntimeKindGuid != runtimeKindGuid) { throw new ArgumentException(); } if (output == null) { throw new ArgumentNullException(nameof(output)); } if (value == null) { throw new ArgumentNullException(nameof(value)); } if (!(value is DbgValueImpl valueImpl)) { throw new ArgumentException(); } if (value.Runtime.RuntimeKindGuid != runtimeKindGuid) { throw new ArgumentException(); } engineValueFormatter.FormatType(context, output, valueImpl.EngineValue, options, cultureInfo, cancellationToken); }
/// <summary> /// Formats a value's type /// </summary> /// <param name="evalInfo">Evaluation info</param> /// <param name="output">Output</param> /// <param name="value">Value to format</param> /// <param name="options">Options</param> /// <param name="cultureInfo">Culture or null to use invariant culture</param> public abstract void FormatType(DbgEvaluationInfo evalInfo, ITextColorWriter output, DbgValue value, DbgValueFormatterTypeOptions options, CultureInfo cultureInfo);