anchor.diff:      open Eval
       /// Returns true if method has specified attribute
       let hasAttribute a (mi:MethodInfo) = mi.GetCustomAttributes(a, true).Length > 0
  -    /// Converts expression to a tuple of MethodInfo and Arg array
  -
  -    let toCallArg arg = 
  -        match arg with
  -        | Call(_, mi, _) when hasAttribute typeof<WildcardAttribute> mi -> Any
  -        | Call(_, mi, [pred]) when hasAttribute typeof<PredicateAttribute> mi -> Pred(eval pred)
  -        | _ -> raise (NotSupportedException ())
  -
  +    /// Matches attributed calls
  +    let (|AttributedArg|_|) = function       
  +        | Call(_, mi, _) when hasAttribute typeof<WildcardAttribute> mi -> Some Any
  +        | Call(_, mi, [pred]) when hasAttribute typeof<PredicateAttribute> mi -> Some (Pred(eval pred))
  +        | _ -> None
  +    /// Converts parameter to arguments
       let rec toArg (pi:ParameterInfo,arg) =
           match pi, arg with
  -        | _, Call _ -> toCallArg arg
  +        | _, AttributedArg arg -> arg
           | pi, NewArray(_,args) when pi <> null && pi.GetCustomAttributes(typeof<ParamArrayAttribute>, true).Length > 0 ->
              ArgArray [|for arg in args -> toArg(null, arg)|]
  -        | _, expr -> eval expr |> Arg 
  +        | _, expr -> eval expr |> Arg
  +    /// Converts parameters to arguments
       let toArgs ps args = [|for arg in Seq.zip ps args -> toArg arg |]
       /// Active pattern matches method call expressions
       let (|MethodCall|_|) expr =
  
positive.code:         generateReturn il (returnValues,returnValuesField) (mi,result)
          il.MarkLabel(unmatched)
  
      /// Defines a type builder for the specified abstract type
      let defineType (abstractType:Type) =
          /// Stub name for abstract type
          let mockName = "Mock." + abstractType.Name.Replace("'", "!")
          /// Builder for assembly
          let assemblyBuilder =
              AppDomain.CurrentDomain.DefineDynamicAssembly(AssemblyName(mockName),AssemblyBuilderAccess.Run)
          /// Builder for module
          let moduleBuilder = assemblyBuilder.DefineDynamicModule(mockName+".dll")
          let parent, interfaces = 
              if abstractType.IsInterface
              then typeof<obj>, [|abstractType|]
              else abstractType, [||]
          let attributes = TypeAttributes.Public ||| TypeAttributes.Class
          let interfaces = [|yield typeof<IMockObject>; yield! interfaces|]
          moduleBuilder.DefineType(mockName, attributes, parent, interfaces)
  
      /// Builds a mock from the specified calls
      let mock (isStrict, abstractType:Type, calls:(MethodInfo * (Arg[] * Result)) list, args:obj[]) =
  
negative.code:             | PropertySet(Some(x), pi, args, value) -> 
                  x, pi.GetSetMethod(), toArgs [yield! pi.GetIndexParameters();yield null] [yield! args;yield value]
              | expr -> raise <| NotSupportedException(expr.ToString())
          // Handle applications of functions and standard functions
          match quote with
          | Application (_, _) -> unwrapApplication quote
          | _ -> unwrapStandard quote
      /// Converts expression to call checking expected type
      let toCallOf abstractType expr =
          match toCall expr with
          | x, mi, args when x.Type = abstractType -> mi, args
          | _ -> raise <| NotSupportedException(expr.ToString())   
      /// Converts Mock.With expressions to calls with expected results list
      let rec toCallResult = function
          | ForIntegerRangeLoop(v,a,b,y) -> [for i = eval a :?> int to eval b :?> int do yield! toCallResult y]
          | Sequential(x,y) -> toCallResult x @ toCallResult y
  