// dnlib: See LICENSE.txt for more info
using System;
using System.Diagnostics;
namespace dnlib.DotNet {
///
/// Contains the name and ordinal of a method that gets exported to unmanaged code.
///
[DebuggerDisplay("{Ordinal} {Name} {Options}")]
public sealed class MethodExportInfo {
MethodExportInfoOptions options;
ushort? ordinal;
string name;
const MethodExportInfoOptions DefaultOptions = MethodExportInfoOptions.FromUnmanaged;
///
/// Gets the ordinal or null
///
public ushort? Ordinal {
get => ordinal;
set => ordinal = value;
}
///
/// Gets the name. If it's null, and is also null, the name of the method
/// () is used as the exported name.
///
public string Name {
get => name;
set => name = value;
}
///
/// Gets the options
///
public MethodExportInfoOptions Options {
get => options;
set => options = value;
}
///
/// Constructor
///
public MethodExportInfo() => options = DefaultOptions;
///
/// Constructor
///
/// Name or null to export by ordinal
public MethodExportInfo(string name) {
options = DefaultOptions;
this.name = name;
}
///
/// Constructor
///
/// Ordinal
public MethodExportInfo(ushort ordinal) {
options = DefaultOptions;
this.ordinal = ordinal;
}
///
/// Constructor
///
/// Name or null to export by ordinal
/// Ordinal or null to export by name
public MethodExportInfo(string name, ushort? ordinal) {
options = DefaultOptions;
this.name = name;
this.ordinal = ordinal;
}
///
/// Constructor
///
/// Name or null to export by ordinal
/// Ordinal or null to export by name
/// Options
public MethodExportInfo(string name, ushort? ordinal, MethodExportInfoOptions options) {
this.options = options;
this.name = name;
this.ordinal = ordinal;
}
}
///
/// Exported method options
///
[Flags]
public enum MethodExportInfoOptions {
///
/// No bit is set
///
None = 0,
///
/// Transition from unmanaged code
///
FromUnmanaged = 0x00000001,
///
/// Also retain app domain
///
FromUnmanagedRetainAppDomain = 0x00000002,
///
/// Call most derived method
///
CallMostDerived = 0x00000004,
}
}