anchor.diff:          | _ -> null
       
   type XamlId =  
  -| XamlId of FilePosition * string
  +| Named of FilePosition * string
  +| Unnamed of FilePosition
  +    member this.Position =
  +        match this with
  +        | Named(pos, _) | Unnamed(pos) -> pos
   
   type XamlElementInfo =
  -| XamlElementInfo of XamlId option * string
  +| XamlElementInfo of XamlId * string
   
  +type XamlNode =
  +    { NodeType : Type
  +      Data : XamlId
  +      Children : XamlNode list }
  +
  +(*
   type XamlFile = 
       { Root : Type
         Position : FilePosition
  
positive.code:         | null -> typeof<obj>
          | st -> st
     
  let readXamlFile info (xaml:XmlReader) =
      let rec readElementChildren () = 
          seq {
              let more = ref true
              while !more && not xaml.EOF do
                  match xaml.Read() with
                  | false -> more := false
                  | true -> 
                      match xaml.NodeType with
                      | XmlNodeType.Element -> 
                          match infoOfXamlElement info xaml with                                                             
                          |   Some (XamlElementInfo(name,typeName)) ->
                                  match name with
                                  |   None -> () // TODO: No name given
                                  |   Some xamlId -> yield (xamlId, typeOfXamlElement typeName)
                                  if not xaml.IsEmptyElement then yield! readElementChildren()
                          |   None -> ()
                      | XmlNodeType.EndElement -> more := false
                      | _ -> ()
          }
          
      let getXamlFileFromRootElement() =
          match  infoOfXamlElement info xaml with
          |   Some (XamlElementInfo(_name,typeName)) ->                 
                  { Root = typeOfXamlElement typeName 
                    Position = posOfReader info xaml
                    Children = readElementChildren() |> Seq.toList }
          |   None -> XamlFile.FileStart info.FileName
  
      match xaml.Read() with
      | false -> XamlFile.FileStart info.FileName
      | true ->                
          if xaml.NodeType = XmlNodeType.XmlDeclaration then
              xaml.Read() |> ignore
          if xaml.NodeType = XmlNodeType.Element then
              getXamlFileFromRootElement()
          else failwithf "Expected Root element but got %A" xaml.NodeType
  
  let createXmlReader(textReader:TextReader) =
      XmlReader.Create(textReader, XmlReaderSettings(IgnoreProcessingInstructions = true, IgnoreWhitespace = true))
  
  let createTypeFromReader typeName (xamlInfo:XamlInfo) (reader: TextReader) =
      let xaml = 
          createXmlReader(reader) 
          |> readXamlFile (fileStart xamlInfo.FileName)
  
      eraseType thisAssembly rootNamespace typeName xaml.Root
          |> addDefinitionLocation xaml.Position
          |+> (provideConstructor
                  [] 
                  (fun args -> 
                      match xamlInfo with 
                      | XamlInfo.Path path -> Expr.Coerce(<@@ XamlReader.Parse(File.ReadAllText(path)) @@>, xaml.Root)
                      | XamlInfo.Text text -> Expr.Coerce(<@@ XamlReader.Parse(text) @@>, xaml.Root))
              |> addXmlDoc (sprintf "Initializes a %s instance" typeName)
              |> addDefinitionLocation xaml.Position)
          |++> (xaml.Children
                  |> List.map 
                      (fun (XamlId(pos, propertyName), resultType) ->
                          provideProperty
                              propertyName
                              resultType
                              (fun args -> Expr.Coerce(<@@ (%%args.[0]:Window).FindName(propertyName) @@>, resultType))
                          |> addDefinitionLocation pos))
          
  let xamlFileTypeUninstantiated invalidateF (cfg:TypeProviderConfig) =
      erasedType<obj> thisAssembly rootNamespace "XamlFile"
  
negative.code:         { Root = typeof<obj>
            Position = fileStart fileName
            Children = [] }
  *)
  
  let posOfReader filename (xaml:XmlReader) = 
      let lineInfo = xaml :> obj :?> IXmlLineInfo
      { Line = lineInfo.LineNumber
        Column = lineInfo.LinePosition
        FileName = filename }
  
  let infoOfXamlElement filename (xaml:XmlReader) =
      try
          let pos = posOfReader filename xaml
          let name = 
              match xaml.GetAttribute("Name") with
              | name when name <> null -> Named (pos, name)
              | _ ->
                  match xaml.GetAttribute("x:Name") with
                  | name when name <> null -> Named (pos, name)
                  | _ -> Unnamed (pos)
          
          XamlElementInfo(name,xaml.Name) |> Some
      with
  