本文整理汇总了C#中Microsoft.VisualStudio.Debugger.Clr.DkmClrType类的典型用法代码示例。如果您正苦于以下问题:C# DkmClrType类的具体用法?C# DkmClrType怎么用?C# DkmClrType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DkmClrType类属于Microsoft.VisualStudio.Debugger.Clr命名空间,在下文中一共展示了DkmClrType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: foreach
void IDkmClrResultProvider.GetResult(DkmClrValue value, DkmWorkList workList, DkmClrType declaredType, DkmClrCustomTypeInfo declaredTypeInfo, DkmInspectionContext inspectionContext, ReadOnlyCollection<string> formatSpecifiers, string resultName, string resultFullName, DkmCompletionRoutine<DkmEvaluationAsyncResult> completionRoutine)
{
if (formatSpecifiers == null)
{
formatSpecifiers = Formatter.NoFormatSpecifiers;
}
if (resultFullName != null)
{
ReadOnlyCollection<string> otherSpecifiers;
resultFullName = FullNameProvider.GetClrExpressionAndFormatSpecifiers(inspectionContext, resultFullName, out otherSpecifiers);
foreach (var formatSpecifier in otherSpecifiers)
{
formatSpecifiers = Formatter.AddFormatSpecifier(formatSpecifiers, formatSpecifier);
}
}
var wl = new WorkList(workList, e => completionRoutine(DkmEvaluationAsyncResult.CreateErrorResult(e)));
wl.ContinueWith(
() => GetRootResultAndContinue(
value,
wl,
declaredType,
declaredTypeInfo,
inspectionContext,
resultName,
resultFullName,
formatSpecifiers,
result => wl.ContinueWith(() => completionRoutine(new DkmEvaluationAsyncResult(result)))));
}
示例2: CreateResultsOnlyRowIfSynthesizedEnumerable
/// <summary>
/// Generate a Results Only row if the value is a synthesized
/// value declared as IEnumerable or IEnumerable<T>.
/// </summary>
internal static EvalResultDataItem CreateResultsOnlyRowIfSynthesizedEnumerable(
DkmInspectionContext inspectionContext,
string name,
DkmClrType declaredType,
DkmClrCustomTypeInfo declaredTypeInfo,
DkmClrValue value,
Formatter formatter)
{
if ((value.ValueFlags & DkmClrValueFlags.Synthetic) == 0)
{
return null;
}
// Must be declared as IEnumerable or IEnumerable<T>, not a derived type.
var enumerableType = GetEnumerableType(value, declaredType, requireExactInterface: true);
if (enumerableType == null)
{
return null;
}
var expansion = CreateExpansion(inspectionContext, value, enumerableType, formatter);
if (expansion == null)
{
return null;
}
return expansion.CreateResultsViewRow(
inspectionContext,
name,
new TypeAndCustomInfo(declaredType.GetLmrType(), declaredTypeInfo),
value,
includeResultsFormatSpecifier: false,
formatter: formatter);
}
示例3: GetTypeName
string IDkmClrFullNameProvider.GetClrTypeName(DkmInspectionContext inspectionContext, DkmClrType clrType, DkmClrCustomTypeInfo customTypeInfo)
{
Debug.Assert(inspectionContext != null);
bool sawInvalidIdentifier;
var name = GetTypeName(new TypeAndCustomInfo(clrType, customTypeInfo), escapeKeywordIdentifiers: true, sawInvalidIdentifier: out sawInvalidIdentifier);
return sawInvalidIdentifier ? null : name;
}
示例4: DkmClrValue
internal DkmClrValue(
object value,
object hostObjectValue,
DkmClrType type,
string alias,
DkmEvaluationResultFlags evalFlags,
DkmClrValueFlags valueFlags,
DkmEvaluationResultCategory category = default(DkmEvaluationResultCategory),
DkmEvaluationResultAccessType access = default(DkmEvaluationResultAccessType),
ulong nativeComPointer = 0)
{
Debug.Assert((type == null) || !type.GetLmrType().IsTypeVariables() || (valueFlags == DkmClrValueFlags.Synthetic));
Debug.Assert((alias == null) || evalFlags.Includes(DkmEvaluationResultFlags.HasObjectId));
// The "real" DkmClrValue will always have a value of zero for null pointers.
Debug.Assert((type == null) || !type.GetLmrType().IsPointer || (value != null));
this.RawValue = value;
this.HostObjectValue = hostObjectValue;
this.Type = type;
this.Alias = alias;
this.EvalFlags = evalFlags;
this.ValueFlags = valueFlags;
this.Category = category;
this.Access = access;
this.NativeComPointer = nativeComPointer;
}
示例5: MultipleExpansions
public void MultipleExpansions()
{
var expression = "o";
dynamic o = new ExpandoObject();
o.Answer = 42;
var type = new DkmClrType((TypeImpl)o.GetType());
var value = CreateDkmClrValue((object)o, type);
// Dynamic View should appear after all other expansions.
var result = FormatResult(expression, value);
Verify(result,
EvalResult(expression, "{System.Dynamic.ExpandoObject}", "System.Dynamic.ExpandoObject", expression, DkmEvaluationResultFlags.Expandable));
Verify(GetChildren(result),
EvalResult("Class", "{System.Dynamic.ExpandoClass}", "System.Dynamic.ExpandoClass", "o.Class", DkmEvaluationResultFlags.Expandable | DkmEvaluationResultFlags.ReadOnly, DkmEvaluationResultCategory.Property, DkmEvaluationResultAccessType.Internal),
EvalResult("LockObject", "{object}", "object", "o.LockObject", DkmEvaluationResultFlags.ReadOnly, DkmEvaluationResultCategory.Data, DkmEvaluationResultAccessType.Internal),
EvalResult("System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<string, object>>.Count", "1", "int", "((System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<string, object>>)o).Count", DkmEvaluationResultFlags.ReadOnly, DkmEvaluationResultCategory.Property, DkmEvaluationResultAccessType.Private),
EvalResult("System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<string, object>>.IsReadOnly", "false", "bool", "((System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<string, object>>)o).IsReadOnly", DkmEvaluationResultFlags.Boolean | DkmEvaluationResultFlags.ReadOnly, DkmEvaluationResultCategory.Property, DkmEvaluationResultAccessType.Private),
EvalResult("System.Collections.Generic.IDictionary<string, object>.Keys", "Count = 1", "System.Collections.Generic.ICollection<string> {System.Dynamic.ExpandoObject.KeyCollection}", "((System.Collections.Generic.IDictionary<string, object>)o).Keys", DkmEvaluationResultFlags.Expandable | DkmEvaluationResultFlags.ReadOnly, DkmEvaluationResultCategory.Property, DkmEvaluationResultAccessType.Private),
EvalResult("System.Collections.Generic.IDictionary<string, object>.Values", "Count = 1", "System.Collections.Generic.ICollection<object> {System.Dynamic.ExpandoObject.ValueCollection}", "((System.Collections.Generic.IDictionary<string, object>)o).Values", DkmEvaluationResultFlags.Expandable | DkmEvaluationResultFlags.ReadOnly, DkmEvaluationResultCategory.Property, DkmEvaluationResultAccessType.Private),
EvalResult("_count", "1", "int", "o._count", category: DkmEvaluationResultCategory.Data, access: DkmEvaluationResultAccessType.Private),
EvalResult("_data", "{System.Dynamic.ExpandoObject.ExpandoData}", "System.Dynamic.ExpandoObject.ExpandoData", "o._data", DkmEvaluationResultFlags.Expandable, DkmEvaluationResultCategory.Data, DkmEvaluationResultAccessType.Private),
EvalResult("_propertyChanged", "null", "System.ComponentModel.PropertyChangedEventHandler", "o._propertyChanged", category: DkmEvaluationResultCategory.Data, access: DkmEvaluationResultAccessType.Private),
EvalResult(Resources.StaticMembers, null, "", "System.Dynamic.ExpandoObject", DkmEvaluationResultFlags.Expandable | DkmEvaluationResultFlags.ReadOnly, DkmEvaluationResultCategory.Class),
EvalResult(Resources.DynamicView, Resources.DynamicViewValueWarning, "", "o, dynamic", DkmEvaluationResultFlags.Expandable | DkmEvaluationResultFlags.ReadOnly, DkmEvaluationResultCategory.Method));
}
示例6: MakeGenericType
internal DkmClrType MakeGenericType(params DkmClrType[] genericArguments)
{
var type = new DkmClrType(
_module,
_appDomain,
_lmrType.MakeGenericType(genericArguments.Select(t => t._lmrType).ToArray()));
type._lazyGenericArguments = new ReadOnlyCollection<DkmClrType>(genericArguments);
return type;
}
示例7: GetCastExpression
string IDkmClrFullNameProvider.GetClrCastExpression(DkmInspectionContext inspectionContext, string argument, DkmClrType type, DkmClrCustomTypeInfo customTypeInfo, bool parenthesizeArgument, bool parenthesizeEntireExpression)
{
bool sawInvalidIdentifier;
var name = GetTypeName(new TypeAndCustomInfo(type, customTypeInfo), escapeKeywordIdentifiers: true, sawInvalidIdentifier: out sawInvalidIdentifier);
if (sawInvalidIdentifier)
{
return null;
}
return GetCastExpression(argument, name, parenthesizeArgument, parenthesizeEntireExpression);
}
示例8: GetResult
internal DkmEvaluationResult GetResult(DkmClrValue value, DkmClrType declaredType, ReadOnlyCollection<string> formatSpecifiers, string resultName, string resultFullName)
{
// TODO: Use full name
try
{
return GetRootResult(value, declaredType, resultName);
}
catch (Exception e) when (ExpressionEvaluatorFatalError.CrashIfFailFastEnabled(e))
{
throw ExceptionUtilities.Unreachable;
}
}
示例9: GetTypeName
public static string GetTypeName(this System.Type type, DkmClrCustomTypeInfo typeInfo, bool escapeKeywordIdentifiers = false, DkmInspectionContext inspectionContext = null)
{
var formatter = new CSharpFormatter();
var clrType = new DkmClrType((TypeImpl)type);
if (inspectionContext == null)
{
var inspectionSession = new DkmInspectionSession(ImmutableArray.Create<IDkmClrFormatter>(formatter), ImmutableArray.Create<IDkmClrResultProvider>(new CSharpResultProvider()));
inspectionContext = new DkmInspectionContext(inspectionSession, DkmEvaluationFlags.None, radix: 10, runtimeInstance: null);
}
return escapeKeywordIdentifiers ?
((IDkmClrFullNameProvider)formatter).GetClrTypeName(inspectionContext, clrType, typeInfo) :
inspectionContext.GetTypeName(clrType, typeInfo, Formatter.NoFormatSpecifiers);
}
示例10: WorkList
void IDkmClrResultProvider.GetResult(DkmClrValue value, DkmWorkList workList, DkmClrType declaredType, DkmClrCustomTypeInfo declaredTypeInfo, DkmInspectionContext inspectionContext, ReadOnlyCollection<string> formatSpecifiers, string resultName, string resultFullName, DkmCompletionRoutine<DkmEvaluationAsyncResult> completionRoutine)
{
// TODO: Use full name
var wl = new WorkList(workList, e => completionRoutine(DkmEvaluationAsyncResult.CreateErrorResult(e)));
GetRootResultAndContinue(
value,
wl,
declaredType,
declaredTypeInfo,
inspectionContext,
resultName,
result => wl.ContinueWith(() => completionRoutine(new DkmEvaluationAsyncResult(result))));
wl.Execute();
}
示例11: CreateResultsOnlyRow
internal static EvalResult CreateResultsOnlyRow(
DkmInspectionContext inspectionContext,
string name,
string fullName,
ReadOnlyCollection<string> formatSpecifiers,
DkmClrType declaredType,
DkmClrCustomTypeInfo declaredTypeInfo,
DkmClrValue value,
ResultProvider resultProvider)
{
string errorMessage;
if (value.IsError())
{
errorMessage = (string)value.HostObjectValue;
}
else if (value.HasExceptionThrown())
{
errorMessage = value.GetExceptionMessage(inspectionContext, name);
}
else
{
var enumerableType = GetEnumerableType(value);
if (enumerableType != null)
{
var expansion = CreateExpansion(inspectionContext, value, enumerableType, resultProvider);
if (expansion != null)
{
return expansion.CreateResultsViewRow(
inspectionContext,
name,
fullName,
formatSpecifiers,
new TypeAndCustomInfo(declaredType, declaredTypeInfo),
value,
includeResultsFormatSpecifier: true,
fullNameProvider: resultProvider.FullNameProvider);
}
errorMessage = Resources.ResultsViewNoSystemCore;
}
else
{
errorMessage = Resources.ResultsViewNotEnumerable;
}
}
Debug.Assert(errorMessage != null);
return new EvalResult(name, errorMessage, inspectionContext);
}
示例12: CreateResultsOnly
internal static DkmEvaluationResult CreateResultsOnly(
string name,
DkmClrType declaredType,
DkmClrValue value,
EvalResultDataItem parent,
Formatter formatter)
{
string errorMessage;
if (value.IsError())
{
errorMessage = (string)value.HostObjectValue;
}
else if (value.HasExceptionThrown(parent))
{
errorMessage = value.GetExceptionMessage(name, formatter);
}
else
{
var enumerableType = GetEnumerableType(value);
if (enumerableType != null)
{
var expansion = CreateExpansion(value, enumerableType, formatter);
if (expansion != null)
{
return expansion.CreateEvaluationResult(name, parent, formatter);
}
errorMessage = Resources.ResultsViewNoSystemCore;
}
else
{
errorMessage = Resources.ResultsViewNotEnumerable;
}
}
Debug.Assert(errorMessage != null);
return DkmFailedEvaluationResult.Create(
InspectionContext: value.InspectionContext,
StackFrame: value.StackFrame,
Name: name,
FullName: null,
ErrorMessage: errorMessage,
Flags: DkmEvaluationResultFlags.None,
Type: null,
DataItem: null);
}
示例13: GetType
internal DkmClrType GetType(string typeName, params System.Type[] typeArguments)
{
foreach (var module in this.Modules)
{
var assembly = module.Assembly;
var type = assembly.GetType(typeName);
if (type != null)
{
var result = new DkmClrType(module, _appDomain, (TypeImpl)type);
if (typeArguments.Length > 0)
{
result = result.MakeGenericType(typeArguments.Select(this.GetType).ToArray());
}
return result;
}
}
return null;
}
示例14: ExceptionTypeMember
public void ExceptionTypeMember()
{
var expression = "o";
dynamic o = new ExpandoObject();
var exception = new NotImplementedException();
o.Member = exception;
var type = new DkmClrType((TypeImpl)o.GetType());
var value = CreateDkmClrValue((object)o, type);
var result = FormatResult(expression, value);
Verify(result,
EvalResult(expression, "{System.Dynamic.ExpandoObject}", "System.Dynamic.ExpandoObject", expression, DkmEvaluationResultFlags.Expandable));
var dynamicView = GetChildren(result).Last();
Verify(dynamicView,
EvalResult(Resources.DynamicView, Resources.DynamicViewValueWarning, "", "o, dynamic", DkmEvaluationResultFlags.Expandable | DkmEvaluationResultFlags.ReadOnly));
Verify(GetChildren(dynamicView),
EvalResult("Member", $"{{{exception.ToString()}}}", "System.NotImplementedException", "new Microsoft.CSharp.RuntimeBinder.DynamicMetaObjectProviderDebugView(o).Items[0]", DkmEvaluationResultFlags.ReadOnly));
}
示例15:
/// <summary>
/// This method is called by the debug engine to populate the text representing the type of
/// a result.
/// </summary>
/// <param name="inspectionContext">Context of the evaluation. This contains options/flags
/// to be used during compilation. It also contains the InspectionSession. The inspection
/// session is the object that provides lifetime management for our objects. When the user
/// steps or continues the process, the debug engine will dispose of the inspection session</param>
/// <param name="clrType">This is the raw type we want to format</param>
/// <param name="customTypeInfo">If Expression Compiler passed any additional information
/// about the type that doesn't exist in metadata, this parameter contais that information.</param>
/// <param name="formatSpecifiers">A list of custom format specifiers that the debugger did
/// not understand. If you want special format specifiers for your language, handle them
/// here. The formatter should ignore any format specifiers it does not understand.</param>
/// <returns>The text of the type name to display</returns>
string IDkmClrFormatter.GetTypeName(
DkmInspectionContext inspectionContext,
DkmClrType clrType,
DkmClrCustomTypeInfo customTypeInfo,
ReadOnlyCollection<string> formatSpecifiers)
{
// Get the LMR type for the DkmClrType. LMR Types (Microsoft.VisualStudio.Debugger.Metadata.Type)
// are similar to System.Type, but represent types that live in the process being debugged.
Type lmrType = clrType.GetLmrType();
IrisType irisType = Utility.GetIrisTypeForLmrType(lmrType);
if (irisType == IrisType.Invalid)
{
// We don't know about this type. Delegate to the C# Formatter to format the
// type name.
return inspectionContext.GetTypeName(clrType, customTypeInfo, formatSpecifiers);
}
return irisType.ToString();
}