namespace WoofWare.PawPrint
open System.Collections.Immutable
open System.Reflection
open System.Reflection.Metadata
///
/// Represents a method specification, which provides information about a method,
/// particularly for generic method instantiations.
///
type MethodSpec =
{
///
/// The token that identifies the method being specialized.
///
Method : MetadataToken
///
/// The actual type arguments for generic instantiation.
///
///
/// For Volatile.Read<System.IO.TextWriter>, the Signature is [System.IO.TextWriter].
///
///
/// The contents might themselves be TypeDefn.GenericMethodParameter, for example.
/// This happens when the method is itself being called from within a generic method, and the generic parameters
/// of the spec are being instantiated with generic parameters from the caller.
///
Signature : TypeDefn ImmutableArray
}
[]
module MethodSpec =
let make (assemblyName : AssemblyName) (p : MethodSpecification) : MethodSpec =
let signature = p.DecodeSignature (TypeDefn.typeProvider assemblyName, ())
{
// Horrible abuse to get this as an int
Method = MetadataToken.ofInt (p.Method.GetHashCode ())
Signature = signature
}