anchor.diff:  open Microsoft.FSharp.Reflection
   open ProviderImplementation.ProvidedTypes
   
  +/// When we split a type provider into a runtime assembly and a design time assembly, we can no longer 
  +/// use quotations directly, because they will reference the wrong types. AssemblyReplacer fixes that 
  +/// by transforming the expressions generated by the quotations to have the right types. On all 
  +/// expressions  that we provide to InvokeCode and GetterCode of ProvidedMethod, ProvidedConstructor,
  +/// and ProvidedProperty, instead of (fun args -> <@@ doSomethingWith(%%args) @@>), we should use 
  +/// (fun args -> let args = replacer.ToDesignTime args in replacer.ToRuntime <@@ doSomethingWith(%%args) @@>)
  +/// When creating the Provided* type, we have to always specify the runtime type, and when it invokes
  +/// the function provided to InvokeCode and GetterCode, we to first transform the argument expressions
  +/// to the design time types, so we can splice it in the quotation, and then after that we have to convert
  +/// it back to the runtime type. A further complication arises because Expr.Var's have reference equality, so
  +/// when can't just create new Expr.Var's with the same variable name and a different type. When transforming
  +/// them from runtime to design time we keep them in a dictionary, so that when we convert them back to runtime
  +/// we can return the exact same instance that was provided to us initially.
  +/// Another limitation (not only of this method, but in general with type providers) is that we can never use 
  +/// expressions that use F# functions as parameters or return values, we always have to use felegates instead.
   type AssemblyReplacer =
  -  abstract member ToRuntime : Type -> Type
  -  abstract member ToRuntime : Expr -> Expr
  -  abstract member ToDesignTime: Expr -> Expr
  +
  +  /// Gets the equivalent runtime type
  +  abstract member ToRuntime : designTimeType:Type -> Type
  +
  +  /// Gets an equivalent expression with all the types replaced with runtime equivalents
  +  abstract member ToRuntime : designTimeTypeExpr:Expr -> Expr
  +
  +  /// Gets an equivalent expression with all the types replaced with designTime equivalents
  +  abstract member ToDesignTime: runtimeExpr:Expr -> Expr
   
   [<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
  -module private AssemblyReplacer =
  -
  +module AssemblyReplacer =
  +
  +  // we use a list for asmMappings because the Assembly type is not
  +  // an IComparable and can't be stored in a map
     let private replace asmMappings (original, originalAsms) f =
       let toAsm = 
         asmMappings
  
positive.code: ﻿// --------------------------------------------------------------------------------------
  //
  // --------------------------------------------------------------------------------------
  
  namespace ProviderImplementation
  
negative.code:     | None -> lazyOriginal.Value
  
    let private getType (asm:Assembly) (t:Type) rt =
      let fixName (fullName:string) =
        if fullName.StartsWith("FSI_") then 
          // when F# Interactive is the host of the design time assembly,
          // all namespaces are prefixed with FSI_, in the runtime assembly
          // the name won't have that prefix
          fullName.Substring(fullName.IndexOf('.') + 1)
        else 
          fullName
      let getType fullName =
        if asm.GetName().Name = "FSI-ASSEMBLY" then
          // when F# Interactive is the host of the design time assembly,
          // for each type in the runtime assembly there might be multiple
          // versions (FSI_0001.FullTypeName, FSI_0002.FullTypeName, etc).
          // Get the last one.
          asm.GetTypes() 
          |> Seq.filter (fun t -> (fixName t.FullName) = fullName)
          |> Seq.sortBy (fun t -> t.FullName)
          |> Seq.last
        else
          asm.GetType fullName
      let newT =
        if t.IsGenericType && not t.IsGenericTypeDefinition then 
          let genericType = t.GetGenericTypeDefinition()
          let newT = getType (fixName genericType.FullName)
          if newT = null then 
            null
          else
  