本文整理汇总了C#中Mono.Debugging.Evaluation.EvaluationContext.WriteDebuggerError方法的典型用法代码示例。如果您正苦于以下问题:C# EvaluationContext.WriteDebuggerError方法的具体用法?C# EvaluationContext.WriteDebuggerError怎么用?C# EvaluationContext.WriteDebuggerError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.Debugging.Evaluation.EvaluationContext
的用法示例。
在下文中一共展示了EvaluationContext.WriteDebuggerError方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateObjectValue
public ObjectValue CreateObjectValue (EvaluationContext ctx, IObjectValueSource source, ObjectPath path, object obj, ObjectValueFlags flags)
{
try {
return CreateObjectValueImpl (ctx, source, path, obj, flags);
} catch (Exception ex) {
ctx.WriteDebuggerError (ex);
return ObjectValue.CreateFatalError (path.LastName, ex.Message, flags);
}
}
示例2: GetTypeDisplayData
public TypeDisplayData GetTypeDisplayData (EvaluationContext ctx, object type)
{
if (!IsClass (type))
return TypeDisplayData.Default;
TypeDisplayData td;
string tname = GetTypeName (ctx, type);
if (typeDisplayData.TryGetValue (tname, out td))
return td;
try {
td = OnGetTypeDisplayData (ctx, type);
}
catch (Exception ex) {
ctx.WriteDebuggerError (ex);
}
if (td == null)
typeDisplayData[tname] = td = TypeDisplayData.Default;
else
typeDisplayData[tname] = td;
return td;
}
示例3: GetProxyObject
public object GetProxyObject (EvaluationContext ctx, object obj)
{
TypeDisplayData data = GetTypeDisplayData (ctx, GetValueType (ctx, obj));
if (string.IsNullOrEmpty (data.ProxyType) || !ctx.Options.AllowDebuggerProxy)
return obj;
object[] typeArgs = null;
int i = data.ProxyType.IndexOf ('`');
if (i != -1) {
// The proxy type is an uninstantiated generic type.
// The number of type args of the proxy must match the args of the target object
int j = i + 1;
for (; j < data.ProxyType.Length && char.IsDigit (data.ProxyType[j]); j++);
int np = int.Parse (data.ProxyType.Substring (i + 1, j - i - 1));
typeArgs = GetTypeArgs (ctx, GetValueType (ctx, obj));
if (typeArgs.Length != np)
return obj;
}
object ttype = GetType (ctx, data.ProxyType, typeArgs);
if (ttype == null) {
i = data.ProxyType.IndexOf (',');
if (i != -1)
ttype = GetType (ctx, data.ProxyType.Substring (0, i).Trim (), typeArgs);
}
if (ttype == null)
throw new EvaluatorException ("Unknown type '{0}'", data.ProxyType);
try {
object val = CreateValue (ctx, ttype, obj);
return val ?? obj;
} catch (Exception ex) {
ctx.WriteDebuggerError (ex);
return obj;
}
}
示例4: GetExpressionCompletionData
public virtual CompletionData GetExpressionCompletionData (EvaluationContext ctx, string exp)
{
int i;
if (exp.Length == 0)
return null;
if (exp [exp.Length - 1] == '.') {
exp = exp.Substring (0, exp.Length - 1);
i = 0;
while (i < exp.Length) {
ValueReference vr = null;
try {
vr = ctx.Evaluator.Evaluate (ctx, exp.Substring (i), null);
if (vr != null) {
CompletionData data = new CompletionData ();
foreach (ValueReference cv in vr.GetChildReferences (ctx.Options))
data.Items.Add (new CompletionItem (cv.Name, cv.Flags));
data.ExpressionLenght = 0;
return data;
}
} catch (Exception ex) {
ctx.WriteDebuggerError (ex);
}
i++;
}
return null;
}
i = exp.Length - 1;
bool lastWastLetter = false;
while (i >= 0) {
char c = exp [i--];
if (!char.IsLetterOrDigit (c) && c != '_')
break;
lastWastLetter = !char.IsDigit (c);
}
if (lastWastLetter) {
string partialWord = exp.Substring (i+1);
CompletionData data = new CompletionData ();
data.ExpressionLenght = partialWord.Length;
// Local variables
foreach (ValueReference vc in GetLocalVariables (ctx))
if (vc.Name.StartsWith (partialWord))
data.Items.Add (new CompletionItem (vc.Name, vc.Flags));
// Parameters
foreach (ValueReference vc in GetParameters (ctx))
if (vc.Name.StartsWith (partialWord))
data.Items.Add (new CompletionItem (vc.Name, vc.Flags));
// Members
ValueReference thisobj = GetThisReference (ctx);
if (thisobj != null)
data.Items.Add (new CompletionItem ("this", ObjectValueFlags.Field | ObjectValueFlags.ReadOnly));
object type = GetEnclosingType (ctx);
foreach (ValueReference vc in GetMembers (ctx, null, type, thisobj != null ? thisobj.Value : null))
if (vc.Name.StartsWith (partialWord))
data.Items.Add (new CompletionItem (vc.Name, vc.Flags));
if (data.Items.Count > 0)
return data;
}
return null;
}
示例5: GetObjectValueChildren
public virtual ObjectValue[] GetObjectValueChildren (EvaluationContext ctx, IObjectSource objectSource, object type, object obj, int firstItemIndex, int count, bool dereferenceProxy)
{
if (obj is EvaluationResult)
return new ObjectValue[0];
if (IsArray (ctx, obj)) {
ArrayElementGroup agroup = new ArrayElementGroup (ctx, CreateArrayAdaptor (ctx, obj));
return agroup.GetChildren (ctx.Options);
}
if (IsPrimitive (ctx, obj))
return new ObjectValue[0];
bool showRawView = false;
// If there is a proxy, it has to show the members of the proxy
object proxy = obj;
if (dereferenceProxy) {
proxy = GetProxyObject (ctx, obj);
if (proxy != obj) {
type = GetValueType (ctx, proxy);
showRawView = true;
}
}
TypeDisplayData tdata = GetTypeDisplayData (ctx, type);
bool groupPrivateMembers = ctx.Options.GroupPrivateMembers && (ctx.Options.GroupUserPrivateMembers || IsExternalType (ctx, type));
List<ObjectValue> values = new List<ObjectValue> ();
BindingFlags flattenFlag = ctx.Options.FlattenHierarchy ? (BindingFlags)0 : BindingFlags.DeclaredOnly;
BindingFlags nonNonPublicFlag = groupPrivateMembers || showRawView ? (BindingFlags)0 : BindingFlags.NonPublic;
BindingFlags staticFlag = ctx.Options.GroupStaticMembers ? (BindingFlags)0 : BindingFlags.Static;
BindingFlags access = BindingFlags.Public | BindingFlags.Instance | flattenFlag | nonNonPublicFlag | staticFlag;
// Load all members to a list before creating the object values,
// to avoid problems with objects being invalidated due to evaluations in the target,
List<ValueReference> list = new List<ValueReference> ();
list.AddRange (GetMembersSorted (ctx, objectSource, type, proxy, access));
var names = new ObjectValueNameTracker (ctx);
object tdataType = type;
foreach (ValueReference val in list) {
try {
object decType = val.DeclaringType;
if (decType != null && decType != tdataType) {
tdataType = decType;
tdata = GetTypeDisplayData (ctx, decType);
}
DebuggerBrowsableState state = tdata.GetMemberBrowsableState (val.Name);
if (state == DebuggerBrowsableState.Never)
continue;
if (state == DebuggerBrowsableState.RootHidden && dereferenceProxy) {
object ob = val.Value;
if (ob != null) {
values.Clear ();
values.AddRange (GetObjectValueChildren (ctx, val, ob, -1, -1));
showRawView = true;
break;
}
}
else {
ObjectValue oval = val.CreateObjectValue (true);
names.Disambiguate (val, oval);
values.Add (oval);
}
}
catch (Exception ex) {
ctx.WriteDebuggerError (ex);
values.Add (ObjectValue.CreateError (null, new ObjectPath (val.Name), GetDisplayTypeName (GetTypeName (ctx, val.Type)), ex.Message, val.Flags));
}
}
if (showRawView) {
values.Add (RawViewSource.CreateRawView (ctx, objectSource, obj));
}
else {
if (IsArray (ctx, proxy)) {
ICollectionAdaptor col = CreateArrayAdaptor (ctx, proxy);
ArrayElementGroup agroup = new ArrayElementGroup (ctx, col);
ObjectValue val = ObjectValue.CreateObject (null, new ObjectPath ("Raw View"), "", "", ObjectValueFlags.ReadOnly, values.ToArray ());
values = new List<ObjectValue> ();
values.Add (val);
values.AddRange (agroup.GetChildren (ctx.Options));
}
else {
if (ctx.Options.GroupStaticMembers && HasMembers (ctx, type, proxy, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | flattenFlag)) {
access = BindingFlags.Static | BindingFlags.Public | flattenFlag | nonNonPublicFlag;
values.Add (FilteredMembersSource.CreateStaticsNode (ctx, objectSource, type, proxy, access));
}
if (groupPrivateMembers && HasMembers (ctx, type, proxy, BindingFlags.Instance | BindingFlags.NonPublic | flattenFlag | staticFlag))
values.Add (FilteredMembersSource.CreateNonPublicsNode (ctx, objectSource, type, proxy, BindingFlags.Instance | BindingFlags.NonPublic | flattenFlag | staticFlag));
if (!ctx.Options.FlattenHierarchy) {
object baseType = GetBaseType (ctx, type, false);
if (baseType != null)
values.Insert (0, BaseTypeViewSource.CreateBaseTypeView (ctx, objectSource, baseType, proxy));
}
}
//.........这里部分代码省略.........
示例6: GetExpressionValue
public ObjectValue GetExpressionValue (EvaluationContext ctx, string exp)
{
try {
ValueReference var = ctx.Evaluator.Evaluate (ctx, exp);
if (var != null) {
return var.CreateObjectValue (ctx.Options);
}
else
return ObjectValue.CreateUnknown (exp);
}
catch (ImplicitEvaluationDisabledException) {
return ObjectValue.CreateImplicitNotSupported (ctx.ExpressionValueSource, new ObjectPath (exp), "", ObjectValueFlags.None);
}
catch (NotSupportedExpressionException ex) {
return ObjectValue.CreateNotSupported (ctx.ExpressionValueSource, new ObjectPath (exp), ex.Message, "", ObjectValueFlags.None);
}
catch (EvaluatorException ex) {
return ObjectValue.CreateError (ctx.ExpressionValueSource, new ObjectPath (exp), "", ex.Message, ObjectValueFlags.None);
}
catch (Exception ex) {
ctx.WriteDebuggerError (ex);
return ObjectValue.CreateUnknown (exp);
}
}
示例7: ObjectValueHasChildren
public virtual bool ObjectValueHasChildren (EvaluationContext ctx, IObjectSource objectSource, object type, object obj, bool dereferenceProxy)
{
if (obj is EvaluationResult)
return false;
if (IsArray (ctx, obj))
return true;
if (IsPrimitive (ctx, obj))
return false;
bool showRawView = false;
// If there is a proxy, it has to show the members of the proxy
object proxy = obj;
if (dereferenceProxy) {
proxy = GetProxyObject (ctx, obj);
if (proxy != obj) {
type = GetValueType (ctx, proxy);
showRawView = true;
}
}
TypeDisplayData tdata = GetTypeDisplayData (ctx, type);
bool groupPrivateMembers = ctx.Options.GroupPrivateMembers && (ctx.Options.GroupUserPrivateMembers || IsExternalType (ctx, type));
BindingFlags flattenFlag = ctx.Options.FlattenHierarchy ? (BindingFlags)0 : BindingFlags.DeclaredOnly;
BindingFlags nonNonPublicFlag = groupPrivateMembers || showRawView ? (BindingFlags)0 : BindingFlags.NonPublic;
BindingFlags staticFlag = ctx.Options.GroupStaticMembers ? (BindingFlags)0 : BindingFlags.Static;
BindingFlags access = BindingFlags.Public | BindingFlags.Instance | flattenFlag | nonNonPublicFlag | staticFlag;
// Load all members to a list before creating the object values,
// to avoid problems with objects being invalidated due to evaluations in the target,
List<ValueReference> list = new List<ValueReference> ();
list.AddRange (GetMembersSorted (ctx, objectSource, type, proxy, access));
object tdataType = type;
foreach (ValueReference val in list) {
try {
object decType = val.DeclaringType;
if (decType != null && decType != tdataType) {
tdataType = decType;
tdata = GetTypeDisplayData (ctx, decType);
}
DebuggerBrowsableState state = tdata.GetMemberBrowsableState (val.Name);
if (state == DebuggerBrowsableState.Never)
continue;
return true;
} catch (Exception ex) {
ctx.WriteDebuggerError (ex);
}
}
if (IsArray (ctx, proxy))
return true;
if (ctx.Options.GroupStaticMembers && HasMembers (ctx, type, proxy, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | flattenFlag))
return true;
if (groupPrivateMembers && HasMembers (ctx, type, proxy, BindingFlags.Instance | BindingFlags.NonPublic | flattenFlag | staticFlag))
return true;
if (!ctx.Options.FlattenHierarchy) {
object baseType = GetBaseType (ctx, type, false);
if (baseType != null)
return true;
}
return false;
}
示例8: GetProxyObject
public object GetProxyObject(EvaluationContext ctx, object obj)
{
TypeDisplayData data = GetTypeDisplayData (ctx, GetValueType (ctx, obj));
if (string.IsNullOrEmpty (data.ProxyType) || !ctx.Options.AllowDebuggerProxy)
return obj;
string proxyType = data.ProxyType;
object[] typeArgs = null;
int index = proxyType.IndexOf ('`');
if (index != -1) {
// The proxy type is an uninstantiated generic type.
// The number of type args of the proxy must match the args of the target object
int startIndex = index + 1;
int endIndex = index + 1;
while (endIndex < proxyType.Length && char.IsDigit (proxyType[endIndex]))
endIndex++;
var attrType = GetType (ctx, "System.Diagnostics.DebuggerTypeProxyAttribute");
int num = int.Parse (proxyType.Substring (startIndex, endIndex - startIndex));
var proxiedType = GetBaseTypeWithAttribute (ctx, GetValueType (ctx, obj), attrType);
if (proxiedType == null || !IsGenericType (ctx, proxiedType))
return obj;
typeArgs = GetTypeArgs (ctx, proxiedType);
if (typeArgs.Length != num)
return obj;
if (endIndex < proxyType.Length) {
// chop off the []'d list of generic type arguments
proxyType = proxyType.Substring (0, endIndex);
}
}
object ttype = GetType (ctx, proxyType, typeArgs);
if (ttype == null) {
// the proxy type string might be in the form: "Namespace.TypeName, Assembly...", chop off the ", Assembly..." bit.
if ((index = proxyType.IndexOf (',')) != -1)
ttype = GetType (ctx, proxyType.Substring (0, index).Trim (), typeArgs);
}
if (ttype == null)
throw new EvaluatorException ("Unknown type '{0}'", data.ProxyType);
try {
object val = CreateValue (ctx, ttype, obj);
return val ?? obj;
} catch (EvaluatorException) {
// probably couldn't find the .ctor for the proxy type because the linker stripped it out
return obj;
} catch (Exception ex) {
ctx.WriteDebuggerError (ex);
return obj;
}
}
示例9: GetExpressionCompletionData
public virtual CompletionData GetExpressionCompletionData(EvaluationContext ctx, string expr)
{
if (string.IsNullOrEmpty (expr))
return null;
if (expr[expr.Length - 1] == '.') {
try {
var vr = ctx.Evaluator.Evaluate (ctx, expr.Substring (0, expr.Length - 1), null);
if (vr != null)
return GetMemberCompletionData (ctx, vr);
// FIXME: handle types and namespaces...
} catch (Exception ex) {
ctx.WriteDebuggerError (ex);
}
return null;
}
bool lastWastLetter = false;
int i = expr.Length - 1;
while (i >= 0) {
char c = expr[i--];
if (!char.IsLetterOrDigit (c) && c != '_')
break;
lastWastLetter = !char.IsDigit (c);
}
if (lastWastLetter) {
string partialWord = expr.Substring (i+1);
CompletionData data = new CompletionData ();
data.ExpressionLength = partialWord.Length;
// Local variables
foreach (ValueReference vc in GetLocalVariables (ctx))
if (vc.Name.StartsWith (partialWord, StringComparison.InvariantCulture))
data.Items.Add (new CompletionItem (vc.Name, vc.Flags));
// Parameters
foreach (ValueReference vc in GetParameters (ctx))
if (vc.Name.StartsWith (partialWord, StringComparison.InvariantCulture))
data.Items.Add (new CompletionItem (vc.Name, vc.Flags));
// Members
ValueReference thisobj = GetThisReference (ctx);
if (thisobj != null)
data.Items.Add (new CompletionItem ("this", ObjectValueFlags.Field | ObjectValueFlags.ReadOnly));
object type = GetEnclosingType (ctx);
foreach (ValueReference vc in GetMembers (ctx, null, type, thisobj != null ? thisobj.Value : null))
if (vc.Name.StartsWith (partialWord, StringComparison.InvariantCulture))
data.Items.Add (new CompletionItem (vc.Name, vc.Flags));
if (data.Items.Count > 0)
return data;
}
return null;
}