Getting compile error on provided type

I'm working on a TypeProvider that reads an XSD file and provides a type for each type defined in the XSD. However I have a problem in the below code

type schema = XmlProviders.Schema<"file.xsd">
type Bazzer = {
    Sum : XmlProviders.bar
}

on the last line I get a compilation error saying that XmlProviders.bar does not exist. The implementation of how I define the types are as follows

let defineType (xType : XElement) =
    let name = xType.Attribute(XName.Get "name").Value
    let t = ProvidedTypeDefinition(thisAssembly,
                                       ns,
                                       name,
                                       baseType = Some typeof<obj>)

    let ctor = ProvidedConstructor(parameters = [ ], 
                                   InvokeCode= (fun args -> <@@ "" :> obj @@>))
    t.AddMember ctor



 do provider.DefineStaticParameters(parameters, fun tyName args ->

    let filename = args.[0] :?> string
    let main = ProvidedTypeDefinition(thisAssembly,ns,
                                       tyName,
                                       baseType = Some typeof<obj>)

    //Elements is a list of XElement
    elements |> List.map defineType |> ignore
    main

I know that a XmlProviders.bar type is created because if I add an additional line to defineType provider.AddMember t then I get an error saying

The type provider 'XmlProviders.SampleTypeProvider' reported an error: container type for 'XmlProviders.bar' was already set to 'XmlProviders.Schema'

Where XmlProviders.Schema is the ProvidedTypeDefinition identified by provider

I'm a bit lost on why the compiler complains that the type is not there while if I explicitly add it I get the error that it's already there

Answers


Found the answer, so to those that end in the same situation

the line

let t = ProvidedTypeDefinition(thisAssembly,
                                   ns,
                                   name,
                                   baseType = Some typeof<obj>)

where the nested type is defined should be without assembly and namespace

let t = ProvidedTypeDefinition(name,baseType = Some typeof<obj>)

Need Your Help

Experienced HTML/CSS programmer trying to “jump” to dynamic stuff

php wordpress content-management-system cpanel roundcube

I've mastered the art of the static website, and now I'm picking up books on PHP, SQL, PEAR, etc so I can get a better handle of making a database-driven website. Now, I'm helping a small startup c...

Checkboxes are not saved in the txt file

php jquery html checkbox

I have purchased a template from a well-known website. I have tweaked the lay-out of the template to my needs. But I can't figure out how to code the checkboxes in PHP to save them - when someone c...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.