xur_

> module

std::re::dotnet

read, construct and write .NET assemblies

use std::re::dotnet; feature re-dotnet in the browser

std::re::dotnet reads, builds and writes .NET (ECMA-335) assemblies. open and parse give a Module, which holds every type, method, field, property and event, and can be written back out or decompiled to C#. new starts an empty one to build.

Module, TypeDefEntry, MethodEntry, FieldEntry, PropertyEntry, EventEntry, ParamEntry, BaseTypeRef, MethodBody, MemberToken, TypeSigDef and MethodSigDef are handles with the methods below. They share what they point at: a TypeDefEntry changed through one handle is changed for all. Plain data reachable from them (custom attributes, constants, enums) are records and enums read through reflection.

Flags come back as integers. For each flags set there are two functions: name_names(bits) lists the names of the flags set in bits, and name(names) combines a list of names into an integer, failing on an unknown one. Names are hao's, which follow the ECMA-335 spelling, such as "Public", "Static" or "BeforeFieldInit". Access and layout are multi-bit fields, so the names of a value list every name whose bits are all set: a public method lists "FamANDAssem", "Family" and "Public".

Backed by hao.

Where a function takes a TypeName it accepts a full "Namespace.Name" string (nested types as "Namespace.Outer/Inner"), a (namespace, name) pair, a SystemType such as SystemType::Object (a type in the System namespace), or a WellKnown such as WellKnown::System(SystemType::Uri).

