Skip to content

Wrong namespace for generative TypeProviders #384

@thinkbeforecoding

Description

@thinkbeforecoding

Description

The WsdlProvider is a generative provider due to the use of WCF. To implement Wsdl Choice elements, some properties must have an attribute referencing the Type of provided classes.

When generating the typeof, the namespace emitted is the generic one used in the TP, but the type is actually emitted in the user's code namespace. When used, the actual type cannot be found.

Repro steps

  1. Create a generative TP type provider
  2. In the type generation, create a ProvidedTypeDefinition call MyObject in TpNS namespace
  3. In a provided function, emit a typeof this type.
  4. Write a sample that use the type provider in a Sample namespace

Expected behavior

When running the sample, the type should be found in the Sample namespace

Actual behavior

The typeof jitting will fail, indicating that the type TpNS.MyObject cannot be found. The class is actually in Sample.MyObject.

Known workarounds

There is no known workaround.

Is there a way to get the actual namespace where the generated code will be compiled ? Is this information available in the TypeProvider ?

Related information

  • All
  • main
  • .NET Runtime & CoreCLR at least

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions