/*
Copyright (C) 2014-2019 de4dot@gmail.com
This file is part of dnSpy
dnSpy is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
dnSpy is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with dnSpy. If not, see .
*/
using System;
using System.Collections.Generic;
namespace dnSpy.Contracts.Debugger.Evaluation {
///
/// Creates s
///
public abstract class DbgObjectIdService {
///
/// Raised when one or more non-hidden s are created or removed
///
public abstract event EventHandler? ObjectIdsChanged;
///
/// Returns true if it's possible to create an object id
///
/// Value
/// Options
///
public abstract bool CanCreateObjectId(DbgValue value, CreateObjectIdOptions options = CreateObjectIdOptions.None);
///
/// Creates an object id or returns null
///
/// Value
/// Options
///
public DbgObjectId? CreateObjectId(DbgValue value, CreateObjectIdOptions options = CreateObjectIdOptions.None) =>
CreateObjectIds(new[] { value ?? throw new ArgumentNullException(nameof(value)) }, options)[0];
///
/// Creates object ids. The returned array will contain null elements if it wasn't possible to create object ids
///
/// Values
/// Options
///
public abstract DbgObjectId?[] CreateObjectIds(DbgValue[] values, CreateObjectIdOptions options = CreateObjectIdOptions.None);
///
/// Returns an non-hidden object id or null if there's none that references
///
/// Value
///
public abstract DbgObjectId? GetObjectId(DbgValue value);
///
/// Returns a non-hidden object id or null if there's none
///
/// Runtime
/// Object id
///
public abstract DbgObjectId? GetObjectId(DbgRuntime runtime, uint id);
///
/// Gets all non-hidden object ids
///
/// Runtime
///
public abstract DbgObjectId[] GetObjectIds(DbgRuntime runtime);
///
/// Removes and closes an object id
///
/// Object id to remove and close
public void Remove(DbgObjectId objectId) =>
Remove(new[] { objectId ?? throw new ArgumentNullException(nameof(objectId)) });
///
/// Removes and closes object ids
///
/// Object ids to remove and close
public abstract void Remove(IEnumerable objectIds);
///
/// Checks if an object id and a value refer to the same data
///
/// Object id
/// Value
///
public abstract bool Equals(DbgObjectId objectId, DbgValue value);
///
/// Gets the hash code of an object id
///
/// Object id
///
public abstract int GetHashCode(DbgObjectId objectId);
}
///
/// Object ID options
///
public enum CreateObjectIdOptions {
///
/// No bit is set
///
None = 0,
///
/// Hidden object Id. It's not shown in any of the variables windows.
///
Hidden = 0x00000001,
}
}