// dnlib: See LICENSE.txt for more info
using System.Collections.Generic;
namespace dnlib.DotNet.Pdb {
///
/// A constant in a method scope, eg. "const int SomeConstant = 123;"
///
public sealed class PdbConstant : IHasCustomDebugInformation {
string name;
TypeSig type;
object value;
///
/// Gets/sets the name
///
public string Name {
get => name;
set => name = value;
}
///
/// Gets/sets the type of the constant
///
public TypeSig Type {
get => type;
set => type = value;
}
///
/// Gets/sets the value of the constant
///
public object Value {
get => value;
set => this.value = value;
}
///
/// Constructor
///
public PdbConstant() {
}
///
/// Constructor
///
/// Name of constant
/// Type of constant
/// Constant value
public PdbConstant(string name, TypeSig type, object value) {
this.name = name;
this.type = type;
this.value = value;
}
///
public int HasCustomDebugInformationTag => 25;
///
public bool HasCustomDebugInfos => CustomDebugInfos.Count > 0;
///
/// Gets all custom debug infos
///
public IList CustomDebugInfos => customDebugInfos;
readonly IList customDebugInfos = new List();
///
/// ToString()
///
///
public override string ToString() {
var type = Type;
var value = Value;
string typeString = type is null ? "" : type.ToString();
string valueString = value is null ? "null" : $"{value} ({value.GetType().FullName})";
return$"{typeString} {Name} = {valueString}";
}
}
}