let assembly_load = 
    let resolver = new DefaultAssemblyResolver()
    let reader = ReaderParameters(ReadingMode.Immediate, 
AssemblyResolver=resolver)
    memoize (d0()) <| fun fullname -> 
        printfn "Loading %s..." fullname
        resolver.Resolve(AssemblyNameReference.Parse(fullname),reader)

---

I've implemented what you said, but it does not work regarding the problem 
I am talking about. I think the problem is that the *Resolve* method of 
*TypeReference* does not go through the resolver specified in 
*assembly_load*, but loads the *TypeDefinition* separately. There are no 
overloads for the *Resolve* method on *TypeReference*, so I cannot pass in 
the *ReaderParameters* unfortunately.

Dana utorak, 7. studenoga 2017. u 23:34:29 UTC+1, korisnik Jb Evain napisao 
je:
>
> The best way to achieve this is to control the assembly resolver that is 
> used across all your assemblies.
>
> You can achieve that by using the overload of ReadModule/ReadAssembly that 
> takes a ReaderParameter, and pass one resolver to it.
> Same for resolving, in your case, use the Resolve overload that takes a 
> ReaderParameter, create one and set its AssemblyResolver to your unique 
> resolver.
>
> This way you'll be able to compare TypeDefinition instances by identity.
>
> Jb
>
> On Tue, Nov 7, 2017 at 3:32 AM, Marko Grdinic <[email protected] 
> <javascript:>> wrote:
>
>> open Mono.Cecil
>>
>> let resolver = new DefaultAssemblyResolver()
>> let assembly_load fullname = 
>> resolver.Resolve(AssemblyNameReference.Parse(fullname)).MainModule
>> let mscorlib = assembly_load "mscorlib"
>> let fsharp_core = assembly_load "FSharp.Core, Version=4.4.0.0, 
>> Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
>>
>> let bool = mscorlib.GetType("System.Boolean")
>> let ops = fsharp_core.GetType("Microsoft.FSharp.Core.Operators")
>> let isNull =
>>     ops.Methods
>>     |> Seq.find (fun x -> x.Name = "IsNull")
>>
>> isNull.ReturnType.Resolve() = bool // false
>> // Is there any way to make this resolve to the same type?
>>
>> ---
>>
>> Since I am using TypeDefinitions in dictionaries, I need the equality to 
>> be firm. The above is the final hurdle before I can finish the rewrite and 
>> make the interop module work with Mono.Cecil.
>>
>> -- 
>> -- 
>> --
>> mono-cecil
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "mono-cecil" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
-- 
--
mono-cecil
--- 
You received this message because you are subscribed to the Google Groups 
"mono-cecil" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to