Where it takes an AssemblyName it accepts an assembly name string, a WellKnownModule such as WellKnownModule::SystemConsole (which carries the assembly's public-key token), or either of those paired with a (major, minor, build, revision) version. Without a version the reference is to version 0.0.0.0.

An AnyWellKnownMethod is a WellKnownMethod such as WellKnownMethod::Console(ConsoleMethod::WriteLineStr), or one of its inner enums on its own, such as ConsoleMethod::WriteLineStr. These name common base class library methods with their signatures built in.

> functions

# add_method(typedef: TypeDefEntry, method: MethodEntry) -> MethodEntry

Add a copy of method to typedef and return the added method, which is the one to pass to Module.set_entry_point().

# assembly_flags(names: list<str>) -> Result<u32, str>

Combine assembly flag names into an integer. The assembly flag names set in bits.

# assembly_flags_names(bits: u32) -> list<str>

Combine assembly flag names into an integer. The assembly flag names set in bits.

# assembly_name(w: WellKnownModule) -> str

The assembly name of a well-known module, such as "System.Console" for WellKnownModule::SystemConsole.

# attribute_is_type(attr: CustomAttribute, name: TypeName) -> bool

Whether a custom attribute's type is name.

# attribute_type_name(attr: CustomAttribute) -> str

The full name of a custom attribute's type.

# event_flags(names: list<str>) -> Result<u16, str>

Combine event attribute names into an integer. The event attribute names set in bits, for example from EventEntry.flags().

# event_flags_names(bits: u16) -> list<str>

Combine event attribute names into an integer. The event attribute names set in bits, for example from EventEntry.flags().

# field_flags(names: list<str>) -> Result<u16, str>

Combine field attribute names into an integer. The field attribute names set in bits.

# field_flags_names(bits: u16) -> list<str>

Combine field attribute names into an integer. The field attribute names set in bits.

# generic_param_flags(names: list<str>) -> Result<u16, str>

Combine generic parameter attribute names into an integer. The generic parameter attribute names set in bits.

# generic_param_flags_names(bits: u16) -> list<str>

Combine generic parameter attribute names into an integer. The generic parameter attribute names set in bits.

# method_flags(names: list<str>) -> Result<u16, str>

Combine method attribute names into an integer. The method attribute names set in bits, for example from MethodEntry.flags().

# method_flags_names(bits: u16) -> list<str>

Combine method attribute names into an integer. The method attribute names set in bits, for example from MethodEntry.flags().

# module_of(w: WellKnown) -> WellKnownModule

The assembly a well-known type lives in. It is worked out per namespace, so a type that lives outside its namespace's main assembly gets that main assembly.

The name of a well-known value: a type's name such as "Uri" for SystemType::Uri, or a module's variant name such as "SystemConsole".

# new(name: str, kind?: str) -> Module

Start an empty module named name that targets .NET 9. kind is "dll" (the default), "console" (or "exe") or "windows"; anything else raises an error.

# open(path: str) -> Result<Module, str>

Load the assembly at path, resolving the assemblies it references from the same directory.

# param_flags(names: list<str>) -> Result<u16, str>

Combine parameter attribute names into an integer. The parameter attribute names set in bits, for example from ParamEntry.flags().

# param_flags_names(bits: u16) -> list<str>

Combine parameter attribute names into an integer. The parameter attribute names set in bits, for example from ParamEntry.flags().

# parse(bytes: bytes) -> Result<Module, str>

Parse an assembly held in memory, without resolving its references.

# property_flags(names: list<str>) -> Result<u16, str>

Combine property attribute names into an integer. The property attribute names set in bits, for example from PropertyEntry.flags().

# property_flags_names(bits: u16) -> list<str>

Combine property attribute names into an integer. The property attribute names set in bits, for example from PropertyEntry.flags().

# public_static_method(name: str, sig: MethodSigDef, body: MethodBody) -> MethodEntry

A new public static method with signature sig (from dotnet::sig) and IL body (from dotnet::il).

# static_class(module: Module, namespace: str, name: str) -> TypeDefEntry

A new public static class (abstract and sealed, extending System.Object). Add it to the module with Module.add_type().

# type_attributes(names: list<str>) -> Result<u32, str>

Combine type attribute names into an integer. The type attribute names set in bits.

# type_attributes_names(bits: u32) -> list<str>

Combine type attribute names into an integer. The type attribute names set in bits.

> types

┌ enum AppDomainMethod
AppDomainMethod::GetCurrentDomain
AppDomainMethod::GetAssemblies
┌ enum ArrayListMethod
ArrayListMethod::New
ArrayListMethod::Add
ArrayListMethod::ToArray
┌ enum ArrayMethod
ArrayMethod::GetLength
┌ struct Assembly

The assembly manifest of the current module.

hash_alg_idu32
versionVersion
flagsAssemblyFlags
public_keybytes
namestr
culturestr
securitylist<DeclSecurity>
custom_attributeslist<CustomAttribute>
┌ type AssemblyFlags

An opaque value; see the functions that return it.

┌ enum AssemblyMethod
AssemblyMethod::LoadFrom
AssemblyMethod::GetName
AssemblyMethod::GetTypeStr
AssemblyMethod::GetTypes
┌ enum AssemblyNameMethod
AssemblyNameMethod::GetName
┌ struct AssemblyRef
versionVersion
flagsAssemblyFlags
public_key_or_tokenbytes
namestr
culturestr
hash_valuebytes
custom_attributeslist<CustomAttribute>
resolvedOption<Module>Set by [`Module::load_dependancies`].
┌ type BaseTypeRef

A reference to a type: one defined in this module, one in another assembly, or a generic instance.

# base_type_ref.full_name() -> str

"Namespace.Name", or the signature for a generic instance.

# base_type_ref.full_name_is(name: TypeName) -> bool

Whether the type is name.

# base_type_ref.name() -> str

The type's name.

# base_type_ref.namespace() -> str

The type's namespace.

# base_type_ref.resolve() -> Option<TypeDefEntry>

The type's definition, if it is in this module or a loaded referenced one. None for a generic instance.

┌ struct ClassLayout
packing_sizeu16
class_sizeu32
┌ enum ConsoleMethod
ConsoleMethod::WriteLine
ConsoleMethod::WriteLineStr
ConsoleMethod::WriteLineObj
ConsoleMethod::WriteLineI32
ConsoleMethod::WriteLineBool
ConsoleMethod::WriteLineChar
ConsoleMethod::WriteStr
ConsoleMethod::ReadLine
┌ struct Constant

A compile time constant for a field, parameter or property (ECMA-335 II.22.9). [`value`](Self::value) is the raw little-endian blob; [`decode`](Self::decode) turns it into a typed [`ConstantValue`].

element_typeElementType
valuebytes
┌ enum ConstantValue

A decoded [`Constant`] value.

ConstantValue::Bool(bool)
ConstantValue::Char(u16)A UTF-16 code unit (`System.Char`).
ConstantValue::I1(i8)
ConstantValue::U1(u8)
ConstantValue::I2(i16)
ConstantValue::U2(u16)
ConstantValue::I4(i32)
ConstantValue::U4(u32)
ConstantValue::I8(i64)
ConstantValue::U8(u64)
ConstantValue::R4(f32)
ConstantValue::R8(f64)
ConstantValue::String(str)
ConstantValue::NullA `null` reference constant (element type `Class`).
┌ enum ConvertMethod
ConvertMethod::ToStringObj
ConvertMethod::ToInt32Str
ConvertMethod::ToBooleanStr
┌ struct CustomAttribute

A custom attribute. The value is kept as the raw blob (II.23.3).

constructorCustomAttributeCtor
valuebytes
┌ enum CustomAttributeCtor
CustomAttributeCtor::Method(Entry)
CustomAttributeCtor::MemberRef(Entry)
┌ struct DeclSecurity

Declarative security (II.22.11). The permission set is the raw blob.

actionu16
permission_setbytes
custom_attributeslist<CustomAttribute>
┌ struct Entry

A shared handle to a metadata entry (a type, method, field, ...). Cloning an `Entry` is cheap and produces another handle to the same value. Entries compare and hash by identity.

0EntryInner
┌ struct EntryAssembly

A shared handle to a metadata entry (a type, method, field, ...). Cloning an `Entry` is cheap and produces another handle to the same value. Entries compare and hash by identity.

0EntryInner
┌ struct EntryAssemblyRef

A shared handle to a metadata entry (a type, method, field, ...). Cloning an `Entry` is cheap and produces another handle to the same value. Entries compare and hash by identity.

0EntryInner
┌ struct EntryEvent

A shared handle to a metadata entry (a type, method, field, ...). Cloning an `Entry` is cheap and produces another handle to the same value. Entries compare and hash by identity.

0EntryInner
┌ struct EntryExportedType

A shared handle to a metadata entry (a type, method, field, ...). Cloning an `Entry` is cheap and produces another handle to the same value. Entries compare and hash by identity.

0EntryInner
┌ struct EntryField

A shared handle to a metadata entry (a type, method, field, ...). Cloning an `Entry` is cheap and produces another handle to the same value. Entries compare and hash by identity.

0EntryInner
┌ struct EntryFile

A shared handle to a metadata entry (a type, method, field, ...). Cloning an `Entry` is cheap and produces another handle to the same value. Entries compare and hash by identity.

0EntryInner
┌ struct EntryGenericParam

A shared handle to a metadata entry (a type, method, field, ...). Cloning an `Entry` is cheap and produces another handle to the same value. Entries compare and hash by identity.

0EntryInner
┌ struct EntryInner
ridRidCell
valueModuleRef
┌ struct EntryInnerAssembly
ridRidCell
valueAssembly
┌ struct EntryInnerAssemblyRef
ridRidCell
valueAssemblyRef
┌ struct EntryInnerEvent
ridRidCell
valueEvent
┌ struct EntryInnerExportedType
ridRidCell
valueExportedType
┌ struct EntryInnerField
ridRidCell
valueField
┌ struct EntryInnerFile
ridRidCell
valueFile
┌ struct EntryInnerGenericParam
ridRidCell
valueGenericParam
┌ struct EntryInnerManifestResource
ridRidCell
valueManifestResource
┌ struct EntryInnerMemberRef
ridRidCell
valueMemberRef
┌ struct EntryInnerMethod
ridRidCell
valueMethod
┌ struct EntryInnerMethodSpec
ridRidCell
valueMethodSpec
┌ struct EntryInnerModuleDef
ridRidCell
valueModuleDef
┌ struct EntryInnerParam
ridRidCell
valueParam
┌ struct EntryInnerProperty
ridRidCell
valueProperty
┌ struct EntryInnerTypeDef
ridRidCell
valueTypeDef
┌ struct EntryInnerTypeRef
ridRidCell
valueTypeRef
┌ struct EntryInnerTypeSpec
ridRidCell
valueTypeSpec
┌ struct EntryManifestResource

A shared handle to a metadata entry (a type, method, field, ...). Cloning an `Entry` is cheap and produces another handle to the same value. Entries compare and hash by identity.

0EntryInner
┌ struct EntryMemberRef

A shared handle to a metadata entry (a type, method, field, ...). Cloning an `Entry` is cheap and produces another handle to the same value. Entries compare and hash by identity.

0EntryInner
┌ struct EntryMethod

A shared handle to a metadata entry (a type, method, field, ...). Cloning an `Entry` is cheap and produces another handle to the same value. Entries compare and hash by identity.

0EntryInner
┌ struct EntryMethodSpec

A shared handle to a metadata entry (a type, method, field, ...). Cloning an `Entry` is cheap and produces another handle to the same value. Entries compare and hash by identity.

0EntryInner
┌ struct EntryModuleRef

A shared handle to a metadata entry (a type, method, field, ...). Cloning an `Entry` is cheap and produces another handle to the same value. Entries compare and hash by identity.

0EntryInner
┌ struct EntryParam

A shared handle to a metadata entry (a type, method, field, ...). Cloning an `Entry` is cheap and produces another handle to the same value. Entries compare and hash by identity.

0EntryInner
┌ struct EntryProperty

A shared handle to a metadata entry (a type, method, field, ...). Cloning an `Entry` is cheap and produces another handle to the same value. Entries compare and hash by identity.

0EntryInner
┌ struct EntryTypeDef

A shared handle to a metadata entry (a type, method, field, ...). Cloning an `Entry` is cheap and produces another handle to the same value. Entries compare and hash by identity.

0EntryInner
┌ struct EntryTypeRef

A shared handle to a metadata entry (a type, method, field, ...). Cloning an `Entry` is cheap and produces another handle to the same value. Entries compare and hash by identity.

0EntryInner
┌ struct EntryTypeSpec

A shared handle to a metadata entry (a type, method, field, ...). Cloning an `Entry` is cheap and produces another handle to the same value. Entries compare and hash by identity.

0EntryInner
┌ enum EnvironmentMethod
EnvironmentMethod::GetNewLine
EnvironmentMethod::GetMachineName
EnvironmentMethod::GetProcessorCount
EnvironmentMethod::GetEnvironmentVariableStr
EnvironmentMethod::Exit
┌ struct Event
flagsEventFlags
namestr
event_typeOption<TypeDefOrRef>
addOption<Entry>
removeOption<Entry>
fireOption<Entry>
other_methodslist<Entry>
custom_attributeslist<CustomAttribute>
┌ type EventEntry
# event_entry.add() -> Option<MethodEntry>

The add accessor.

# event_entry.event_type() -> Option<BaseTypeRef>

The event's delegate type.

# event_entry.fire() -> Option<MethodEntry>

The raise accessor, which C# never emits.

# event_entry.flags() -> i64

Its event attributes; see event_flags_names().

# event_entry.name() -> str

The event's name.

# event_entry.remove() -> Option<MethodEntry>

The remove accessor.

┌ type EventFlags

An opaque value; see the functions that return it.

┌ enum ExceptionMethod
ExceptionMethod::GetHResult
┌ struct ExportedType

A type exported (or forwarded) by this assembly.

flagsTypeAttributes
type_def_idu32
namestr
namespacestr
implementationOption<Implementation>
custom_attributeslist<CustomAttribute>
┌ struct Field
flagsFieldFlags
namestr
signatureFieldSig
constantOption<Constant>
offsetOption<u32>Explicit offset from `FieldLayout`.
marshalOption<bytes>
initial_valueOption<bytes>Initial data from `FieldRVA`.
impl_mapOption<ImplMap>
custom_attributeslist<CustomAttribute>
declaring_typeWeakEntry
┌ type FieldEntry
# field_entry.constant() -> Option<ConstantValue>

The field's compile-time constant (a const or enum member), if it has one.

# field_entry.custom_attributes() -> list<CustomAttribute>

The field's custom attributes.

# field_entry.field_type() -> TypeSigDef

The field's type.

# field_entry.is_static() -> bool

Whether it is static.

# field_entry.name() -> str

The field's name.

# field_entry.signature() -> TypeSigDef

The field's type; the same as field_type().

┌ type FieldFlags

An opaque value; see the functions that return it.

┌ struct File
flagsFileFlags
namestr
hash_valuebytes
custom_attributeslist<CustomAttribute>
┌ type FileFlags

An opaque value; see the functions that return it.

┌ enum GcMethod
GcMethod::Collect
GcMethod::CollectGen
GcMethod::SuppressFinalize
GcMethod::TryStartNoGCRegion
GcMethod::EndNoGCRegion
┌ struct GenericParam
numberu16
flagsGenericParamFlags
namestr
constraintslist<GenericParamConstraint>
custom_attributeslist<CustomAttribute>
┌ struct GenericParamConstraint
constraintTypeDefOrRef
custom_attributeslist<CustomAttribute>
┌ type GenericParamFlags

An opaque value; see the functions that return it.

┌ enum IEnumerableMethod
IEnumerableMethod::GetEnumerator
┌ enum IEnumeratorMethod
IEnumeratorMethod::MoveNext
IEnumeratorMethod::GetCurrent
┌ struct ImplMap

P/Invoke information for a method or field.

flagsPInvokeMapFlags
import_namestr
scopeEntry
┌ enum Implementation
Implementation::File(Entry)
Implementation::AssemblyRef(Entry)
Implementation::ExportedType(Entry)
┌ struct InterfaceImpl
interfaceTypeDefOrRef
custom_attributeslist<CustomAttribute>
┌ struct ManifestResource
┌ type ManifestResourceFlags

An opaque value; see the functions that return it.

┌ enum MarshalMethod
MarshalMethod::PtrToStringAuto
MarshalMethod::StringToCoTaskMemUni
MarshalMethod::FreeCoTaskMem
MarshalMethod::UnsafeAddrOfPinnedArrayElement
┌ enum MathMethod
MathMethod::MaxI32
MathMethod::MinI32
MathMethod::AbsI32
┌ enum MemberInfoMethod
MemberInfoMethod::GetName
┌ struct MemberRef

A reference to a field or method, usually in another assembly.

parentMemberRefParent
namestr
signatureMemberRefSig
custom_attributeslist<CustomAttribute>
┌ enum MemberRefParent
MemberRefParent::TypeDef(Entry)
MemberRefParent::TypeRef(Entry)
MemberRefParent::ModuleRef(Entry)
MemberRefParent::Method(Entry)
MemberRefParent::TypeSpec(Entry)
┌ type MemberToken

An opaque value; see the functions that return it.

┌ struct Method
flagsMethodFlags
impl_flagsMethodImplFlags
namestr
signatureMethodSig
paramslist<Entry>
bodyOption<MethodBody>
generic_paramslist<Entry>
impl_mapOption<ImplMap>
securitylist<DeclSecurity>
custom_attributeslist<CustomAttribute>
declaring_typeWeakEntry
┌ enum MethodBaseMethod
MethodBaseMethod::GetMethodHandle
MethodBaseMethod::GetParameters
┌ type MethodBody
# method_body.instructions() -> list<str>

The instructions as text, such as "IL_0002:\call\System.Console::WriteLine". The IL_ labels number instructions by index, not byte offset.

# method_body.size() -> i64

The number of IL instructions (not bytes).

┌ enum MethodDefOrRef
MethodDefOrRef::Method(Entry)
MethodDefOrRef::MemberRef(Entry)
┌ type MethodEntry
# method_entry.body() -> Option<MethodBody>

Its IL body; None for abstract, extern and runtime methods.

# method_entry.custom_attributes() -> list<CustomAttribute>

The method's custom attributes.

# method_entry.flags() -> i64

Its method attributes; see method_flags_names().

# method_entry.is_abstract() -> bool

Whether it is abstract.

# method_entry.is_cctor() -> bool

Whether it is a static constructor (.cctor).

# method_entry.is_ctor() -> bool

Whether it is an instance constructor (.ctor).

# method_entry.is_public() -> bool

Whether its access is public.

# method_entry.is_static() -> bool

Whether it is static.

# method_entry.is_virtual() -> bool

Whether it is virtual.

# method_entry.name() -> str

The method's name; ".ctor" for a constructor.

# method_entry.param_name(index: usize) -> str

The name of parameter index (from 0, not counting this), or argindex if it has no name.

# method_entry.parameters() -> list<ParamEntry>

Its parameter rows.

# method_entry.params() -> list<str>

The names of its parameter rows.

# method_entry.return_type() -> TypeSigDef

The return type from its signature.

# method_entry.signature() -> MethodSigDef

The method's signature.

┌ type MethodFlags

An opaque value; see the functions that return it.

┌ struct MethodImpl

An explicit interface method implementation (II.22.27).

bodyMethodDefOrRef
declarationMethodDefOrRef
┌ type MethodImplFlags

An opaque value; see the functions that return it.

┌ type MethodSigDef

An opaque value; see the functions that return it.

┌ struct MethodSpec

An instantiation of a generic method.

methodMethodDefOrRef
instantiationlist<TypeSig>
custom_attributeslist<CustomAttribute>
┌ enum MicrosoftCSharpRuntimeBinderType
MicrosoftCSharpRuntimeBinderType::Binder
MicrosoftCSharpRuntimeBinderType::CSharpArgumentInfo
MicrosoftCSharpRuntimeBinderType::CSharpArgumentInfoFlags
MicrosoftCSharpRuntimeBinderType::CSharpBinderFlags
┌ enum MicrosoftVisualBasicApplicationServicesType
MicrosoftVisualBasicApplicationServicesType::ApplicationBase
MicrosoftVisualBasicApplicationServicesType::WindowsFormsApplicationBase
┌ enum MicrosoftVisualBasicCompilerServicesType
MicrosoftVisualBasicCompilerServicesType::Conversions
MicrosoftVisualBasicCompilerServicesType::Operators
MicrosoftVisualBasicCompilerServicesType::NewLateBinding
MicrosoftVisualBasicCompilerServicesType::EmbeddedOperators
MicrosoftVisualBasicCompilerServicesType::StandardModuleAttribute
MicrosoftVisualBasicCompilerServicesType::Utils
MicrosoftVisualBasicCompilerServicesType::LikeOperator
MicrosoftVisualBasicCompilerServicesType::ProjectData
MicrosoftVisualBasicCompilerServicesType::ObjectFlowControl
MicrosoftVisualBasicCompilerServicesType::StaticLocalInitFlag
MicrosoftVisualBasicCompilerServicesType::StringType
MicrosoftVisualBasicCompilerServicesType::IncompleteInitialization
MicrosoftVisualBasicCompilerServicesType::Versioned
┌ enum MicrosoftVisualBasicType
MicrosoftVisualBasicType::CallType
MicrosoftVisualBasicType::Embedded
MicrosoftVisualBasicType::CompareMethod
MicrosoftVisualBasicType::Strings
MicrosoftVisualBasicType::ErrObject
MicrosoftVisualBasicType::FileSystem
MicrosoftVisualBasicType::Information
MicrosoftVisualBasicType::Interaction
MicrosoftVisualBasicType::Conversion
┌ type Module
# module.add_assembly_ref(assembly: AssemblyName)

Add a reference to an assembly, unless there already is one.

# module.add_type(typedef: TypeDefEntry)

Add a type built with static_class() to the module.

# module.all_fields() -> list<FieldEntry>

Every field of every type.

# module.all_methods() -> list<MethodEntry>

Every method of every type.

# module.all_types() -> list<TypeDefEntry>

Every type, nested ones included, depth first. The first is <Module>, which holds global fields and methods.

# module.corlib_type(ty: TypeName) -> Result<BaseTypeRef, str>

A reference to a type in the core library, such as "System.Object".

# module.find_field(ty: TypeName, name: str) -> Option<FieldEntry>

The field named name in the type named ty.

# module.find_method(ty: TypeName, name: str) -> Option<MethodEntry>

The first method named name in the type named ty (found as by find_type_by_full_name()).

# module.find_type(ty: TypeName) -> Option<TypeDefEntry>

The top-level type named ty.

# module.find_type_by_full_name(ty: TypeName) -> Option<TypeDefEntry>

The type named ty, nested types included ("Namespace.Outer/Inner").

# module.global_type() -> Option<TypeDefEntry>

The <Module> type, which holds global fields and methods.

# module.import_corlib_method(ty: TypeName, name: str, sig: MethodSigDef) -> Result<MemberToken, str>

A token for method name with signature sig on a core library type, such as System.Math::Max.

# module.import_method(assembly: AssemblyName, type_name: TypeName, method_name: str, sig: MethodSigDef) -> Result<MemberToken, str>

A token for method method_name with signature sig on type type_name in assembly, for Emitter.call(). Add the assembly with add_assembly_ref() first.

# module.import_well_known_method(method: AnyWellKnownMethod) -> Result<MemberToken, str>

A token for a well-known method, such as ConsoleMethod::WriteLineStr, with no assembly, type or signature to spell out.

# module.import_well_known_type(ty: WellKnown) -> Result<BaseTypeRef, str>

A reference to a well-known type, adding a reference to the assembly it lives in (see module_of()).

# module.name() -> str

The module's name, such as "Game.dll".

# module.original_image() -> bytes

The bytes the module was loaded from.

# module.resolve_type(ty: TypeName) -> Option<TypeDefEntry>

Like find_type(), but also follows type forwarders into the loaded assemblies this one references.

# module.runtime_version() -> str

The metadata version string, such as "v4.0.30319".

# module.set_entry_point(method: MethodEntry)

Make method the program's entry point.

# module.to_csharp() -> str

Decompile the module to C# source.

# module.write() -> Result<bytes, str>

Serialize the module, with any changes, to a PE image.

# module.write_to_path(path: str) -> Result<(), str>

Serialize the module and write it to path.

┌ struct ModuleDef
generationu16
namestr
mvidUuid
enc_idUuid
enc_base_idUuid
custom_attributeslist<CustomAttribute>
┌ enum ModuleKind
ModuleKind::Dll
ModuleKind::Console
ModuleKind::Windows
┌ struct ModuleRef
namestr
custom_attributeslist<CustomAttribute>
┌ enum ObjectMethod
ObjectMethod::ToString
ObjectMethod::GetHashCode
ObjectMethod::GetType
ObjectMethod::EqualsObj
ObjectMethod::ReferenceEquals
┌ type PInvokeMapFlags

An opaque value; see the functions that return it.

┌ struct Param
flagsParamFlags
sequenceu16
namestr
constantOption<Constant>
marshalOption<bytes>
custom_attributeslist<CustomAttribute>
┌ type ParamEntry
# param_entry.constant() -> Option<ConstantValue>

Its default value, if it has one.

# param_entry.flags() -> i64

Its parameter attributes (in, out, optional...); see param_flags_names().

# param_entry.name() -> str

The parameter's name.

# param_entry.sequence() -> i64

Its position: 0 for the return value, 1 for the first parameter.

┌ type ParamFlags

An opaque value; see the functions that return it.

┌ struct Property
flagsPropertyFlags
namestr
signaturePropertySig
constantOption<Constant>
getterOption<Entry>
setterOption<Entry>
other_methodslist<Entry>
custom_attributeslist<CustomAttribute>
┌ type PropertyEntry
# property_entry.constant() -> Option<ConstantValue>

The property's default value, if it has one.

# property_entry.flags() -> i64

Its property attributes; see property_flags_names().

# property_entry.getter() -> Option<MethodEntry>

The get accessor, if any.

# property_entry.name() -> str

The property's name.

# property_entry.setter() -> Option<MethodEntry>

The set accessor, if any.

┌ type PropertyFlags

An opaque value; see the functions that return it.

┌ enum ResolutionScope
ResolutionScope::Module(Entry)
ResolutionScope::ModuleRef(Entry)
ResolutionScope::AssemblyRef(Entry)
ResolutionScope::TypeRef(Entry)
┌ enum ResourceData
ResourceData::Embedded(bytes)
ResourceData::Linked(implementation:Implementation,offset:u32)
┌ enum RuntimeHelpersMethod
RuntimeHelpersMethod::PrepareMethod
┌ enum RuntimeMethodHandleMethod
RuntimeMethodHandleMethod::GetFunctionPointer
┌ enum StringBuilderMethod
StringBuilderMethod::New
StringBuilderMethod::NewStr
StringBuilderMethod::AppendStr
StringBuilderMethod::AppendChar
StringBuilderMethod::AppendI32
StringBuilderMethod::AppendObj
StringBuilderMethod::AppendLineStr
StringBuilderMethod::Clear
StringBuilderMethod::ToString
┌ enum StringExtMethod
StringExtMethod::OpEquality
┌ enum StringMethod
StringMethod::Concat2
StringMethod::FormatObj
StringMethod::IsNullOrEmpty
StringMethod::EqualsStr
StringMethod::GetLength
StringMethod::SubstringI32
StringMethod::ToUpper
StringMethod::ToLower
StringMethod::ContainsStr
StringMethod::ReplaceStr
┌ enum SystemCollectionsGenericType
SystemCollectionsGenericType::HashSet_1
SystemCollectionsGenericType::Queue_1
SystemCollectionsGenericType::Stack_1
SystemCollectionsGenericType::LinkedList_1
SystemCollectionsGenericType::SortedDictionary_2
SystemCollectionsGenericType::SortedList_2
SystemCollectionsGenericType::SortedSet_1
SystemCollectionsGenericType::ISet_1
SystemCollectionsGenericType::IReadOnlySet_1
SystemCollectionsGenericType::IComparer_1
SystemCollectionsGenericType::IEqualityComparer_1
SystemCollectionsGenericType::Comparer_1
SystemCollectionsGenericType::IEnumerable_1
SystemCollectionsGenericType::IList_1
SystemCollectionsGenericType::ICollection_1
SystemCollectionsGenericType::IEnumerator_1
SystemCollectionsGenericType::IReadOnlyList_1
SystemCollectionsGenericType::IReadOnlyCollection_1
SystemCollectionsGenericType::EqualityComparer_1
SystemCollectionsGenericType::List_1
SystemCollectionsGenericType::IDictionary_2
SystemCollectionsGenericType::Dictionary_2
SystemCollectionsGenericType::IReadOnlyDictionary_2
SystemCollectionsGenericType::KeyValuePair_2
SystemCollectionsGenericType::IAsyncEnumerable_1
SystemCollectionsGenericType::IAsyncEnumerator_1
┌ enum SystemCollectionsObjectModelType
SystemCollectionsObjectModelType::Collection_1
SystemCollectionsObjectModelType::ReadOnlyCollection_1
┌ enum SystemCollectionsSpecializedType
SystemCollectionsSpecializedType::INotifyCollectionChanged
┌ enum SystemCollectionsType
SystemCollectionsType::Hashtable
SystemCollectionsType::ArrayList
SystemCollectionsType::IDictionary
SystemCollectionsType::IComparer
SystemCollectionsType::IEqualityComparer
SystemCollectionsType::Queue
SystemCollectionsType::Stack
SystemCollectionsType::BitArray
SystemCollectionsType::DictionaryEntry
SystemCollectionsType::IEnumerator
SystemCollectionsType::IEnumerable
SystemCollectionsType::IList
SystemCollectionsType::ICollection
┌ enum SystemComponentModelType
SystemComponentModelType::DesignerSerializationVisibilityAttribute
SystemComponentModelType::INotifyPropertyChanged
SystemComponentModelType::EditorBrowsableAttribute
SystemComponentModelType::EditorBrowsableState
┌ enum SystemDiagnosticsType
SystemDiagnosticsType::Stopwatch
SystemDiagnosticsType::Debug
SystemDiagnosticsType::Trace
SystemDiagnosticsType::ConditionalAttribute
SystemDiagnosticsType::StackTrace
SystemDiagnosticsType::StackFrame
SystemDiagnosticsType::Process
SystemDiagnosticsType::ProcessStartInfo
SystemDiagnosticsType::DebuggerTypeProxyAttribute
SystemDiagnosticsType::Debugger
SystemDiagnosticsType::DebuggerDisplayAttribute
SystemDiagnosticsType::DebuggerNonUserCodeAttribute
SystemDiagnosticsType::DebuggerHiddenAttribute
SystemDiagnosticsType::DebuggerBrowsableAttribute
SystemDiagnosticsType::DebuggerStepThroughAttribute
SystemDiagnosticsType::DebuggerBrowsableState
SystemDiagnosticsType::DebuggableAttribute
┌ enum SystemGlobalizationType
SystemGlobalizationType::CultureInfo
SystemGlobalizationType::NumberStyles
SystemGlobalizationType::DateTimeStyles
SystemGlobalizationType::NumberFormatInfo
SystemGlobalizationType::DateTimeFormatInfo
SystemGlobalizationType::CompareInfo
SystemGlobalizationType::RegionInfo
SystemGlobalizationType::TextInfo
SystemGlobalizationType::Calendar
┌ enum SystemIoType
SystemIoType::Path
SystemIoType::File
SystemIoType::Directory
SystemIoType::FileInfo
SystemIoType::DirectoryInfo
SystemIoType::Stream
SystemIoType::MemoryStream
SystemIoType::FileStream
SystemIoType::StreamReader
SystemIoType::StreamWriter
SystemIoType::BinaryReader
SystemIoType::BinaryWriter
SystemIoType::TextReader
SystemIoType::TextWriter
SystemIoType::FileMode
SystemIoType::FileAccess
SystemIoType::FileShare
SystemIoType::SeekOrigin
SystemIoType::IOException
SystemIoType::FileNotFoundException
SystemIoType::DirectoryNotFoundException
┌ enum SystemLinqExpressionsType
SystemLinqExpressionsType::Expression
SystemLinqExpressionsType::Expression_1
SystemLinqExpressionsType::ParameterExpression
SystemLinqExpressionsType::ElementInit
SystemLinqExpressionsType::MemberBinding
SystemLinqExpressionsType::ExpressionType
┌ enum SystemLinqType
SystemLinqType::Enumerable
SystemLinqType::IQueryable
SystemLinqType::IQueryable_1
SystemLinqType::SystemCore_EnumerableDebugView
SystemLinqType::SystemCore_EnumerableDebugView_1
┌ enum SystemReflectionType
SystemReflectionType::PropertyInfo
SystemReflectionType::EventInfo
SystemReflectionType::ParameterInfo
SystemReflectionType::Module
SystemReflectionType::AssemblyName
SystemReflectionType::TypeInfo
SystemReflectionType::CustomAttributeData
SystemReflectionType::Pointer
SystemReflectionType::BindingFlags
SystemReflectionType::MethodAttributes
SystemReflectionType::FieldAttributes
SystemReflectionType::TypeAttributes
SystemReflectionType::PropertyAttributes
SystemReflectionType::ParameterAttributes
SystemReflectionType::MethodImplAttributes
SystemReflectionType::CallingConventions
SystemReflectionType::MethodInfo
SystemReflectionType::ConstructorInfo
SystemReflectionType::MethodBase
SystemReflectionType::FieldInfo
SystemReflectionType::MemberInfo
SystemReflectionType::Missing
SystemReflectionType::AssemblyKeyFileAttribute
SystemReflectionType::AssemblyKeyNameAttribute
SystemReflectionType::DefaultMemberAttribute
SystemReflectionType::Assembly
┌ enum SystemRuntimeCompilerServicesType
SystemRuntimeCompilerServicesType::MethodImplAttribute
SystemRuntimeCompilerServicesType::MethodImplOptions
SystemRuntimeCompilerServicesType::Unsafe
SystemRuntimeCompilerServicesType::CallerMemberNameAttribute
SystemRuntimeCompilerServicesType::CallerLineNumberAttribute
SystemRuntimeCompilerServicesType::CallerFilePathAttribute
SystemRuntimeCompilerServicesType::CallerArgumentExpressionAttribute
SystemRuntimeCompilerServicesType::ModuleInitializerAttribute
SystemRuntimeCompilerServicesType::SkipLocalsInitAttribute
SystemRuntimeCompilerServicesType::StrongBox_1
SystemRuntimeCompilerServicesType::ConditionalWeakTable_2
SystemRuntimeCompilerServicesType::IsVolatile
SystemRuntimeCompilerServicesType::FormattableStringFactory
SystemRuntimeCompilerServicesType::RuntimeHelpers
SystemRuntimeCompilerServicesType::DateTimeConstantAttribute
SystemRuntimeCompilerServicesType::DecimalConstantAttribute
SystemRuntimeCompilerServicesType::IUnknownConstantAttribute
SystemRuntimeCompilerServicesType::IDispatchConstantAttribute
SystemRuntimeCompilerServicesType::ExtensionAttribute
SystemRuntimeCompilerServicesType::INotifyCompletion
SystemRuntimeCompilerServicesType::InternalsVisibleToAttribute
SystemRuntimeCompilerServicesType::CompilerGeneratedAttribute
SystemRuntimeCompilerServicesType::AccessedThroughPropertyAttribute
SystemRuntimeCompilerServicesType::CompilationRelaxationsAttribute
SystemRuntimeCompilerServicesType::RuntimeCompatibilityAttribute
SystemRuntimeCompilerServicesType::UnsafeValueTypeAttribute
SystemRuntimeCompilerServicesType::FixedBufferAttribute
SystemRuntimeCompilerServicesType::DynamicAttribute
SystemRuntimeCompilerServicesType::CallSiteBinder
SystemRuntimeCompilerServicesType::CallSite
SystemRuntimeCompilerServicesType::CallSite_1
SystemRuntimeCompilerServicesType::ICriticalNotifyCompletion
SystemRuntimeCompilerServicesType::IAsyncStateMachine
SystemRuntimeCompilerServicesType::AsyncVoidMethodBuilder
SystemRuntimeCompilerServicesType::AsyncTaskMethodBuilder
SystemRuntimeCompilerServicesType::AsyncTaskMethodBuilder_1
SystemRuntimeCompilerServicesType::AsyncStateMachineAttribute
SystemRuntimeCompilerServicesType::IteratorStateMachineAttribute
SystemRuntimeCompilerServicesType::TupleElementNamesAttribute
SystemRuntimeCompilerServicesType::ReferenceAssemblyAttribute
SystemRuntimeCompilerServicesType::TypeForwardedToAttribute
SystemRuntimeCompilerServicesType::IsReadOnlyAttribute
SystemRuntimeCompilerServicesType::IsByRefLikeAttribute
SystemRuntimeCompilerServicesType::AsyncIteratorMethodBuilder
SystemRuntimeCompilerServicesType::AsyncIteratorStateMachineAttribute
SystemRuntimeCompilerServicesType::NullableAttribute
SystemRuntimeCompilerServicesType::IsUnmanagedAttribute
SystemRuntimeCompilerServicesType::CallConvCdecl
SystemRuntimeCompilerServicesType::CallConvStdcall
SystemRuntimeCompilerServicesType::CallConvThiscall
SystemRuntimeCompilerServicesType::CallConvFastcall
SystemRuntimeCompilerServicesType::CallConvSuppressGCTransition
SystemRuntimeCompilerServicesType::CallConvMemberFunction
┌ enum SystemRuntimeExceptionServicesType
SystemRuntimeExceptionServicesType::ExceptionDispatchInfo
┌ enum SystemRuntimeInteropServicesType
SystemRuntimeInteropServicesType::StructLayoutAttribute
SystemRuntimeInteropServicesType::UnknownWrapper
SystemRuntimeInteropServicesType::DispatchWrapper
SystemRuntimeInteropServicesType::CallingConvention
SystemRuntimeInteropServicesType::ClassInterfaceAttribute
SystemRuntimeInteropServicesType::ClassInterfaceType
SystemRuntimeInteropServicesType::CoClassAttribute
SystemRuntimeInteropServicesType::ComAwareEventInfo
SystemRuntimeInteropServicesType::ComEventInterfaceAttribute
SystemRuntimeInteropServicesType::ComInterfaceType
SystemRuntimeInteropServicesType::ComSourceInterfacesAttribute
SystemRuntimeInteropServicesType::ComVisibleAttribute
SystemRuntimeInteropServicesType::DispIdAttribute
SystemRuntimeInteropServicesType::GuidAttribute
SystemRuntimeInteropServicesType::InterfaceTypeAttribute
SystemRuntimeInteropServicesType::Marshal
SystemRuntimeInteropServicesType::TypeIdentifierAttribute
SystemRuntimeInteropServicesType::BestFitMappingAttribute
SystemRuntimeInteropServicesType::DefaultParameterValueAttribute
SystemRuntimeInteropServicesType::LCIDConversionAttribute
SystemRuntimeInteropServicesType::UnmanagedFunctionPointerAttribute
SystemRuntimeInteropServicesType::ComImportAttribute
SystemRuntimeInteropServicesType::DllImportAttribute
SystemRuntimeInteropServicesType::FieldOffsetAttribute
SystemRuntimeInteropServicesType::InAttribute
SystemRuntimeInteropServicesType::MarshalAsAttribute
SystemRuntimeInteropServicesType::OptionalAttribute
SystemRuntimeInteropServicesType::OutAttribute
SystemRuntimeInteropServicesType::PreserveSigAttribute
SystemRuntimeInteropServicesType::CharSet
SystemRuntimeInteropServicesType::UnmanagedType
SystemRuntimeInteropServicesType::VarEnum
SystemRuntimeInteropServicesType::GCHandle
SystemRuntimeInteropServicesType::GCHandleType
SystemRuntimeInteropServicesType::UnmanagedCallersOnlyAttribute
SystemRuntimeInteropServicesType::LayoutKind
SystemRuntimeInteropServicesType::SafeHandle
SystemRuntimeInteropServicesType::HandleRef
SystemRuntimeInteropServicesType::NativeLibrary
SystemRuntimeInteropServicesType::MemoryMarshal
SystemRuntimeInteropServicesType::CollectionsMarshal
SystemRuntimeInteropServicesType::NativeMemory
SystemRuntimeInteropServicesType::RuntimeInformation
SystemRuntimeInteropServicesType::OSPlatform
SystemRuntimeInteropServicesType::Architecture
SystemRuntimeInteropServicesType::ComWrappers
┌ enum SystemRuntimeInteropServicesWindowsRuntimeType
SystemRuntimeInteropServicesWindowsRuntimeType::EventRegistrationToken
SystemRuntimeInteropServicesWindowsRuntimeType::EventRegistrationTokenTable_1
SystemRuntimeInteropServicesWindowsRuntimeType::WindowsRuntimeMarshal
SystemRuntimeInteropServicesWindowsRuntimeType::RuntimeClass
┌ enum SystemRuntimeType
SystemRuntimeType::GCLatencyMode
┌ enum SystemSecurityPermissionsType
SystemSecurityPermissionsType::SecurityAction
SystemSecurityPermissionsType::SecurityAttribute
SystemSecurityPermissionsType::SecurityPermissionAttribute
SystemSecurityPermissionsType::PermissionSetAttribute
┌ enum SystemSecurityType
SystemSecurityType::UnverifiableCodeAttribute
┌ enum SystemTextType
SystemTextType::Encoding
SystemTextType::StringBuilder
SystemTextType::Rune
SystemTextType::UTF8Encoding
SystemTextType::UnicodeEncoding
SystemTextType::ASCIIEncoding
SystemTextType::NormalizationForm
┌ enum SystemThreadingTasksSourcesType
SystemThreadingTasksSourcesType::ManualResetValueTaskSourceCore_1
SystemThreadingTasksSourcesType::ValueTaskSourceStatus
SystemThreadingTasksSourcesType::ValueTaskSourceOnCompletedFlags
SystemThreadingTasksSourcesType::IValueTaskSource_1
SystemThreadingTasksSourcesType::IValueTaskSource
┌ enum SystemThreadingTasksType
SystemThreadingTasksType::TaskCompletionSource
SystemThreadingTasksType::TaskCompletionSource_1
SystemThreadingTasksType::TaskScheduler
SystemThreadingTasksType::Parallel
SystemThreadingTasksType::TaskFactory
SystemThreadingTasksType::TaskStatus
SystemThreadingTasksType::TaskCreationOptions
SystemThreadingTasksType::TaskContinuationOptions
SystemThreadingTasksType::Task
SystemThreadingTasksType::Task_1
SystemThreadingTasksType::ValueTask_1
SystemThreadingTasksType::ValueTask
┌ enum SystemThreadingType
SystemThreadingType::Interlocked
SystemThreadingType::Monitor
SystemThreadingType::Thread
SystemThreadingType::CancellationToken
SystemThreadingType::CancellationTokenSource
SystemThreadingType::SemaphoreSlim
SystemThreadingType::ManualResetEventSlim
SystemThreadingType::ManualResetEvent
SystemThreadingType::AutoResetEvent
SystemThreadingType::Mutex
SystemThreadingType::Volatile
SystemThreadingType::WaitHandle
SystemThreadingType::ThreadPool
SystemThreadingType::SynchronizationContext
SystemThreadingType::ThreadStart
SystemThreadingType::ParameterizedThreadStart
SystemThreadingType::ReaderWriterLockSlim
SystemThreadingType::EventWaitHandle
┌ enum SystemType
SystemType::Object
SystemType::Enum
SystemType::MulticastDelegate
SystemType::Delegate
SystemType::ValueType
SystemType::Void
SystemType::Boolean
SystemType::Char
SystemType::SByte
SystemType::Byte
SystemType::Int16
SystemType::UInt16
SystemType::Int32
SystemType::UInt32
SystemType::Int64
SystemType::UInt64
SystemType::Decimal
SystemType::Single
SystemType::Double
SystemType::String
SystemType::IntPtr
SystemType::UIntPtr
SystemType::Array
SystemType::Nullable_1
SystemType::DateTime
SystemType::IDisposable
SystemType::TypedReference
SystemType::ArgIterator
SystemType::RuntimeArgumentHandle
SystemType::RuntimeFieldHandle
SystemType::RuntimeMethodHandle
SystemType::RuntimeTypeHandle
SystemType::IAsyncResult
SystemType::AsyncCallback
SystemType::Math
SystemType::Attribute
SystemType::CLSCompliantAttribute
SystemType::Convert
SystemType::Exception
SystemType::FlagsAttribute
SystemType::FormattableString
SystemType::Guid
SystemType::IFormattable
SystemType::MarshalByRefObject
SystemType::Type
SystemType::Func_1
SystemType::Func_2
SystemType::Func_3
SystemType::Func_4
SystemType::Func_5
SystemType::Func_6
SystemType::Func_7
SystemType::Func_8
SystemType::Func_9
SystemType::Func_10
SystemType::Func_11
SystemType::Func_12
SystemType::Func_13
SystemType::Func_14
SystemType::Func_15
SystemType::Func_16
SystemType::Func_17
SystemType::Action
SystemType::Action_1
SystemType::Action_2
SystemType::Action_3
SystemType::Action_4
SystemType::Action_5
SystemType::Action_6
SystemType::Action_7
SystemType::Action_8
SystemType::Action_9
SystemType::Action_10
SystemType::Action_11
SystemType::Action_12
SystemType::Action_13
SystemType::Action_14
SystemType::Action_15
SystemType::Action_16
SystemType::Activator
SystemType::AttributeUsageAttribute
SystemType::ParamArrayAttribute
SystemType::NonSerializedAttribute
SystemType::STAThreadAttribute
SystemType::IEquatable_1
SystemType::NotSupportedException
SystemType::Environment
SystemType::IFormatProvider
SystemType::ValueTuple_1
SystemType::ValueTuple_2
SystemType::ValueTuple_3
SystemType::ValueTuple_4
SystemType::ValueTuple_5
SystemType::ValueTuple_6
SystemType::ValueTuple_7
SystemType::ValueTuple_8
SystemType::AppDomain
SystemType::ContextBoundObject
SystemType::SerializableAttribute
SystemType::RuntimeMethodHandleInternal
SystemType::ByReference_1
SystemType::__ComObject
SystemType::DBNull
SystemType::ObsoleteAttribute
SystemType::Span_1
SystemType::ReadOnlySpan_1
SystemType::Index
SystemType::Range
SystemType::IAsyncDisposable
SystemType::Console
SystemType::GC
SystemType::GCCollectionMode
SystemType::TimeSpan
SystemType::DateTimeOffset
SystemType::Random
SystemType::Version
SystemType::Uri
SystemType::BitConverter
SystemType::Buffer
SystemType::MathF
SystemType::HashCode
SystemType::EventArgs
SystemType::EventHandler
SystemType::EventHandler_1
SystemType::IComparable
SystemType::IComparable_1
SystemType::ICloneable
SystemType::WeakReference
SystemType::WeakReference_1
SystemType::Lazy_1
SystemType::Progress_1
SystemType::IProgress_1
SystemType::Comparison_1
SystemType::Predicate_1
SystemType::Converter_2
SystemType::StringComparison
SystemType::StringSplitOptions
SystemType::AttributeTargets
SystemType::DateTimeKind
SystemType::MidpointRounding
SystemType::ArgumentException
SystemType::ArgumentNullException
SystemType::ArgumentOutOfRangeException
SystemType::InvalidOperationException
SystemType::NullReferenceException
SystemType::IndexOutOfRangeException
SystemType::NotImplementedException
SystemType::FormatException
SystemType::OverflowException
SystemType::InvalidCastException
SystemType::SystemException
SystemType::AggregateException
SystemType::ObjectDisposedException
SystemType::TimeoutException
SystemType::DivideByZeroException
SystemType::ArithmeticException
┌ enum SystemWindowsFormsType
SystemWindowsFormsType::Form
SystemWindowsFormsType::Application
┌ enum SystemXmlLinqType
SystemXmlLinqType::Extensions
SystemXmlLinqType::XAttribute
SystemXmlLinqType::XCData
SystemXmlLinqType::XComment
SystemXmlLinqType::XContainer
SystemXmlLinqType::XDeclaration
SystemXmlLinqType::XDocument
SystemXmlLinqType::XElement
SystemXmlLinqType::XName
SystemXmlLinqType::XNamespace
SystemXmlLinqType::XObject
SystemXmlLinqType::XProcessingInstruction
┌ type TypeAttributes

An opaque value; see the functions that return it.

┌ struct TypeDef
flagsTypeAttributes
namestr
namespacestr
extendsOption<TypeDefOrRef>
fieldslist<Entry>
methodslist<Entry>
propertieslist<Entry>
eventslist<Entry>
nested_typeslist<Entry>
generic_paramslist<Entry>
interfaceslist<InterfaceImpl>
method_implslist<MethodImpl>
class_layoutOption<ClassLayout>
securitylist<DeclSecurity>
custom_attributeslist<CustomAttribute>
declaring_typeWeakEntry
┌ type TypeDefEntry

A type defined in a module.

# type_def_entry.base_type() -> Option<BaseTypeRef>

The direct base type, if any.

# type_def_entry.custom_attributes() -> list<CustomAttribute>

The type's custom attributes.

# type_def_entry.enum_underlying_field() -> Option<FieldEntry>

For an enum, the instance field (value__) whose type is the enum's underlying type.

# type_def_entry.events() -> list<EventEntry>

The type's events.

# type_def_entry.extends_type(name: TypeName) -> bool

Whether this type's direct base type is name.

# type_def_entry.fields() -> list<FieldEntry>

The type's fields.

# type_def_entry.find_field(name: str) -> Option<FieldEntry>

The field named name.

# type_def_entry.find_method(name: str) -> Option<MethodEntry>

The first method named name.

# type_def_entry.full_name() -> str

"Namespace.Name", or "Namespace.Outer/Inner" for a nested type.

# type_def_entry.full_name_is(name: TypeName) -> bool

Whether this type's namespace and name are name.

# type_def_entry.is_delegate() -> bool

Whether it extends System.MulticastDelegate.

# type_def_entry.is_enum() -> bool

Whether it extends System.Enum.

# type_def_entry.is_interface() -> bool

Whether it is an interface.

# type_def_entry.is_nested() -> bool

Whether it is declared inside another type.

# type_def_entry.is_static() -> bool

Whether it is a static class: abstract and sealed, and not an interface.

# type_def_entry.is_value_type() -> bool

Whether it is a struct or enum.

# type_def_entry.is_visible() -> bool

Whether it is public, and if nested, only inside other visible types.

# type_def_entry.kind() -> TypeKind

Which kind of type it is: class, struct (value type), interface, enum or delegate.

# type_def_entry.methods() -> list<MethodEntry>

The type's methods.

# type_def_entry.name() -> str

The type's name, such as "Program".

# type_def_entry.namespace() -> str

The type's namespace; empty for a nested type.

# type_def_entry.nested_types() -> list<TypeDefEntry>

The types declared directly inside this one.

# type_def_entry.properties() -> list<PropertyEntry>

The type's properties.

# type_def_entry.top_level_namespace() -> str

The namespace of the outermost declaring type, for nested types.

# type_def_entry.with_nested() -> list<TypeDefEntry>

This type and every type nested in it, depth first.

┌ enum TypeDefOrRef
TypeDefOrRef::TypeDef(Entry)
TypeDefOrRef::TypeRef(Entry)
TypeDefOrRef::TypeSpec(Entry)
┌ enum TypeExtMethod
TypeExtMethod::GetTypeStatic
TypeExtMethod::GetMethodBF
TypeExtMethod::GetMethodsBF
┌ enum TypeKind

The broad kind of a [`TypeDef`], named with its C# keyword.

TypeKind::Class
TypeKind::ValueType
TypeKind::Interface
TypeKind::Enum
TypeKind::Delegate
┌ enum TypeMethod
TypeMethod::GetFullName
TypeMethod::GetName
TypeMethod::GetMethodStr
┌ struct TypeRef
scopeOption<ResolutionScope>`None` means the type is found through the `ExportedType` table.
namestr
namespacestr
custom_attributeslist<CustomAttribute>
┌ type TypeSigDef

An opaque value; see the functions that return it.

┌ struct TypeSpec
signatureTypeSig
custom_attributeslist<CustomAttribute>
┌ struct Version
majoru16
minoru16
buildu16
revisionu16
┌ struct WeakEntry

A non-owning [`Entry`] handle, used for back references like a method's declaring type.

0EntryInner
┌ enum WellKnown

A well-known .NET type, grouped by namespace. `from_full_name`, `full_name` and `name` strip the generic arity suffix (e.g. `Nullable\`1` -> `Nullable`).

WellKnown::System(SystemType)
WellKnown::SystemRuntimeCompilerServices(SystemRuntimeCompilerServicesType)
WellKnown::SystemCollectionsGeneric(SystemCollectionsGenericType)
WellKnown::SystemCollections(SystemCollectionsType)
WellKnown::SystemCollectionsObjectModel(SystemCollectionsObjectModelType)
WellKnown::SystemCollectionsSpecialized(SystemCollectionsSpecializedType)
WellKnown::SystemReflection(SystemReflectionType)
WellKnown::SystemDiagnostics(SystemDiagnosticsType)
WellKnown::SystemRuntimeExceptionServices(SystemRuntimeExceptionServicesType)
WellKnown::SystemRuntimeInteropServices(SystemRuntimeInteropServicesType)
WellKnown::SystemThreadingTasks(SystemThreadingTasksType)
WellKnown::SystemThreading(SystemThreadingType)
WellKnown::MicrosoftCSharpRuntimeBinder(MicrosoftCSharpRuntimeBinderType)
WellKnown::MicrosoftVisualBasic(MicrosoftVisualBasicType)
WellKnown::MicrosoftVisualBasicCompilerServices(MicrosoftVisualBasicCompilerServicesType)
WellKnown::MicrosoftVisualBasicApplicationServices(MicrosoftVisualBasicApplicationServicesType)
WellKnown::SystemRuntimeInteropServicesWindowsRuntime(SystemRuntimeInteropServicesWindowsRuntimeType)
WellKnown::WindowsFoundation(WindowsFoundationType)
WellKnown::SystemComponentModel(SystemComponentModelType)
WellKnown::SystemLinq(SystemLinqType)
WellKnown::SystemLinqExpressions(SystemLinqExpressionsType)
WellKnown::SystemXmlLinq(SystemXmlLinqType)
WellKnown::SystemSecurity(SystemSecurityType)
WellKnown::SystemSecurityPermissions(SystemSecurityPermissionsType)
WellKnown::SystemWindowsForms(SystemWindowsFormsType)
WellKnown::SystemRuntime(SystemRuntimeType)
WellKnown::SystemText(SystemTextType)
WellKnown::SystemThreadingTasksSources(SystemThreadingTasksSourcesType)
WellKnown::SystemIo(SystemIoType)
WellKnown::SystemGlobalization(SystemGlobalizationType)
┌ enum WellKnownMethod

A common BCL method, keyed by declaring type. Each variant wraps a per-type method sub-enum, e.g. `WellKnownMethod::Console(ConsoleMethod::WriteLineStr)`.

WellKnownMethod::Console(ConsoleMethod)
WellKnownMethod::Object(ObjectMethod)
WellKnownMethod::Type(TypeMethod)
WellKnownMethod::String(StringMethod)
WellKnownMethod::StringBuilder(StringBuilderMethod)
WellKnownMethod::Math(MathMethod)
WellKnownMethod::Convert(ConvertMethod)
WellKnownMethod::Environment(EnvironmentMethod)
WellKnownMethod::Gc(GcMethod)
WellKnownMethod::Marshal(MarshalMethod)
WellKnownMethod::Array(ArrayMethod)
WellKnownMethod::Exception(ExceptionMethod)
WellKnownMethod::Assembly(AssemblyMethod)
WellKnownMethod::TypeExt(TypeExtMethod)
WellKnownMethod::MethodBase(MethodBaseMethod)
WellKnownMethod::RuntimeMethodHandle(RuntimeMethodHandleMethod)
WellKnownMethod::RuntimeHelpers(RuntimeHelpersMethod)
WellKnownMethod::AppDomain(AppDomainMethod)
WellKnownMethod::AssemblyName(AssemblyNameMethod)
WellKnownMethod::MemberInfo(MemberInfoMethod)
WellKnownMethod::StringExt(StringExtMethod)
WellKnownMethod::ArrayList(ArrayListMethod)
WellKnownMethod::IEnumerable(IEnumerableMethod)
WellKnownMethod::IEnumerator(IEnumeratorMethod)
┌ enum WellKnownModule

A well-known .NET assembly a module references. Carries the stable assembly name and public-key token; the version is version-dependent and supplied separately (see [`AssemblyName`] impls, e.g. `(WellKnownModule, Version)`).

WellKnownModule::Mscorlib
WellKnownModule::SystemPrivateCoreLib
WellKnownModule::SystemRuntime
WellKnownModule::NetStandard
WellKnownModule::SystemConsole
WellKnownModule::SystemRuntimeExtensions
WellKnownModule::SystemCollections
WellKnownModule::SystemObjectModel
WellKnownModule::SystemLinq
WellKnownModule::SystemLinqExpressions
WellKnownModule::SystemRuntimeInteropServices
WellKnownModule::SystemThreadingTasks
WellKnownModule::SystemThreading
WellKnownModule::SystemComponentModelPrimitives
WellKnownModule::SystemXmlLinq
WellKnownModule::MicrosoftCSharp
WellKnownModule::MicrosoftVisualBasic
WellKnownModule::SystemWindowsForms
┌ enum WindowsFoundationType
WindowsFoundationType::IAsyncAction
WindowsFoundationType::IAsyncActionWithProgress_1
WindowsFoundationType::IAsyncOperation_1
WindowsFoundationType::IAsyncOperationWithProgress_2

> type aliases

Names these signatures use for a value of any of several types.

> examples

use std::io;
use std::re::dotnet;

fn main() -> Result<(), str> {
    let module = dotnet::open("Game.dll")?;
    for ty in module.all_types() {
        io::println("{} {}", ty.kind(), ty.full_name());
        for method in ty.methods() {
            let flags = dotnet::method_flags_names(method.flags());
            io::println("  {} {}", method.name(), flags);
        }
    }
    Ok(())
}
use std::re::dotnet;
use std::re::dotnet::{ConsoleMethod, WellKnownModule};

fn main() -> Result<(), str> {
    let sig = dotnet::sig;
    let module = dotnet::new("Hello", "console");
    module.add_assembly_ref(WellKnownModule::SystemConsole);
    let write_line = module.import_well_known_method(ConsoleMethod::WriteLineStr)?;
    let body = {
        let e = dotnet::il::emitter();
        e.ldstr("Hello from Xur!");
        e.call(write_line);
        e.ldc_i4(0);
        e.ret();
        e.finish()
    };
    let main_sig = sig::method_static(sig::int32(), [sig::sz_array(sig::string())]);
    let main = dotnet::public_static_method("Main", main_sig, body);
    let program = dotnet::static_class(module, "Hello", "Program");
    let entry = dotnet::add_method(program, main);
    module.add_type(program);
    module.set_entry_point(entry);
    module.write_to_path("Hello.dll")?;
    Ok(())
}