string IDkmClrFullNameProvider.GetClrCastExpression( DkmInspectionContext inspectionContext, string argument, DkmClrType type, DkmClrCustomTypeInfo customTypeInfo, DkmClrCastExpressionOptions castExpressionOptions ) { throw new NotImplementedException(); }
string IDkmClrFullNameProvider.GetClrCastExpression( DkmInspectionContext inspectionContext, string argument, DkmClrType type, DkmClrCustomTypeInfo customTypeInfo, DkmClrCastExpressionOptions castExpressionOptions ) { bool sawInvalidIdentifier; var name = GetTypeName( new TypeAndCustomInfo(type, customTypeInfo), escapeKeywordIdentifiers: true, sawInvalidIdentifier: out sawInvalidIdentifier ); if (sawInvalidIdentifier) { return(null); } return(GetCastExpression(argument, name, castExpressionOptions)); }
internal override string GetCastExpression( string argument, string type, DkmClrCastExpressionOptions options ) { Debug.Assert(!string.IsNullOrEmpty(argument)); Debug.Assert(!string.IsNullOrEmpty(type)); var pooled = PooledStringBuilder.GetInstance(); var builder = pooled.Builder; if ((options & DkmClrCastExpressionOptions.ParenthesizeEntireExpression) != 0) { builder.Append('('); } if ((options & DkmClrCastExpressionOptions.ParenthesizeArgument) != 0) { argument = $"({argument})"; } if ((options & DkmClrCastExpressionOptions.ConditionalCast) != 0) { builder.Append(argument); builder.Append(" as "); builder.Append(type); } else { builder.Append('('); builder.Append(type); builder.Append(')'); builder.Append(argument); } if ((options & DkmClrCastExpressionOptions.ParenthesizeEntireExpression) != 0) { builder.Append(')'); } return(pooled.ToStringAndFree()); }
internal abstract string GetCastExpression( string argument, string type, DkmClrCastExpressionOptions options );