Search code examples
f#type-providersfsharp.data.sqlclient

Compile-time error with generative type provider


I've run into an issue with on a branch of FSharp.Data.SqlClient I am working on with the generative SqlEnumProvider type provider. When the test project attemps to use a provided type, I get the following compile-time error:

A problem occurred writing the binary 'C:\code\FSharp.Data.SqlClient\src\SqlClient.Tests\obj\Debug\net451\SqlClient.Tests.dll': Error in pass3 for type FSharp.Data.EnumTests, error: Error in GetMethodRefAsMethodDefIdx for mref = ("Parse", "TinyIntMapping"), error: Exception of type 'Microsoft.FSharp.Compiler.AbstractIL.ILBinaryWriter+MethodDefNotFound' was thrown.

At design time, everything appears to be working as expected. (I have intellisense on the provided types, etc.)

I attempted the workaround suggested here, but no joy.


Solution

  • It turns out the answer was in the sample template in the SDK, I just wasn't reading it closely enough:

    • The provider type (e.g., SqlEnumProvider) should be added to the executing assembly.
    • The root types (e.g., SqlEnumProvider<"SELECT * FROM (VALUES(('One'), 1), ('Two', 2)) AS T(Tag, Value)">) should be added to the provided assembly.

    In the failing code, we were adding the root types to both assemblies.