public static bool TryGetAliasInfo(string aliasName, bool isCaseSensitive, out DbgDotNetParsedAlias aliasInfo) { if (aliasName != null) { var comparison = isCaseSensitive ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal; if (aliasName.Equals(ReturnValueName, comparison)) { aliasInfo = new DbgDotNetParsedAlias(DbgDotNetAliasKind.ReturnValue, DbgDotNetRuntimeConstants.LastReturnValueId); return(true); } if (aliasName.Equals(ExceptionName, comparison)) { aliasInfo = new DbgDotNetParsedAlias(DbgDotNetAliasKind.Exception, DbgDotNetRuntimeConstants.ExceptionId); return(true); } if (aliasName.Equals(StowedExceptionName, comparison)) { aliasInfo = new DbgDotNetParsedAlias(DbgDotNetAliasKind.StowedException, DbgDotNetRuntimeConstants.StowedExceptionId); return(true); } if (TryGetId(aliasName, ReturnValueName, comparison, out uint id) && id != DbgDotNetRuntimeConstants.LastReturnValueId) { aliasInfo = new DbgDotNetParsedAlias(DbgDotNetAliasKind.ReturnValue, id); return(true); } if (TryGetId(aliasName, ObjectIdName, comparison, out id)) { aliasInfo = new DbgDotNetParsedAlias(DbgDotNetAliasKind.ObjectId, id); return(true); } } aliasInfo = default; return(false); }
DbgDotNetValue IDebuggerRuntime.GetObjectByAlias(string name) { context.TryGetData(out DbgDotNetExpressionCompiler expressionCompiler); Debug.Assert(expressionCompiler != null); if (expressionCompiler == null) { throw new InvalidOperationException(); } if (!expressionCompiler.TryGetAliasInfo(name, out var aliasInfo)) { aliasInfo = new DbgDotNetParsedAlias(DbgDotNetAliasKind.Variable, 0); } DbgDotNetValue value; switch (aliasInfo.Kind) { case DbgDotNetAliasKind.Exception: case DbgDotNetAliasKind.StowedException: case DbgDotNetAliasKind.ReturnValue: // These can't be returned by this method break; case DbgDotNetAliasKind.Variable: //TODO: break; case DbgDotNetAliasKind.ObjectId: var objectId = dbgObjectIdService.GetObjectId(context.Runtime, aliasInfo.Id); if (objectId != null) { var dbgValue = objectId.GetValue(context, frame, cancellationToken); value = (DbgDotNetValue)dbgValue.InternalValue; return(RecordValue(value)); } break; default: throw new InvalidOperationException(); } throw new InterpreterMessageException(dnSpy_Debugger_DotNet_Resources.UnknownVariableOrObjectId); }