I am working on a TypeProvider that reads an XSD file and provides a type for each type defined in XSD. However, I have a problem in the code below
type schema = XmlProviders.Schema<"file.xsd"> type Bazzer = { Sum : XmlProviders.bar }
in the last line, I get a compilation error saying that XmlProviders.bar does not exist. The implementation of how I define types is 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>)
I know that the XmlProviders.bar type is being created, because if I add an extra line to define Type provider.AddMember t , then I get an error
A provider of type "XmlProviders.SampleTypeProvider" reported an error: the container type for "XmlProviders.bar" was already set to "XmlProviders.Schema"
Where XmlProviders.Schema is the ProvidedTypeDefinition identified by provider
I lost a little because the compiler complains that this type is not there, if I explicitly add it, I get an error message that it is already there
source share