fsprojects / FSharp.TypeProviders.SDK

The SDK for creating F# type providers
https://fsprojects.github.io/FSharp.TypeProviders.SDK/
MIT License
298 stars 94 forks source link

Compile-time error when using SqlEnumProvider after upgrading to latest version of SDK #270

Closed samhanes closed 5 years ago

samhanes commented 5 years ago

Description

After upgrading FSharp.Data.SqlClient to the latest version of the SDK, I am seeing compile-time errors for tests using SqlEnumProvider, which is a generative provider. At design time, the provided types are working as expected.

The error at compile time:

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.

I also see the following in the output:

1>output error FS0073: error : One of your modules expects the type 'FSharp.Data.EnumTests.TinyIntMapping' to be defined within the module being emitted.  You may be missing an input file
1>output error FS0073: error : The local field Items was referenced but not declared
1>output error FS0073: error : One of your modules expects the type 'FSharp.Data.EnumTests.TinyIntMapping' to be defined within the module being emitted.  You may be missing an input file

Repro steps

  1. Fetch the branch used here: https://github.com/fsprojects/FSharp.Data.SqlClient/pull/315

  2. Run build.fsx, type provider will build but tests will fail to compile.

  3. Open Tests.sln and observe that design-time behavior in SqlEnumTests.fs is as expected.

Expected behavior

SqlClient.Tests project should compile.

Actual behavior

Error when compiling SqlClient.Tests.

Known workarounds

None

Related information

sergey-tihon commented 5 years ago

Is it possible to create Test for this repo with TP that provide enums? I see that @Dzoukr is also interested in such sample/test #264

Dzoukr commented 5 years ago

Thanks for pinging me - I updated #264 with snippet of my usage, but as written there - there must be cleaner way.

samhanes commented 5 years ago

I was able to resolve this issue - we were incorrectly adding both the root types and the provider type to the executing assembly. After updating usage to match the example in the template, the compiler error is resolved.

I'm now seeing a different issue, but it may not be related - going to investigate a bit more before I close this. Please don't spend any time on this for now!